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