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
* 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
19
namespace
ns3
20
{
21
namespace
energy
22
{
23
24
class
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
*/
37
class
EnergyHarvesterContainer
:
public
Object
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
*/
52
EnergyHarvesterContainer
();
53
~EnergyHarvesterContainer
()
override
;
54
55
/**
56
* \param harvester Pointer to an EnergyHarvester.
57
*
58
* Creates a EnergyHarvesterContainer with exactly one EnergyHarvester
59
* previously instantiated.
60
*/
61
EnergyHarvesterContainer
(
Ptr<EnergyHarvester>
harvester);
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
*/
83
EnergyHarvesterContainer
(
const
EnergyHarvesterContainer
& a,
const
EnergyHarvesterContainer
& b);
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
* EnergyHarvesterContainer::Iterator i;
98
* for (i = container.Begin (); i != container.End (); ++i)
99
* {
100
* (*i)->method (); // some EnergyHarvester method
101
* }
102
* \endcode
103
*/
104
Iterator
Begin
()
const
;
105
106
/**
107
* \brief Get an iterator which refers to the last EnergyHarvester pointer
108
* in the container.
109
*
110
* \returns An iterator which refers to the last EnergyHarvester in container.
111
*
112
* EnergyHarvesters can be retrieved from the container in two ways. First,
113
* directly by an index into the container, and second, using an iterator.
114
* This method is used in the iterator method and is typically used in a
115
* for-loop to run through the EnergyHarvesters.
116
*
117
* \code
118
* EnergyHarvesterContainer::Iterator i;
119
* for (i = container.Begin (); i != container.End (); ++i)
120
* {
121
* (*i)->method (); // some EnergyHarvester method
122
* }
123
* \endcode
124
*/
125
Iterator
End
()
const
;
126
127
/**
128
* \brief Get the number of Ptr<EnergyHarvester> stored in this container.
129
*
130
* \returns The number of Ptr<EnergyHarvester> stored in this container.
131
*/
132
uint32_t
GetN
()
const
;
133
134
/**
135
* \brief Get the i-th Ptr<EnergyHarvester> stored in this container.
136
*
137
* \param i Index of the requested Ptr<EnergyHarvester>.
138
* \returns The requested Ptr<EnergyHarvester>.
139
*/
140
Ptr<EnergyHarvester>
Get
(
uint32_t
i)
const
;
141
142
/**
143
* \param container Another EnergyHarvesterContainer.
144
*
145
* Appends the contents of another EnergyHarvesterContainer to the end of
146
* this EnergyHarvesterContainer.
147
*/
148
void
Add
(
EnergyHarvesterContainer
container);
149
150
/**
151
* \brief Append a single Ptr<EnergyHarvester> to the end of this container.
152
*
153
* \param harvester Pointer to an EnergyHarvester.
154
*/
155
void
Add
(
Ptr<EnergyHarvester>
harvester);
156
157
/**
158
* \brief Append a single Ptr<EnergyHarvester> referred to by its object
159
* name to the end of this container.
160
*
161
* \param harvesterName Name of EnergyHarvester object.
162
*/
163
void
Add
(std::string harvesterName);
164
165
/**
166
* \brief Removes all elements in the container.
167
*/
168
void
Clear
();
169
170
private
:
171
void
DoDispose
()
override
;
172
173
/**
174
* \brief Calls Object::Initialize () for all EnergySource objects.
175
*/
176
void
DoInitialize
()
override
;
177
178
private
:
179
std::vector<Ptr<EnergyHarvester>>
m_harvesters
;
//!< Harvester container
180
};
181
182
}
// namespace energy
183
}
// namespace ns3
184
185
#endif
/* defined(ENERGY_HARVESTER_CONTAINER_H) */
ns3::Object
A base class which provides memory management and object aggregation.
Definition
object.h:78
ns3::Ptr
Smart pointer class similar to boost::intrusive_ptr.
Definition
mpi-test-fixtures.h:37
ns3::TypeId
a unique identifier for an interface.
Definition
type-id.h:48
ns3::energy::EnergyHarvesterContainer
Holds a vector of ns3::EnergyHarvester pointers.
Definition
energy-harvester-container.h:38
ns3::energy::EnergyHarvesterContainer::~EnergyHarvesterContainer
~EnergyHarvesterContainer() override
Definition
energy-harvester-container.cc:39
ns3::energy::EnergyHarvesterContainer::GetN
uint32_t GetN() const
Get the number of Ptr<EnergyHarvester> stored in this container.
Definition
energy-harvester-container.cc:82
ns3::energy::EnergyHarvesterContainer::DoInitialize
void DoInitialize() override
Calls Object::Initialize () for all EnergySource objects.
Definition
energy-harvester-container.cc:145
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:89
ns3::energy::EnergyHarvesterContainer::EnergyHarvesterContainer
EnergyHarvesterContainer()
Creates an empty EnergyHarvesterContainer.
Definition
energy-harvester-container.cc:34
ns3::energy::EnergyHarvesterContainer::Clear
void Clear()
Removes all elements in the container.
Definition
energy-harvester-container.cc:123
ns3::energy::EnergyHarvesterContainer::Iterator
std::vector< Ptr< EnergyHarvester > >::const_iterator Iterator
Const iterator for EnergyHarvester container.
Definition
energy-harvester-container.h:41
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:75
ns3::energy::EnergyHarvesterContainer::Add
void Add(EnergyHarvesterContainer container)
Definition
energy-harvester-container.cc:96
ns3::energy::EnergyHarvesterContainer::m_harvesters
std::vector< Ptr< EnergyHarvester > > m_harvesters
Harvester container.
Definition
energy-harvester-container.h:179
ns3::energy::EnergyHarvesterContainer::DoDispose
void DoDispose() override
Destructor implementation.
Definition
energy-harvester-container.cc:134
ns3::energy::EnergyHarvesterContainer::GetTypeId
static TypeId GetTypeId()
Get the type ID.
Definition
energy-harvester-container.cc:24
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:68
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 Fri Nov 8 2024 13:59:00 for ns-3 by
1.11.0