A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
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
30
namespace
ns3
31
{
32
namespace
energy
33
{
34
35
class
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
*/
48
class
EnergyHarvesterContainer
:
public
Object
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
*/
63
EnergyHarvesterContainer
();
64
~EnergyHarvesterContainer
()
override
;
65
66
/**
67
* \param harvester Pointer to an EnergyHarvester.
68
*
69
* Creates a EnergyHarvesterContainer with exactly one EnergyHarvester
70
* previously instantiated.
71
*/
72
EnergyHarvesterContainer
(
Ptr<EnergyHarvester>
harvester);
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
*/
94
EnergyHarvesterContainer
(
const
EnergyHarvesterContainer
& a,
const
EnergyHarvesterContainer
& b);
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
*/
151
Ptr<EnergyHarvester>
Get
(
uint32_t
i)
const
;
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) */
EnergyHarvester
Introspection did not find any typical Config paths.
ns3::Object
A base class which provides memory management and object aggregation.
Definition:
object.h:89
ns3::Ptr
Smart pointer class similar to boost::intrusive_ptr.
Definition:
ptr.h:77
ns3::TypeId
a unique identifier for an interface.
Definition:
type-id.h:59
ns3::energy::EnergyHarvesterContainer
Holds a vector of ns3::EnergyHarvester pointers.
Definition:
energy-harvester-container.h:49
ns3::energy::EnergyHarvesterContainer::~EnergyHarvesterContainer
~EnergyHarvesterContainer() override
Definition:
energy-harvester-container.cc:49
ns3::energy::EnergyHarvesterContainer::GetN
uint32_t GetN() const
Get the number of Ptr<EnergyHarvester> stored in this container.
Definition:
energy-harvester-container.cc:92
ns3::energy::EnergyHarvesterContainer::DoInitialize
void DoInitialize() override
Calls Object::Initialize () for all EnergySource objects.
Definition:
energy-harvester-container.cc:155
ns3::energy::EnergyHarvesterContainer::Get
Ptr< EnergyHarvester > Get(uint32_t i) const
Get the i-th Ptr<EnergyHarvester> stored in this container.
Definition:
energy-harvester-container.cc:99
ns3::energy::EnergyHarvesterContainer::EnergyHarvesterContainer
EnergyHarvesterContainer()
Creates an empty EnergyHarvesterContainer.
Definition:
energy-harvester-container.cc:44
ns3::energy::EnergyHarvesterContainer::Clear
void Clear()
Removes all elements in the container.
Definition:
energy-harvester-container.cc:133
ns3::energy::EnergyHarvesterContainer::Iterator
std::vector< Ptr< EnergyHarvester > >::const_iterator Iterator
Const iterator for EnergyHarvester container.
Definition:
energy-harvester-container.h:52
ns3::energy::EnergyHarvesterContainer::End
Iterator End() const
Get an iterator which refers to the last EnergyHarvester pointer in the container.
Definition:
energy-harvester-container.cc:85
ns3::energy::EnergyHarvesterContainer::Add
void Add(EnergyHarvesterContainer container)
Definition:
energy-harvester-container.cc:106
ns3::energy::EnergyHarvesterContainer::m_harvesters
std::vector< Ptr< EnergyHarvester > > m_harvesters
Harvester container.
Definition:
energy-harvester-container.h:190
ns3::energy::EnergyHarvesterContainer::DoDispose
void DoDispose() override
Destructor implementation.
Definition:
energy-harvester-container.cc:144
ns3::energy::EnergyHarvesterContainer::GetTypeId
static TypeId GetTypeId()
Get the type ID.
Definition:
energy-harvester-container.cc:35
ns3::energy::EnergyHarvesterContainer::Begin
Iterator Begin() const
Get an iterator which refers to the first EnergyHarvester pointer in the container.
Definition:
energy-harvester-container.cc:78
uint32_t
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
src
energy
helper
energy-harvester-container.h
Generated on Tue May 28 2024 23:35:16 for ns-3 by
1.9.6