A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
device-energy-model-container.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2008 INRIA
3 * Copyright (c) 2010 Network Security Lab, University of Washington, Seattle.
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation;
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 *
18 * Authors: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
19 * Sidharth Nabar <snabar@uw.edu>, He Wu <mdzz@u.washington.edu>
20 */
21
22#ifndef DEVICE_ENERGY_MODEL_CONTAINER_H
23#define DEVICE_ENERGY_MODEL_CONTAINER_H
24
25#include "device-energy-model.h"
26
27#include <stdint.h>
28#include <vector>
29
30namespace ns3
31{
32
33/**
34 * \ingroup energy
35 * \brief Holds a vector of ns3::DeviceEnergyModel pointers.
36 *
37 * DeviceEnergyModelContainer returns a list of DeviceEnergyModel pointers
38 * installed on a node. Users can use this list to access DeviceEnergyModel
39 * objects to obtain total device energy consumption on a node easily.
40 *
41 * \see NetDeviceContainer
42 *
43 */
45{
46 public:
47 /// Const iterator of DeviceEnergyModel container
48 typedef std::vector<Ptr<DeviceEnergyModel>>::const_iterator Iterator;
49
50 public:
51 /**
52 * Creates an empty DeviceEnergyModelContainer.
53 */
55
56 /**
57 * \param model Pointer to a DeviceEnergyModel.
58 *
59 * Creates a DeviceEnergyModelContainer with exactly one DeviceEnergyModel
60 * previously instantiated.
61 */
63
64 /**
65 * \param modelName Name of DeviceEnergyModel.
66 *
67 * Creates an DeviceEnergyModelContainer with exactly one DeviceEnergyModel
68 * previously instantiated and assigned a name using the Object name service.
69 * This DeviceEnergyModel is specified by its assigned name.
70 */
71 DeviceEnergyModelContainer(std::string modelName);
72
73 /**
74 * \param a A DeviceEnergyModelContainer.
75 * \param b Another DeviceEnergyModelContainer.
76 *
77 * Creates a DeviceEnergyModelContainer by concatenating DeviceEnergyModelContainer b
78 * to DeviceEnergyModelContainer a.
79 *
80 * \note Can be used to concatenate 2 Ptr<DeviceEnergyModel> directly. C++
81 * will be calling DeviceEnergyModelContainer constructor with Ptr<DeviceEnergyModel>
82 * first.
83 */
86
87 /**
88 * \brief Get an iterator which refers to the first DeviceEnergyModel pointer
89 * in the container.
90 *
91 * \returns An iterator which refers to the first DeviceEnergyModel in container.
92 *
93 * DeviceEnergyModels can be retrieved from the container in two ways. First,
94 * directly by an index into the container, and second, using an iterator.
95 * This method is used in the iterator method and is typically used in a
96 * for-loop to run through the DeviceEnergyModels.
97 *
98 * \code
99 * DeviceEnergyModelContainer::Iterator i;
100 * for (i = container.Begin (); i != container.End (); ++i)
101 * {
102 * (*i)->method (); // some DeviceEnergyModel method
103 * }
104 * \endcode
105 */
106 Iterator Begin() const;
107
108 /**
109 * \brief Get an iterator which refers to the last DeviceEnergyModel pointer
110 * in the container.
111 *
112 * \returns An iterator which refers to the last DeviceEnergyModel in container.
113 *
114 * DeviceEnergyModels can be retrieved from the container in two ways. First,
115 * directly by an index into the container, and second, using an iterator.
116 * This method is used in the iterator method and is typically used in a
117 * for-loop to run through the DeviceEnergyModels.
118 *
119 * \code
120 * DeviceEnergyModelContainer::Iterator i;
121 * for (i = container.Begin (); i != container.End (); ++i)
122 * {
123 * (*i)->method (); // some DeviceEnergyModel method
124 * }
125 * \endcode
126 */
127 Iterator End() const;
128
129 /**
130 * \brief Get the number of Ptr<DeviceEnergyModel> stored in this container.
131 *
132 * \returns The number of Ptr<DeviceEnergyModel> stored in this container.
133 */
134 uint32_t GetN() const;
135
136 /**
137 * \brief Get the i-th Ptr<DeviceEnergyModel> stored in this container.
138 *
139 * \param i Index of the requested Ptr<DeviceEnergyModel>.
140 * \returns The requested Ptr<DeviceEnergyModel>.
141 */
143
144 /**
145 * \param container Another DeviceEnergyModelContainer.
146 *
147 * Appends the contents of another DeviceEnergyModelContainer to the end of
148 * this DeviceEnergyModelContainer.
149 */
150 void Add(DeviceEnergyModelContainer container);
151
152 /**
153 * \brief Append a single Ptr<DeviceEnergyModel> to the end of this container.
154 *
155 * \param model Pointer to an DeviceEnergyModel.
156 */
157 void Add(Ptr<DeviceEnergyModel> model);
158
159 /**
160 * \brief Append a single Ptr<DeviceEnergyModel> referred to by its object
161 * name to the end of this container.
162 *
163 * \param modelName Name of DeviceEnergyModel object.
164 */
165 void Add(std::string modelName);
166
167 /**
168 * \brief Removes all elements in the container.
169 */
170 void Clear();
171
172 private:
173 std::vector<Ptr<DeviceEnergyModel>> m_models; //!< Container of Energy models
174};
175
176} // namespace ns3
177
178#endif /* DEVICE_ENERGY_MODEL_CONTAINER_H */
Holds a vector of ns3::DeviceEnergyModel pointers.
void Clear()
Removes all elements in the container.
DeviceEnergyModelContainer()
Creates an empty DeviceEnergyModelContainer.
std::vector< Ptr< DeviceEnergyModel > >::const_iterator Iterator
Const iterator of DeviceEnergyModel container.
uint32_t GetN() const
Get the number of Ptr<DeviceEnergyModel> stored in this container.
void Add(DeviceEnergyModelContainer container)
Iterator Begin() const
Get an iterator which refers to the first DeviceEnergyModel pointer in the container.
std::vector< Ptr< DeviceEnergyModel > > m_models
Container of Energy models.
Iterator End() const
Get an iterator which refers to the last DeviceEnergyModel pointer in the container.
Ptr< DeviceEnergyModel > Get(uint32_t i) const
Get the i-th Ptr<DeviceEnergyModel> stored in this container.
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
Every class exported by the ns3 library is enclosed in the ns3 namespace.