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
33
class
EnergyHarvester;
34
35
/**
36
* \ingroup energy
37
* \brief Holds a vector of ns3::EnergyHarvester pointers.
38
*
39
* EnergyHarvesterContainer returns a list of EnergyHarvester pointers
40
* installed on a node. Users can use this list to access EnergyHarvester
41
* objects to obtain the total energy harvested on a node easily.
42
*
43
* \see NetDeviceContainer
44
*
45
*/
46
class
EnergyHarvesterContainer
:
public
Object
47
{
48
public
:
49
/// Const iterator for EnergyHarvester container
50
typedef
std::vector<Ptr<EnergyHarvester>>::const_iterator
Iterator
;
51
52
public
:
53
/**
54
* \brief Get the type ID.
55
* \return The object TypeId.
56
*/
57
static
TypeId
GetTypeId
();
58
/**
59
* Creates an empty EnergyHarvesterContainer.
60
*/
61
EnergyHarvesterContainer
();
62
~EnergyHarvesterContainer
()
override
;
63
64
/**
65
* \param harvester Pointer to an EnergyHarvester.
66
*
67
* Creates a EnergyHarvesterContainer with exactly one EnergyHarvester
68
* previously instantiated.
69
*/
70
EnergyHarvesterContainer
(
Ptr<EnergyHarvester>
harvester);
71
72
/**
73
* \param harvesterName Name of EnergyHarvester.
74
*
75
* Creates an EnergyHarvesterContainer with exactly one EnergyHarvester
76
* previously instantiated and assigned a name using the Object name service.
77
* This EnergyHarvester is specified by its assigned name.
78
*/
79
EnergyHarvesterContainer
(std::string harvesterName);
80
81
/**
82
* \param a A EnergyHarvesterContainer.
83
* \param b Another EnergyHarvesterContainer.
84
*
85
* Creates a EnergyHarvesterContainer by concatenating EnergyHarvesterContainer b
86
* to EnergyHarvesterContainer a.
87
*
88
* \note Can be used to concatenate 2 Ptr<EnergyHarvester> directly. C++
89
* will be calling EnergyHarvesterContainer constructor with Ptr<EnergyHarvester>
90
* first.
91
*/
92
EnergyHarvesterContainer
(
const
EnergyHarvesterContainer
& a,
const
EnergyHarvesterContainer
& b);
93
94
/**
95
* \brief Get an iterator which refers to the first EnergyHarvester pointer
96
* in the container.
97
*
98
* \returns An iterator which refers to the first EnergyHarvester in container.
99
*
100
* EnergyHarvesters 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 EnergyHarvesters.
104
*
105
* \code
106
* EnergyHarvesterContainer::Iterator i;
107
* for (i = container.Begin (); i != container.End (); ++i)
108
* {
109
* (*i)->method (); // some EnergyHarvester method
110
* }
111
* \endcode
112
*/
113
Iterator
Begin
()
const
;
114
115
/**
116
* \brief Get an iterator which refers to the last EnergyHarvester pointer
117
* in the container.
118
*
119
* \returns An iterator which refers to the last EnergyHarvester in container.
120
*
121
* EnergyHarvesters 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 EnergyHarvesters.
125
*
126
* \code
127
* EnergyHarvesterContainer::Iterator i;
128
* for (i = container.Begin (); i != container.End (); ++i)
129
* {
130
* (*i)->method (); // some EnergyHarvester method
131
* }
132
* \endcode
133
*/
134
Iterator
End
()
const
;
135
136
/**
137
* \brief Get the number of Ptr<EnergyHarvester> stored in this container.
138
*
139
* \returns The number of Ptr<EnergyHarvester> stored in this container.
140
*/
141
uint32_t
GetN
()
const
;
142
143
/**
144
* \brief Get the i-th Ptr<EnergyHarvester> stored in this container.
145
*
146
* \param i Index of the requested Ptr<EnergyHarvester>.
147
* \returns The requested Ptr<EnergyHarvester>.
148
*/
149
Ptr<EnergyHarvester>
Get
(
uint32_t
i)
const
;
150
151
/**
152
* \param container Another EnergyHarvesterContainer.
153
*
154
* Appends the contents of another EnergyHarvesterContainer to the end of
155
* this EnergyHarvesterContainer.
156
*/
157
void
Add
(
EnergyHarvesterContainer
container);
158
159
/**
160
* \brief Append a single Ptr<EnergyHarvester> to the end of this container.
161
*
162
* \param harvester Pointer to an EnergyHarvester.
163
*/
164
void
Add
(
Ptr<EnergyHarvester>
harvester);
165
166
/**
167
* \brief Append a single Ptr<EnergyHarvester> referred to by its object
168
* name to the end of this container.
169
*
170
* \param harvesterName Name of EnergyHarvester object.
171
*/
172
void
Add
(std::string harvesterName);
173
174
/**
175
* \brief Removes all elements in the container.
176
*/
177
void
Clear
();
178
179
private
:
180
void
DoDispose
()
override
;
181
182
/**
183
* \brief Calls Object::Initialize () for all EnergySource objects.
184
*/
185
void
DoInitialize
()
override
;
186
187
private
:
188
std::vector<Ptr<EnergyHarvester>>
m_harvesters
;
//!< Harvester container
189
};
190
191
}
// namespace ns3
192
193
#endif
/* defined(ENERGY_HARVESTER_CONTAINER_H) */
ns3::EnergyHarvesterContainer
Holds a vector of ns3::EnergyHarvester pointers.
Definition:
energy-harvester-container.h:47
ns3::EnergyHarvesterContainer::Clear
void Clear()
Removes all elements in the container.
Definition:
energy-harvester-container.cc:132
ns3::EnergyHarvesterContainer::~EnergyHarvesterContainer
~EnergyHarvesterContainer() override
Definition:
energy-harvester-container.cc:48
ns3::EnergyHarvesterContainer::Iterator
std::vector< Ptr< EnergyHarvester > >::const_iterator Iterator
Const iterator for EnergyHarvester container.
Definition:
energy-harvester-container.h:50
ns3::EnergyHarvesterContainer::End
Iterator End() const
Get an iterator which refers to the last EnergyHarvester pointer in the container.
Definition:
energy-harvester-container.cc:84
ns3::EnergyHarvesterContainer::DoDispose
void DoDispose() override
Destructor implementation.
Definition:
energy-harvester-container.cc:143
ns3::EnergyHarvesterContainer::Begin
Iterator Begin() const
Get an iterator which refers to the first EnergyHarvester pointer in the container.
Definition:
energy-harvester-container.cc:77
ns3::EnergyHarvesterContainer::DoInitialize
void DoInitialize() override
Calls Object::Initialize () for all EnergySource objects.
Definition:
energy-harvester-container.cc:154
ns3::EnergyHarvesterContainer::Get
Ptr< EnergyHarvester > Get(uint32_t i) const
Get the i-th Ptr<EnergyHarvester> stored in this container.
Definition:
energy-harvester-container.cc:98
ns3::EnergyHarvesterContainer::Add
void Add(EnergyHarvesterContainer container)
Definition:
energy-harvester-container.cc:105
ns3::EnergyHarvesterContainer::EnergyHarvesterContainer
EnergyHarvesterContainer()
Creates an empty EnergyHarvesterContainer.
Definition:
energy-harvester-container.cc:43
ns3::EnergyHarvesterContainer::GetN
uint32_t GetN() const
Get the number of Ptr<EnergyHarvester> stored in this container.
Definition:
energy-harvester-container.cc:91
ns3::EnergyHarvesterContainer::GetTypeId
static TypeId GetTypeId()
Get the type ID.
Definition:
energy-harvester-container.cc:34
ns3::EnergyHarvesterContainer::m_harvesters
std::vector< Ptr< EnergyHarvester > > m_harvesters
Harvester container.
Definition:
energy-harvester-container.h:188
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
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 Sun Apr 28 2024 23:35:51 for ns-3 by
1.9.6