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
* 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
*/
138
Ptr<EnergyHarvester>
Get
(
uint32_t
i)
const
;
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) */
ns3::Object::Object
Object()
Caller graph was not generated because of its size.
Definition
object.cc:93
ns3::Ptr
Smart pointer class similar to boost::intrusive_ptr.
Definition
ptr.h:70
ns3::TypeId
a unique identifier for an interface.
Definition
type-id.h:49
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:177
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
ns3::energy::EnergyHarvester
Energy harvester base class.
Definition
energy-harvester.h:36
uint32_t
ns3::energy
Definition
energy-harvester-container.cc:18
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
src
energy
helper
energy-harvester-container.h
Generated on
for ns-3 by
1.15.0