A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
energy-harvester-container.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2014 Wireless Communications and Networking Group (WCNG),
3 * University of Rochester, Rochester, NY, USA.
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 * Author: Cristiano Tapparello <cristiano.tapparello@rochester.edu>
19 */
20
21#ifndef ENERGY_HARVESTER_CONTAINER_H
22#define ENERGY_HARVESTER_CONTAINER_H
23
24#include "ns3/energy-harvester.h"
25#include "ns3/object.h"
26
27#include <stdint.h>
28#include <vector>
29
30namespace ns3
31{
32namespace energy
33{
34
35class EnergyHarvester;
36
37/**
38 * \ingroup energy
39 * \brief Holds a vector of ns3::EnergyHarvester pointers.
40 *
41 * EnergyHarvesterContainer returns a list of EnergyHarvester pointers
42 * installed on a node. Users can use this list to access EnergyHarvester
43 * objects to obtain the total energy harvested on a node easily.
44 *
45 * \see NetDeviceContainer
46 *
47 */
49{
50 public:
51 /// Const iterator for EnergyHarvester container
52 typedef std::vector<Ptr<EnergyHarvester>>::const_iterator Iterator;
53
54 public:
55 /**
56 * \brief Get the type ID.
57 * \return The object TypeId.
58 */
59 static TypeId GetTypeId();
60 /**
61 * Creates an empty EnergyHarvesterContainer.
62 */
65
66 /**
67 * \param harvester Pointer to an EnergyHarvester.
68 *
69 * Creates a EnergyHarvesterContainer with exactly one EnergyHarvester
70 * previously instantiated.
71 */
73
74 /**
75 * \param harvesterName Name of EnergyHarvester.
76 *
77 * Creates an EnergyHarvesterContainer with exactly one EnergyHarvester
78 * previously instantiated and assigned a name using the Object name service.
79 * This EnergyHarvester is specified by its assigned name.
80 */
81 EnergyHarvesterContainer(std::string harvesterName);
82
83 /**
84 * \param a A EnergyHarvesterContainer.
85 * \param b Another EnergyHarvesterContainer.
86 *
87 * Creates a EnergyHarvesterContainer by concatenating EnergyHarvesterContainer b
88 * to EnergyHarvesterContainer a.
89 *
90 * \note Can be used to concatenate 2 Ptr<EnergyHarvester> directly. C++
91 * will be calling EnergyHarvesterContainer constructor with Ptr<EnergyHarvester>
92 * first.
93 */
95
96 /**
97 * \brief Get an iterator which refers to the first EnergyHarvester pointer
98 * in the container.
99 *
100 * \returns An iterator which refers to the first EnergyHarvester in container.
101 *
102 * EnergyHarvesters can be retrieved from the container in two ways. First,
103 * directly by an index into the container, and second, using an iterator.
104 * This method is used in the iterator method and is typically used in a
105 * for-loop to run through the EnergyHarvesters.
106 *
107 * \code
108 * EnergyHarvesterContainer::Iterator i;
109 * for (i = container.Begin (); i != container.End (); ++i)
110 * {
111 * (*i)->method (); // some EnergyHarvester method
112 * }
113 * \endcode
114 */
115 Iterator Begin() const;
116
117 /**
118 * \brief Get an iterator which refers to the last EnergyHarvester pointer
119 * in the container.
120 *
121 * \returns An iterator which refers to the last EnergyHarvester in container.
122 *
123 * EnergyHarvesters can be retrieved from the container in two ways. First,
124 * directly by an index into the container, and second, using an iterator.
125 * This method is used in the iterator method and is typically used in a
126 * for-loop to run through the EnergyHarvesters.
127 *
128 * \code
129 * EnergyHarvesterContainer::Iterator i;
130 * for (i = container.Begin (); i != container.End (); ++i)
131 * {
132 * (*i)->method (); // some EnergyHarvester method
133 * }
134 * \endcode
135 */
136 Iterator End() const;
137
138 /**
139 * \brief Get the number of Ptr<EnergyHarvester> stored in this container.
140 *
141 * \returns The number of Ptr<EnergyHarvester> stored in this container.
142 */
143 uint32_t GetN() const;
144
145 /**
146 * \brief Get the i-th Ptr<EnergyHarvester> stored in this container.
147 *
148 * \param i Index of the requested Ptr<EnergyHarvester>.
149 * \returns The requested Ptr<EnergyHarvester>.
150 */
152
153 /**
154 * \param container Another EnergyHarvesterContainer.
155 *
156 * Appends the contents of another EnergyHarvesterContainer to the end of
157 * this EnergyHarvesterContainer.
158 */
159 void Add(EnergyHarvesterContainer container);
160
161 /**
162 * \brief Append a single Ptr<EnergyHarvester> to the end of this container.
163 *
164 * \param harvester Pointer to an EnergyHarvester.
165 */
166 void Add(Ptr<EnergyHarvester> harvester);
167
168 /**
169 * \brief Append a single Ptr<EnergyHarvester> referred to by its object
170 * name to the end of this container.
171 *
172 * \param harvesterName Name of EnergyHarvester object.
173 */
174 void Add(std::string harvesterName);
175
176 /**
177 * \brief Removes all elements in the container.
178 */
179 void Clear();
180
181 private:
182 void DoDispose() override;
183
184 /**
185 * \brief Calls Object::Initialize () for all EnergySource objects.
186 */
187 void DoInitialize() override;
188
189 private:
190 std::vector<Ptr<EnergyHarvester>> m_harvesters; //!< Harvester container
191};
192
193} // namespace energy
194} // namespace ns3
195
196#endif /* defined(ENERGY_HARVESTER_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::EnergyHarvester pointers.
uint32_t GetN() const
Get the number of Ptr<EnergyHarvester> stored in this container.
void DoInitialize() override
Calls Object::Initialize () for all EnergySource objects.
Ptr< EnergyHarvester > Get(uint32_t i) const
Get the i-th Ptr<EnergyHarvester> stored in this container.
EnergyHarvesterContainer()
Creates an empty EnergyHarvesterContainer.
void Clear()
Removes all elements in the container.
std::vector< Ptr< EnergyHarvester > >::const_iterator Iterator
Const iterator for EnergyHarvester container.
Iterator End() const
Get an iterator which refers to the last EnergyHarvester pointer in the container.
void Add(EnergyHarvesterContainer container)
std::vector< Ptr< EnergyHarvester > > m_harvesters
Harvester container.
void DoDispose() override
Destructor implementation.
Iterator Begin() const
Get an iterator which refers to the first EnergyHarvester pointer in the container.
Every class exported by the ns3 library is enclosed in the ns3 namespace.