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 * SPDX-License-Identifier: GPL-2.0-only
6 *
7 * Author: Cristiano Tapparello <cristiano.tapparello@rochester.edu>
8 */
9
10#ifndef ENERGY_HARVESTER_CONTAINER_H
11#define ENERGY_HARVESTER_CONTAINER_H
12
13#include "ns3/energy-harvester.h"
14#include "ns3/object.h"
15
16#include <stdint.h>
17#include <vector>
18
19namespace ns3
20{
21namespace energy
22{
23
24class EnergyHarvester;
25
26/**
27 * @ingroup energy
28 * @brief Holds a vector of ns3::EnergyHarvester pointers.
29 *
30 * EnergyHarvesterContainer returns a list of EnergyHarvester pointers
31 * installed on a node. Users can use this list to access EnergyHarvester
32 * objects to obtain the total energy harvested on a node easily.
33 *
34 * @see NetDeviceContainer
35 *
36 */
38{
39 public:
40 /// Const iterator for EnergyHarvester container
41 typedef std::vector<Ptr<EnergyHarvester>>::const_iterator Iterator;
42
43 public:
44 /**
45 * @brief Get the type ID.
46 * @return The object TypeId.
47 */
48 static TypeId GetTypeId();
49 /**
50 * Creates an empty EnergyHarvesterContainer.
51 */
54
55 /**
56 * @param harvester Pointer to an EnergyHarvester.
57 *
58 * Creates a EnergyHarvesterContainer with exactly one EnergyHarvester
59 * previously instantiated.
60 */
62
63 /**
64 * @param harvesterName Name of EnergyHarvester.
65 *
66 * Creates an EnergyHarvesterContainer with exactly one EnergyHarvester
67 * previously instantiated and assigned a name using the Object name service.
68 * This EnergyHarvester is specified by its assigned name.
69 */
70 EnergyHarvesterContainer(std::string harvesterName);
71
72 /**
73 * @param a A EnergyHarvesterContainer.
74 * @param b Another EnergyHarvesterContainer.
75 *
76 * Creates a EnergyHarvesterContainer by concatenating EnergyHarvesterContainer b
77 * to EnergyHarvesterContainer a.
78 *
79 * @note Can be used to concatenate 2 Ptr<EnergyHarvester> directly. C++
80 * will be calling EnergyHarvesterContainer constructor with Ptr<EnergyHarvester>
81 * first.
82 */
84
85 /**
86 * @brief Get an iterator which refers to the first EnergyHarvester pointer
87 * in the container.
88 *
89 * @returns An iterator which refers to the first EnergyHarvester in container.
90 *
91 * EnergyHarvesters can be retrieved from the container in two ways. First,
92 * directly by an index into the container, and second, using an iterator.
93 * This method is used in the iterator method and is typically used in a
94 * for-loop to run through the EnergyHarvesters.
95 *
96 * @code
97 * for (auto i = container.Begin(); i != container.End(); ++i)
98 * {
99 * (*i)->method(); // some EnergyHarvester method
100 * }
101 * @endcode
102 */
103 Iterator Begin() const;
104
105 /**
106 * @brief Get an iterator which refers to the last EnergyHarvester pointer
107 * in the container.
108 *
109 * @returns An iterator which refers to the last EnergyHarvester in container.
110 *
111 * EnergyHarvesters can be retrieved from the container in two ways. First,
112 * directly by an index into the container, and second, using an iterator.
113 * This method is used in the iterator method and is typically used in a
114 * for-loop to run through the EnergyHarvesters.
115 *
116 * @code
117 * for (auto i = container.Begin(); i != container.End(); ++i)
118 * {
119 * (*i)->method(); // some EnergyHarvester method
120 * }
121 * @endcode
122 */
123 Iterator End() const;
124
125 /**
126 * @brief Get the number of Ptr<EnergyHarvester> stored in this container.
127 *
128 * @returns The number of Ptr<EnergyHarvester> stored in this container.
129 */
130 uint32_t GetN() const;
131
132 /**
133 * @brief Get the i-th Ptr<EnergyHarvester> stored in this container.
134 *
135 * @param i Index of the requested Ptr<EnergyHarvester>.
136 * @returns The requested Ptr<EnergyHarvester>.
137 */
139
140 /**
141 * @param container Another EnergyHarvesterContainer.
142 *
143 * Appends the contents of another EnergyHarvesterContainer to the end of
144 * this EnergyHarvesterContainer.
145 */
146 void Add(EnergyHarvesterContainer container);
147
148 /**
149 * @brief Append a single Ptr<EnergyHarvester> to the end of this container.
150 *
151 * @param harvester Pointer to an EnergyHarvester.
152 */
153 void Add(Ptr<EnergyHarvester> harvester);
154
155 /**
156 * @brief Append a single Ptr<EnergyHarvester> referred to by its object
157 * name to the end of this container.
158 *
159 * @param harvesterName Name of EnergyHarvester object.
160 */
161 void Add(std::string harvesterName);
162
163 /**
164 * @brief Removes all elements in the container.
165 */
166 void Clear();
167
168 private:
169 void DoDispose() override;
170
171 /**
172 * @brief Calls Object::Initialize () for all EnergySource objects.
173 */
174 void DoInitialize() override;
175
176 private:
177 std::vector<Ptr<EnergyHarvester>> m_harvesters; //!< Harvester container
178};
179
180} // namespace energy
181} // namespace ns3
182
183#endif /* defined(ENERGY_HARVESTER_CONTAINER_H) */
Object()
Caller graph was not generated because of its size.
Definition object.cc:93
Smart pointer class similar to boost::intrusive_ptr.
Definition ptr.h:70
a unique identifier for an interface.
Definition type-id.h:49
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.
Energy harvester base class.
Every class exported by the ns3 library is enclosed in the ns3 namespace.