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
* EnergySourceContainer::Iterator i;
96
* for (i = container.Begin (); i != container.End (); ++i)
97
* {
98
* (*i)->method (); // some EnergySource method
99
* }
100
* \endcode
101
*/
102
Iterator
Begin
()
const
;
103
104
/**
105
* \brief Get an iterator which refers to the last EnergySource pointer in
106
* the container.
107
*
108
* \returns An iterator which refers to the last EnergySource in container.
109
*
110
* EnergySources can be retrieved from the container in two ways. First,
111
* directly by an index into the container, and second, using an iterator.
112
* This method is used in the iterator method and is typically used in a
113
* for-loop to run through the EnergySources.
114
*
115
* \code
116
* EnergySourceContainer::Iterator i;
117
* for (i = container.Begin (); i != container.End (); ++i)
118
* {
119
* (*i)->method (); // some EnergySource method
120
* }
121
* \endcode
122
*/
123
Iterator
End
()
const
;
124
125
/**
126
* \brief Get the number of Ptr<EnergySource> stored in this container.
127
*
128
* \returns The number of Ptr<EnergySource> stored in this container.
129
*/
130
uint32_t
GetN
()
const
;
131
132
/**
133
* \brief Get the i-th Ptr<EnergySource> stored in this container.
134
*
135
* \param i Index of the requested Ptr<EnergySource>.
136
* \returns The requested Ptr<EnergySource>.
137
*/
138
Ptr<EnergySource>
Get
(
uint32_t
i)
const
;
139
140
/**
141
* \param container Another EnergySourceContainer to append.
142
*
143
* Appends the contents of another EnergySourceContainer to the end of this
144
* EnergySourceContainer.
145
*/
146
void
Add
(
EnergySourceContainer
container);
147
148
/**
149
* \brief Append a single Ptr<EnergySource> to the end of this container.
150
*
151
* \param source Pointer to an EnergySource.
152
*/
153
void
Add
(
Ptr<EnergySource>
source);
154
155
/**
156
* \brief Append a single Ptr<EnergySource> referred to by its object name to
157
* the end of this container.
158
*
159
* \param sourceName Name of EnergySource object.
160
*/
161
void
Add
(std::string sourceName);
162
163
private
:
164
void
DoDispose
()
override
;
165
166
/**
167
* \brief Calls Object::Start () for all EnergySource objects.
168
*/
169
void
DoInitialize
()
override
;
170
171
private
:
172
std::vector<Ptr<EnergySource>>
m_sources
;
//!< Energy source container
173
};
174
175
}
// namespace energy
176
}
// namespace ns3
177
178
#endif
/* ENERGY_SOURCE_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::EnergySourceContainer
Holds a vector of ns3::EnergySource pointers.
Definition
energy-source-container.h:37
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:172
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
Every class exported by the ns3 library is enclosed in the ns3 namespace.
src
energy
helper
energy-source-container.h
Generated on Fri Nov 8 2024 13:59:00 for ns-3 by
1.11.0