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
device-energy-model-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 "
device-energy-model-container.h
"
23
24
#include "ns3/log.h"
25
#include "ns3/names.h"
26
27
namespace
ns3
28
{
29
namespace
energy
30
{
31
32
NS_LOG_COMPONENT_DEFINE
(
"DeviceEnergyModelContainer"
);
33
34
DeviceEnergyModelContainer::DeviceEnergyModelContainer
()
35
{
36
NS_LOG_FUNCTION
(
this
);
37
}
38
39
DeviceEnergyModelContainer::DeviceEnergyModelContainer
(
Ptr<DeviceEnergyModel>
model)
40
{
41
NS_LOG_FUNCTION
(
this
<< model);
42
NS_ASSERT
(model);
43
m_models
.push_back(model);
44
}
45
46
DeviceEnergyModelContainer::DeviceEnergyModelContainer
(std::string modelName)
47
{
48
NS_LOG_FUNCTION
(
this
<< modelName);
49
Ptr<DeviceEnergyModel>
model = Names::Find<DeviceEnergyModel>(modelName);
50
NS_ASSERT
(model);
51
m_models
.push_back(model);
52
}
53
54
DeviceEnergyModelContainer::DeviceEnergyModelContainer
(
const
DeviceEnergyModelContainer
& a,
55
const
DeviceEnergyModelContainer
& b)
56
{
57
NS_LOG_FUNCTION
(
this
<< &a << &b);
58
*
this
= a;
59
Add
(b);
60
}
61
62
DeviceEnergyModelContainer::Iterator
63
DeviceEnergyModelContainer::Begin
()
const
64
{
65
NS_LOG_FUNCTION
(
this
);
66
return
m_models
.begin();
67
}
68
69
DeviceEnergyModelContainer::Iterator
70
DeviceEnergyModelContainer::End
()
const
71
{
72
NS_LOG_FUNCTION
(
this
);
73
return
m_models
.end();
74
}
75
76
uint32_t
77
DeviceEnergyModelContainer::GetN
()
const
78
{
79
NS_LOG_FUNCTION
(
this
);
80
return
m_models
.size();
81
}
82
83
Ptr<DeviceEnergyModel>
84
DeviceEnergyModelContainer::Get
(
uint32_t
i)
const
85
{
86
NS_LOG_FUNCTION
(
this
<< i);
87
return
m_models
[i];
88
}
89
90
void
91
DeviceEnergyModelContainer::Add
(
DeviceEnergyModelContainer
container)
92
{
93
NS_LOG_FUNCTION
(
this
<< &container);
94
for
(
auto
i = container.Begin(); i != container.End(); i++)
95
{
96
m_models
.push_back(*i);
97
}
98
}
99
100
void
101
DeviceEnergyModelContainer::Add
(
Ptr<DeviceEnergyModel>
model)
102
{
103
NS_LOG_FUNCTION
(
this
<< model);
104
NS_ASSERT
(model);
105
m_models
.push_back(model);
106
}
107
108
void
109
DeviceEnergyModelContainer::Add
(std::string modelName)
110
{
111
NS_LOG_FUNCTION
(
this
<< modelName);
112
Ptr<DeviceEnergyModel>
model = Names::Find<DeviceEnergyModel>(modelName);
113
NS_ASSERT
(model);
114
m_models
.push_back(model);
115
}
116
117
void
118
DeviceEnergyModelContainer::Clear
()
119
{
120
NS_LOG_FUNCTION
(
this
);
121
m_models
.clear();
122
}
123
124
}
// namespace energy
125
}
// namespace ns3
ns3::Ptr
Smart pointer class similar to boost::intrusive_ptr.
Definition:
ptr.h:77
ns3::energy::DeviceEnergyModelContainer
Holds a vector of ns3::DeviceEnergyModel pointers.
Definition:
device-energy-model-container.h:47
ns3::energy::DeviceEnergyModelContainer::Add
void Add(DeviceEnergyModelContainer container)
Definition:
device-energy-model-container.cc:91
ns3::energy::DeviceEnergyModelContainer::Iterator
std::vector< Ptr< DeviceEnergyModel > >::const_iterator Iterator
Const iterator of DeviceEnergyModel container.
Definition:
device-energy-model-container.h:50
ns3::energy::DeviceEnergyModelContainer::m_models
std::vector< Ptr< DeviceEnergyModel > > m_models
Container of Energy models.
Definition:
device-energy-model-container.h:175
ns3::energy::DeviceEnergyModelContainer::Get
Ptr< DeviceEnergyModel > Get(uint32_t i) const
Get the i-th Ptr<DeviceEnergyModel> stored in this container.
Definition:
device-energy-model-container.cc:84
ns3::energy::DeviceEnergyModelContainer::DeviceEnergyModelContainer
DeviceEnergyModelContainer()
Creates an empty DeviceEnergyModelContainer.
Definition:
device-energy-model-container.cc:34
ns3::energy::DeviceEnergyModelContainer::End
Iterator End() const
Get an iterator which refers to the last DeviceEnergyModel pointer in the container.
Definition:
device-energy-model-container.cc:70
ns3::energy::DeviceEnergyModelContainer::Begin
Iterator Begin() const
Get an iterator which refers to the first DeviceEnergyModel pointer in the container.
Definition:
device-energy-model-container.cc:63
ns3::energy::DeviceEnergyModelContainer::Clear
void Clear()
Removes all elements in the container.
Definition:
device-energy-model-container.cc:118
ns3::energy::DeviceEnergyModelContainer::GetN
uint32_t GetN() const
Get the number of Ptr<DeviceEnergyModel> stored in this container.
Definition:
device-energy-model-container.cc:77
uint32_t
device-energy-model-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_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition:
log.h:202
NS_LOG_FUNCTION
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
Definition:
log-macros-enabled.h:240
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
src
energy
model
device-energy-model-container.cc
Generated on Tue May 28 2024 23:35:17 for ns-3 by
1.9.6