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
* 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
#include "
device-energy-model-container.h
"
12
13
#include "ns3/log.h"
14
#include "ns3/names.h"
15
16
namespace
ns3
17
{
18
namespace
energy
19
{
20
21
NS_LOG_COMPONENT_DEFINE
(
"DeviceEnergyModelContainer"
);
22
23
DeviceEnergyModelContainer::DeviceEnergyModelContainer
()
24
{
25
NS_LOG_FUNCTION
(
this
);
26
}
27
28
DeviceEnergyModelContainer::DeviceEnergyModelContainer
(
Ptr<DeviceEnergyModel>
model)
29
{
30
NS_LOG_FUNCTION
(
this
<< model);
31
NS_ASSERT
(model);
32
m_models
.push_back(model);
33
}
34
35
DeviceEnergyModelContainer::DeviceEnergyModelContainer
(std::string modelName)
36
{
37
NS_LOG_FUNCTION
(
this
<< modelName);
38
Ptr<DeviceEnergyModel>
model =
Names::Find<DeviceEnergyModel>
(modelName);
39
NS_ASSERT
(model);
40
m_models
.push_back(model);
41
}
42
43
DeviceEnergyModelContainer::DeviceEnergyModelContainer
(
const
DeviceEnergyModelContainer
& a,
44
const
DeviceEnergyModelContainer
& b)
45
{
46
NS_LOG_FUNCTION
(
this
<< &a << &b);
47
*
this
= a;
48
Add
(b);
49
}
50
51
DeviceEnergyModelContainer::Iterator
52
DeviceEnergyModelContainer::Begin
()
const
53
{
54
NS_LOG_FUNCTION
(
this
);
55
return
m_models
.begin();
56
}
57
58
DeviceEnergyModelContainer::Iterator
59
DeviceEnergyModelContainer::End
()
const
60
{
61
NS_LOG_FUNCTION
(
this
);
62
return
m_models
.end();
63
}
64
65
uint32_t
66
DeviceEnergyModelContainer::GetN
()
const
67
{
68
NS_LOG_FUNCTION
(
this
);
69
return
m_models
.size();
70
}
71
72
Ptr<DeviceEnergyModel>
73
DeviceEnergyModelContainer::Get
(
uint32_t
i)
const
74
{
75
NS_LOG_FUNCTION
(
this
<< i);
76
return
m_models
[i];
77
}
78
79
void
80
DeviceEnergyModelContainer::Add
(
DeviceEnergyModelContainer
container)
81
{
82
NS_LOG_FUNCTION
(
this
<< &container);
83
for
(
auto
i = container.Begin(); i != container.End(); i++)
84
{
85
m_models
.push_back(*i);
86
}
87
}
88
89
void
90
DeviceEnergyModelContainer::Add
(
Ptr<DeviceEnergyModel>
model)
91
{
92
NS_LOG_FUNCTION
(
this
<< model);
93
NS_ASSERT
(model);
94
m_models
.push_back(model);
95
}
96
97
void
98
DeviceEnergyModelContainer::Add
(std::string modelName)
99
{
100
NS_LOG_FUNCTION
(
this
<< modelName);
101
Ptr<DeviceEnergyModel>
model =
Names::Find<DeviceEnergyModel>
(modelName);
102
NS_ASSERT
(model);
103
m_models
.push_back(model);
104
}
105
106
void
107
DeviceEnergyModelContainer::Clear
()
108
{
109
NS_LOG_FUNCTION
(
this
);
110
m_models
.clear();
111
}
112
113
}
// namespace energy
114
}
// namespace ns3
ns3::Names::Find
static Ptr< T > Find(std::string path)
Given a name path string, look to see if there's an object in the system with that associated to it.
Definition
names.h:443
ns3::Ptr
Smart pointer class similar to boost::intrusive_ptr.
Definition
mpi-test-fixtures.h:37
ns3::energy::DeviceEnergyModelContainer
Holds a vector of ns3::DeviceEnergyModel pointers.
Definition
device-energy-model-container.h:36
ns3::energy::DeviceEnergyModelContainer::Add
void Add(DeviceEnergyModelContainer container)
Definition
device-energy-model-container.cc:80
ns3::energy::DeviceEnergyModelContainer::Iterator
std::vector< Ptr< DeviceEnergyModel > >::const_iterator Iterator
Const iterator of DeviceEnergyModel container.
Definition
device-energy-model-container.h:39
ns3::energy::DeviceEnergyModelContainer::m_models
std::vector< Ptr< DeviceEnergyModel > > m_models
Container of Energy models.
Definition
device-energy-model-container.h:164
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:73
ns3::energy::DeviceEnergyModelContainer::DeviceEnergyModelContainer
DeviceEnergyModelContainer()
Creates an empty DeviceEnergyModelContainer.
Definition
device-energy-model-container.cc:23
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:59
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:52
ns3::energy::DeviceEnergyModelContainer::Clear
void Clear()
Removes all elements in the container.
Definition
device-energy-model-container.cc:107
ns3::energy::DeviceEnergyModelContainer::GetN
uint32_t GetN() const
Get the number of Ptr<DeviceEnergyModel> stored in this container.
Definition
device-energy-model-container.cc:66
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:55
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition
log.h:191
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:229
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
src
energy
model
device-energy-model-container.cc
Generated on Fri Nov 8 2024 13:59:00 for ns-3 by
1.11.0