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-source-container.h
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2008 INRIA
3
* Copyright (c) 2010 Network Security Lab, University of Washington, Seattle.
4
*
5
* SPDX-License-Identifier: GPL-2.0-only
6
*
7
* Authors: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
8
* Sidharth Nabar <snabar@uw.edu>, He Wu <mdzz@u.washington.edu>
9
*/
10
11
#ifndef ENERGY_SOURCE_CONTAINER_H
12
#define ENERGY_SOURCE_CONTAINER_H
13
14
#include "ns3/energy-source.h"
15
#include "ns3/object.h"
16
17
#include <stdint.h>
18
#include <vector>
19
20
namespace
ns3
21
{
22
namespace
energy
23
{
24
25
/**
26
* @ingroup energy
27
* @brief Holds a vector of ns3::EnergySource pointers.
28
*
29
* EnergySourceHelper returns a list of EnergySource pointers installed onto a
30
* node. Users can use this list to access EnergySource objects to obtain total
31
* energy consumption on a node easily.
32
*
33
* @see NetDeviceContainer
34
*
35
*/
36
class
EnergySourceContainer
:
public
Object
37
{
38
public
:
39
/// Const iterator for EnergySource container
40
typedef
std::vector<Ptr<EnergySource>>::const_iterator
Iterator
;
41
42
public
:
43
/**
44
* @brief Get the type ID.
45
* @return The object TypeId.
46
*/
47
static
TypeId
GetTypeId
();
48
/**
49
* Creates an empty EnergySourceContainer.
50
*/
51
EnergySourceContainer
();
52
~EnergySourceContainer
()
override
;
53
54
/**
55
* @param source Pointer to an EnergySource.
56
*
57
* Creates an EnergySourceContainer with exactly one EnergySource previously
58
* instantiated.
59
*/
60
EnergySourceContainer
(
Ptr<EnergySource>
source);
61
62
/**
63
* @param sourceName Name of EnergySource.
64
*
65
* Creates an EnergySourceContainer with exactly one EnergySource previously
66
* instantiated and assigned a name using the Object name service. This
67
* EnergySource is specified by its assigned name.
68
*/
69
EnergySourceContainer
(std::string sourceName);
70
71
/**
72
* @param a A EnergySourceContainer.
73
* @param b Another EnergySourceContainer.
74
*
75
* Creates an EnergySourceContainer by concatenating EnergySourceContainer b
76
* to EnergySourceContainer a.
77
*
78
* @note Can be used to concatenate 2 Ptr<EnergySource> directly. C++ will be
79
* calling EnergySourceContainer constructor with Ptr<EnergySource> first.
80
*/
81
EnergySourceContainer
(
const
EnergySourceContainer
& a,
const
EnergySourceContainer
& b);
82
83
/**
84
* @brief Get an iterator which refers to the first EnergySource pointer in
85
* the container.
86
*
87
* @returns An iterator which refers to the first EnergySource in container.
88
*
89
* EnergySources can be retrieved from the container in two ways. First,
90
* directly by an index into the container, and second, using an iterator.
91
* This method is used in the iterator method and is typically used in a
92
* for-loop to run through the EnergySources.
93
*
94
* @code
95
* for (auto i = container.Begin(); i != container.End(); ++i)
96
* {
97
* (*i)->method(); // some EnergySource method
98
* }
99
* @endcode
100
*/
101
Iterator
Begin
()
const
;
102
103
/**
104
* @brief Get an iterator which refers to the last EnergySource pointer in
105
* the container.
106
*
107
* @returns An iterator which refers to the last EnergySource in container.
108
*
109
* EnergySources can be retrieved from the container in two ways. First,
110
* directly by an index into the container, and second, using an iterator.
111
* This method is used in the iterator method and is typically used in a
112
* for-loop to run through the EnergySources.
113
*
114
* @code
115
* for (auto i = container.Begin(); i != container.End(); ++i)
116
* {
117
* (*i)->method(); // some EnergySource method
118
* }
119
* @endcode
120
*/
121
Iterator
End
()
const
;
122
123
/**
124
* @brief Get the number of Ptr<EnergySource> stored in this container.
125
*
126
* @returns The number of Ptr<EnergySource> stored in this container.
127
*/
128
uint32_t
GetN
()
const
;
129
130
/**
131
* @brief Get the i-th Ptr<EnergySource> stored in this container.
132
*
133
* @param i Index of the requested Ptr<EnergySource>.
134
* @returns The requested Ptr<EnergySource>.
135
*/
136
Ptr<EnergySource>
Get
(
uint32_t
i)
const
;
137
138
/**
139
* @param container Another EnergySourceContainer to append.
140
*
141
* Appends the contents of another EnergySourceContainer to the end of this
142
* EnergySourceContainer.
143
*/
144
void
Add
(
EnergySourceContainer
container);
145
146
/**
147
* @brief Append a single Ptr<EnergySource> to the end of this container.
148
*
149
* @param source Pointer to an EnergySource.
150
*/
151
void
Add
(
Ptr<EnergySource>
source);
152
153
/**
154
* @brief Append a single Ptr<EnergySource> referred to by its object name to
155
* the end of this container.
156
*
157
* @param sourceName Name of EnergySource object.
158
*/
159
void
Add
(std::string sourceName);
160
161
private
:
162
void
DoDispose
()
override
;
163
164
/**
165
* @brief Calls Object::Start () for all EnergySource objects.
166
*/
167
void
DoInitialize
()
override
;
168
169
private
:
170
std::vector<Ptr<EnergySource>>
m_sources
;
//!< Energy source container
171
};
172
173
}
// namespace energy
174
}
// namespace ns3
175
176
#endif
/* ENERGY_SOURCE_CONTAINER_H */
ns3::Object::Object
Object()
Caller graph was not generated because of its size.
Definition
object.cc:96
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::EnergySourceContainer::GetTypeId
static TypeId GetTypeId()
Get the type ID.
Definition
energy-source-container.cc:23
ns3::energy::EnergySourceContainer::DoDispose
void DoDispose() override
Destructor implementation.
Definition
energy-source-container.cc:114
ns3::energy::EnergySourceContainer::EnergySourceContainer
EnergySourceContainer()
Creates an empty EnergySourceContainer.
Definition
energy-source-container.cc:33
ns3::energy::EnergySourceContainer::Begin
Iterator Begin() const
Get an iterator which refers to the first EnergySource pointer in the container.
Definition
energy-source-container.cc:62
ns3::energy::EnergySourceContainer::~EnergySourceContainer
~EnergySourceContainer() override
Definition
energy-source-container.cc:37
ns3::energy::EnergySourceContainer::m_sources
std::vector< Ptr< EnergySource > > m_sources
Energy source container.
Definition
energy-source-container.h:170
ns3::energy::EnergySourceContainer::GetN
uint32_t GetN() const
Get the number of Ptr<EnergySource> stored in this container.
Definition
energy-source-container.cc:74
ns3::energy::EnergySourceContainer::Add
void Add(EnergySourceContainer container)
Definition
energy-source-container.cc:86
ns3::energy::EnergySourceContainer::End
Iterator End() const
Get an iterator which refers to the last EnergySource pointer in the container.
Definition
energy-source-container.cc:68
ns3::energy::EnergySourceContainer::Get
Ptr< EnergySource > Get(uint32_t i) const
Get the i-th Ptr<EnergySource> stored in this container.
Definition
energy-source-container.cc:80
ns3::energy::EnergySourceContainer::Iterator
std::vector< Ptr< EnergySource > >::const_iterator Iterator
Const iterator for EnergySource container.
Definition
energy-source-container.h:40
ns3::energy::EnergySourceContainer::DoInitialize
void DoInitialize() override
Calls Object::Start () for all EnergySource objects.
Definition
energy-source-container.cc:126
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-source-container.h
Generated on
for ns-3 by
1.15.0