A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
energy-source-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 ENERGY_SOURCE_CONTAINER_H
23#define ENERGY_SOURCE_CONTAINER_H
24
25#include "ns3/energy-source.h"
26#include "ns3/object.h"
27
28#include <stdint.h>
29#include <vector>
30
31namespace ns3
32{
33namespace energy
34{
35
36/**
37 * \ingroup energy
38 * \brief Holds a vector of ns3::EnergySource pointers.
39 *
40 * EnergySourceHelper returns a list of EnergySource pointers installed onto a
41 * node. Users can use this list to access EnergySource objects to obtain total
42 * energy consumption on a node easily.
43 *
44 * \see NetDeviceContainer
45 *
46 */
48{
49 public:
50 /// Const iterator for EnergySource container
51 typedef std::vector<Ptr<EnergySource>>::const_iterator Iterator;
52
53 public:
54 /**
55 * \brief Get the type ID.
56 * \return The object TypeId.
57 */
58 static TypeId GetTypeId();
59 /**
60 * Creates an empty EnergySourceContainer.
61 */
63 ~EnergySourceContainer() override;
64
65 /**
66 * \param source Pointer to an EnergySource.
67 *
68 * Creates an EnergySourceContainer with exactly one EnergySource previously
69 * instantiated.
70 */
72
73 /**
74 * \param sourceName Name of EnergySource.
75 *
76 * Creates an EnergySourceContainer with exactly one EnergySource previously
77 * instantiated and assigned a name using the Object name service. This
78 * EnergySource is specified by its assigned name.
79 */
80 EnergySourceContainer(std::string sourceName);
81
82 /**
83 * \param a A EnergySourceContainer.
84 * \param b Another EnergySourceContainer.
85 *
86 * Creates an EnergySourceContainer by concatenating EnergySourceContainer b
87 * to EnergySourceContainer a.
88 *
89 * \note Can be used to concatenate 2 Ptr<EnergySource> directly. C++ will be
90 * calling EnergySourceContainer constructor with Ptr<EnergySource> first.
91 */
93
94 /**
95 * \brief Get an iterator which refers to the first EnergySource pointer in
96 * the container.
97 *
98 * \returns An iterator which refers to the first EnergySource in container.
99 *
100 * EnergySources can be retrieved from the container in two ways. First,
101 * directly by an index into the container, and second, using an iterator.
102 * This method is used in the iterator method and is typically used in a
103 * for-loop to run through the EnergySources.
104 *
105 * \code
106 * EnergySourceContainer::Iterator i;
107 * for (i = container.Begin (); i != container.End (); ++i)
108 * {
109 * (*i)->method (); // some EnergySource method
110 * }
111 * \endcode
112 */
113 Iterator Begin() const;
114
115 /**
116 * \brief Get an iterator which refers to the last EnergySource pointer in
117 * the container.
118 *
119 * \returns An iterator which refers to the last EnergySource in container.
120 *
121 * EnergySources can be retrieved from the container in two ways. First,
122 * directly by an index into the container, and second, using an iterator.
123 * This method is used in the iterator method and is typically used in a
124 * for-loop to run through the EnergySources.
125 *
126 * \code
127 * EnergySourceContainer::Iterator i;
128 * for (i = container.Begin (); i != container.End (); ++i)
129 * {
130 * (*i)->method (); // some EnergySource method
131 * }
132 * \endcode
133 */
134 Iterator End() const;
135
136 /**
137 * \brief Get the number of Ptr<EnergySource> stored in this container.
138 *
139 * \returns The number of Ptr<EnergySource> stored in this container.
140 */
141 uint32_t GetN() const;
142
143 /**
144 * \brief Get the i-th Ptr<EnergySource> stored in this container.
145 *
146 * \param i Index of the requested Ptr<EnergySource>.
147 * \returns The requested Ptr<EnergySource>.
148 */
150
151 /**
152 * \param container Another EnergySourceContainer to append.
153 *
154 * Appends the contents of another EnergySourceContainer to the end of this
155 * EnergySourceContainer.
156 */
157 void Add(EnergySourceContainer container);
158
159 /**
160 * \brief Append a single Ptr<EnergySource> to the end of this container.
161 *
162 * \param source Pointer to an EnergySource.
163 */
164 void Add(Ptr<EnergySource> source);
165
166 /**
167 * \brief Append a single Ptr<EnergySource> referred to by its object name to
168 * the end of this container.
169 *
170 * \param sourceName Name of EnergySource object.
171 */
172 void Add(std::string sourceName);
173
174 private:
175 void DoDispose() override;
176
177 /**
178 * \brief Calls Object::Start () for all EnergySource objects.
179 */
180 void DoInitialize() override;
181
182 private:
183 std::vector<Ptr<EnergySource>> m_sources; //!< Energy source container
184};
185
186} // namespace energy
187} // namespace ns3
188
189#endif /* ENERGY_SOURCE_CONTAINER_H */
A base class which provides memory management and object aggregation.
Definition: object.h:89
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
a unique identifier for an interface.
Definition: type-id.h:59
Holds a vector of ns3::EnergySource pointers.
static TypeId GetTypeId()
Get the type ID.
void DoDispose() override
Destructor implementation.
EnergySourceContainer()
Creates an empty EnergySourceContainer.
Iterator Begin() const
Get an iterator which refers to the first EnergySource pointer in the container.
std::vector< Ptr< EnergySource > > m_sources
Energy source container.
uint32_t GetN() const
Get the number of Ptr<EnergySource> stored in this container.
void Add(EnergySourceContainer container)
Iterator End() const
Get an iterator which refers to the last EnergySource pointer in the container.
Ptr< EnergySource > Get(uint32_t i) const
Get the i-th Ptr<EnergySource> stored in this container.
std::vector< Ptr< EnergySource > >::const_iterator Iterator
Const iterator for EnergySource container.
void DoInitialize() override
Calls Object::Start () for all EnergySource objects.
Every class exported by the ns3 library is enclosed in the ns3 namespace.