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 * SPDX-License-Identifier: GPL-2.0-only
6 *
7 * Authors: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
8 * Sidharth Nabar <snabar@uw.edu>, He Wu <mdzz@u.washington.edu>
9 */
10
11#ifndef DEVICE_ENERGY_MODEL_CONTAINER_H
12#define DEVICE_ENERGY_MODEL_CONTAINER_H
13
14#include "device-energy-model.h"
15
16#include <stdint.h>
17#include <vector>
18
19namespace ns3
20{
21namespace energy
22{
23
24/**
25 * \ingroup energy
26 * \brief Holds a vector of ns3::DeviceEnergyModel pointers.
27 *
28 * DeviceEnergyModelContainer returns a list of DeviceEnergyModel pointers
29 * installed on a node. Users can use this list to access DeviceEnergyModel
30 * objects to obtain total device energy consumption on a node easily.
31 *
32 * \see NetDeviceContainer
33 *
34 */
36{
37 public:
38 /// Const iterator of DeviceEnergyModel container
39 typedef std::vector<Ptr<DeviceEnergyModel>>::const_iterator Iterator;
40
41 public:
42 /**
43 * Creates an empty DeviceEnergyModelContainer.
44 */
46
47 /**
48 * \param model Pointer to a DeviceEnergyModel.
49 *
50 * Creates a DeviceEnergyModelContainer with exactly one DeviceEnergyModel
51 * previously instantiated.
52 */
54
55 /**
56 * \param modelName Name of DeviceEnergyModel.
57 *
58 * Creates an DeviceEnergyModelContainer with exactly one DeviceEnergyModel
59 * previously instantiated and assigned a name using the Object name service.
60 * This DeviceEnergyModel is specified by its assigned name.
61 */
62 DeviceEnergyModelContainer(std::string modelName);
63
64 /**
65 * \param a A DeviceEnergyModelContainer.
66 * \param b Another DeviceEnergyModelContainer.
67 *
68 * Creates a DeviceEnergyModelContainer by concatenating DeviceEnergyModelContainer b
69 * to DeviceEnergyModelContainer a.
70 *
71 * \note Can be used to concatenate 2 Ptr<DeviceEnergyModel> directly. C++
72 * will be calling DeviceEnergyModelContainer constructor with Ptr<DeviceEnergyModel>
73 * first.
74 */
77
78 /**
79 * \brief Get an iterator which refers to the first DeviceEnergyModel pointer
80 * in the container.
81 *
82 * \returns An iterator which refers to the first DeviceEnergyModel in container.
83 *
84 * DeviceEnergyModels can be retrieved from the container in two ways. First,
85 * directly by an index into the container, and second, using an iterator.
86 * This method is used in the iterator method and is typically used in a
87 * for-loop to run through the DeviceEnergyModels.
88 *
89 * \code
90 * DeviceEnergyModelContainer::Iterator i;
91 * for (i = container.Begin (); i != container.End (); ++i)
92 * {
93 * (*i)->method (); // some DeviceEnergyModel method
94 * }
95 * \endcode
96 */
97 Iterator Begin() const;
98
99 /**
100 * \brief Get an iterator which refers to the last DeviceEnergyModel pointer
101 * in the container.
102 *
103 * \returns An iterator which refers to the last DeviceEnergyModel in container.
104 *
105 * DeviceEnergyModels can be retrieved from the container in two ways. First,
106 * directly by an index into the container, and second, using an iterator.
107 * This method is used in the iterator method and is typically used in a
108 * for-loop to run through the DeviceEnergyModels.
109 *
110 * \code
111 * DeviceEnergyModelContainer::Iterator i;
112 * for (i = container.Begin (); i != container.End (); ++i)
113 * {
114 * (*i)->method (); // some DeviceEnergyModel method
115 * }
116 * \endcode
117 */
118 Iterator End() const;
119
120 /**
121 * \brief Get the number of Ptr<DeviceEnergyModel> stored in this container.
122 *
123 * \returns The number of Ptr<DeviceEnergyModel> stored in this container.
124 */
125 uint32_t GetN() const;
126
127 /**
128 * \brief Get the i-th Ptr<DeviceEnergyModel> stored in this container.
129 *
130 * \param i Index of the requested Ptr<DeviceEnergyModel>.
131 * \returns The requested Ptr<DeviceEnergyModel>.
132 */
134
135 /**
136 * \param container Another DeviceEnergyModelContainer.
137 *
138 * Appends the contents of another DeviceEnergyModelContainer to the end of
139 * this DeviceEnergyModelContainer.
140 */
141 void Add(DeviceEnergyModelContainer container);
142
143 /**
144 * \brief Append a single Ptr<DeviceEnergyModel> to the end of this container.
145 *
146 * \param model Pointer to an DeviceEnergyModel.
147 */
148 void Add(Ptr<DeviceEnergyModel> model);
149
150 /**
151 * \brief Append a single Ptr<DeviceEnergyModel> referred to by its object
152 * name to the end of this container.
153 *
154 * \param modelName Name of DeviceEnergyModel object.
155 */
156 void Add(std::string modelName);
157
158 /**
159 * \brief Removes all elements in the container.
160 */
161 void Clear();
162
163 private:
164 std::vector<Ptr<DeviceEnergyModel>> m_models; //!< Container of Energy models
165};
166
167} // namespace energy
168} // namespace ns3
169
170#endif /* DEVICE_ENERGY_MODEL_CONTAINER_H */
Smart pointer class similar to boost::intrusive_ptr.
Holds a vector of ns3::DeviceEnergyModel pointers.
void Add(DeviceEnergyModelContainer container)
std::vector< Ptr< DeviceEnergyModel > >::const_iterator Iterator
Const iterator of DeviceEnergyModel container.
std::vector< Ptr< DeviceEnergyModel > > m_models
Container of Energy models.
Ptr< DeviceEnergyModel > Get(uint32_t i) const
Get the i-th Ptr<DeviceEnergyModel> stored in this container.
DeviceEnergyModelContainer()
Creates an empty DeviceEnergyModelContainer.
Iterator End() const
Get an iterator which refers to the last DeviceEnergyModel pointer in the container.
Iterator Begin() const
Get an iterator which refers to the first DeviceEnergyModel pointer in the container.
void Clear()
Removes all elements in the container.
uint32_t GetN() const
Get the number of Ptr<DeviceEnergyModel> stored in this container.
Every class exported by the ns3 library is enclosed in the ns3 namespace.