A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
API
energy-source-container.cc
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
#include "
energy-source-container.h
"
23
24
#include "ns3/names.h"
25
26
namespace
ns3
27
{
28
29
NS_OBJECT_ENSURE_REGISTERED
(EnergySourceContainer);
30
31
TypeId
32
EnergySourceContainer::GetTypeId
()
33
{
34
static
TypeId
tid =
TypeId
(
"ns3::EnergySourceContainer"
)
35
.
SetParent
<
Object
>()
36
.SetGroupName(
"Energy"
)
37
.AddConstructor<
EnergySourceContainer
>();
38
return
tid;
39
}
40
41
EnergySourceContainer::EnergySourceContainer
()
42
{
43
}
44
45
EnergySourceContainer::~EnergySourceContainer
()
46
{
47
}
48
49
EnergySourceContainer::EnergySourceContainer
(
Ptr<EnergySource>
source)
50
{
51
NS_ASSERT
(source);
52
m_sources
.push_back(source);
53
}
54
55
EnergySourceContainer::EnergySourceContainer
(std::string sourceName)
56
{
57
Ptr<EnergySource>
source = Names::Find<EnergySource>(sourceName);
58
NS_ASSERT
(source);
59
m_sources
.push_back(source);
60
}
61
62
EnergySourceContainer::EnergySourceContainer
(
const
EnergySourceContainer
& a,
63
const
EnergySourceContainer
& b)
64
{
65
*
this
= a;
66
Add
(b);
67
}
68
69
EnergySourceContainer::Iterator
70
EnergySourceContainer::Begin
()
const
71
{
72
return
m_sources
.begin();
73
}
74
75
EnergySourceContainer::Iterator
76
EnergySourceContainer::End
()
const
77
{
78
return
m_sources
.end();
79
}
80
81
uint32_t
82
EnergySourceContainer::GetN
()
const
83
{
84
return
m_sources
.size();
85
}
86
87
Ptr<EnergySource>
88
EnergySourceContainer::Get
(uint32_t i)
const
89
{
90
return
m_sources
[i];
91
}
92
93
void
94
EnergySourceContainer::Add
(
EnergySourceContainer
container
)
95
{
96
for
(
auto
i =
container
.Begin(); i !=
container
.End(); i++)
97
{
98
m_sources
.push_back(*i);
99
}
100
}
101
102
void
103
EnergySourceContainer::Add
(
Ptr<EnergySource>
source)
104
{
105
NS_ASSERT
(source);
106
m_sources
.push_back(source);
107
}
108
109
void
110
EnergySourceContainer::Add
(std::string sourceName)
111
{
112
Ptr<EnergySource>
source = Names::Find<EnergySource>(sourceName);
113
NS_ASSERT
(source);
114
m_sources
.push_back(source);
115
}
116
117
/*
118
* Private functions start here.
119
*/
120
121
void
122
EnergySourceContainer::DoDispose
()
123
{
124
// call Object::Dispose for all EnergySource objects
125
for
(
auto
i =
m_sources
.begin(); i !=
m_sources
.end(); i++)
126
{
127
(*i)->DisposeDeviceModels();
128
(*i)->Dispose();
129
}
130
m_sources
.clear();
131
}
132
133
void
134
EnergySourceContainer::DoInitialize
()
135
{
136
// call Object::Start for all EnergySource objects
137
for
(
auto
i =
m_sources
.begin(); i !=
m_sources
.end(); i++)
138
{
139
(*i)->Initialize();
140
(*i)->InitializeDeviceModels();
141
}
142
}
143
144
}
// namespace ns3
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::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::Iterator
std::vector< Ptr< EnergySource > >::const_iterator Iterator
Const iterator for EnergySource container.
Definition:
energy-source-container.h:49
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
ns3::TypeId::SetParent
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition:
type-id.cc:931
energy-source-container.h
NS_ASSERT
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
Definition:
assert.h:66
NS_OBJECT_ENSURE_REGISTERED
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition:
object-base.h:46
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
openflow-switch.container
container
Definition:
openflow-switch.py:46
src
energy
helper
energy-source-container.cc
Generated on Sun Mar 3 2024 17:10:57 for ns-3 by
1.9.1