A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Portuguese
Docs ▼
Wiki
Manual
Models
Develop ▼
API
Bugs
API
src
energy
model
device-energy-model-container.cc
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
* Copyright (c) 2008 INRIA
4
* Copyright (c) 2010 Network Security Lab, University of Washington, Seattle.
5
*
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License version 2 as
8
* published by the Free Software Foundation;
9
*
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
14
*
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
*
19
* Authors: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
20
* Sidharth Nabar <snabar@uw.edu>, He Wu <mdzz@u.washington.edu>
21
*/
22
23
#include "
device-energy-model-container.h
"
24
#include "ns3/names.h"
25
#include "ns3/log.h"
26
27
namespace
ns3
{
28
29
NS_LOG_COMPONENT_DEFINE
(
"DeviceEnergyModelContainer"
);
30
31
DeviceEnergyModelContainer::DeviceEnergyModelContainer
()
32
{
33
NS_LOG_FUNCTION
(
this
);
34
}
35
36
DeviceEnergyModelContainer::DeviceEnergyModelContainer
(
Ptr<DeviceEnergyModel>
model)
37
{
38
NS_LOG_FUNCTION
(
this
<< model);
39
NS_ASSERT
(model != NULL);
40
m_models
.push_back (model);
41
}
42
43
DeviceEnergyModelContainer::DeviceEnergyModelContainer
(std::string modelName)
44
{
45
NS_LOG_FUNCTION
(
this
<< modelName);
46
Ptr<DeviceEnergyModel>
model = Names::Find<DeviceEnergyModel> (modelName);
47
NS_ASSERT
(model != NULL);
48
m_models
.push_back (model);
49
}
50
51
DeviceEnergyModelContainer::DeviceEnergyModelContainer
(
const
DeviceEnergyModelContainer
&a,
52
const
DeviceEnergyModelContainer
&b)
53
{
54
NS_LOG_FUNCTION
(
this
<< &a << &b);
55
*
this
= a;
56
Add
(b);
57
}
58
59
DeviceEnergyModelContainer::Iterator
60
DeviceEnergyModelContainer::Begin
(
void
)
const
61
{
62
NS_LOG_FUNCTION
(
this
);
63
return
m_models
.begin ();
64
}
65
66
DeviceEnergyModelContainer::Iterator
67
DeviceEnergyModelContainer::End
(
void
)
const
68
{
69
NS_LOG_FUNCTION
(
this
);
70
return
m_models
.end ();
71
}
72
73
uint32_t
74
DeviceEnergyModelContainer::GetN
(
void
)
const
75
{
76
NS_LOG_FUNCTION
(
this
);
77
return
m_models
.size ();
78
}
79
80
Ptr<DeviceEnergyModel>
81
DeviceEnergyModelContainer::Get
(uint32_t i)
const
82
{
83
NS_LOG_FUNCTION
(
this
<< i);
84
return
m_models
[i];
85
}
86
87
void
88
DeviceEnergyModelContainer::Add
(
DeviceEnergyModelContainer
container)
89
{
90
NS_LOG_FUNCTION
(
this
<< &container);
91
for
(
Iterator
i = container.
Begin
(); i != container.
End
(); i++)
92
{
93
m_models
.push_back (*i);
94
}
95
}
96
97
void
98
DeviceEnergyModelContainer::Add
(
Ptr<DeviceEnergyModel>
model)
99
{
100
NS_LOG_FUNCTION
(
this
<< model);
101
NS_ASSERT
(model != NULL);
102
m_models
.push_back (model);
103
}
104
105
void
106
DeviceEnergyModelContainer::Add
(std::string modelName)
107
{
108
NS_LOG_FUNCTION
(
this
<< modelName);
109
Ptr<DeviceEnergyModel>
model = Names::Find<DeviceEnergyModel> (modelName);
110
NS_ASSERT
(model != NULL);
111
m_models
.push_back (model);
112
}
113
114
void
115
DeviceEnergyModelContainer::Clear
(
void
)
116
{
117
NS_LOG_FUNCTION
(
this
);
118
m_models
.clear ();
119
}
120
121
}
// namespace ns3
ns3::DeviceEnergyModelContainer::Iterator
std::vector< Ptr< DeviceEnergyModel > >::const_iterator Iterator
Definition:
device-energy-model-container.h:46
ns3::Ptr
Smart pointer class similar to boost::intrusive_ptr.
Definition:
ptr.h:73
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:213
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:67
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition:
log.h:202
ns3::DeviceEnergyModelContainer::Add
void Add(DeviceEnergyModelContainer container)
Definition:
device-energy-model-container.cc:88
ns3::DeviceEnergyModelContainer
Holds a vector of ns3::DeviceEnergyModel pointers.
Definition:
device-energy-model-container.h:43
ns3::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:81
ns3::DeviceEnergyModelContainer::GetN
uint32_t GetN(void) const
Get the number of Ptr<DeviceEnergyModel> stored in this container.
Definition:
device-energy-model-container.cc:74
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::DeviceEnergyModelContainer::End
Iterator End(void) const
Get an iterator which refers to the last DeviceEnergyModel pointer in the container.
Definition:
device-energy-model-container.cc:67
device-energy-model-container.h
ns3::DeviceEnergyModelContainer::Begin
Iterator Begin(void) const
Get an iterator which refers to the first DeviceEnergyModel pointer in the container.
Definition:
device-energy-model-container.cc:60
ns3::DeviceEnergyModelContainer::m_models
std::vector< Ptr< DeviceEnergyModel > > m_models
Definition:
device-energy-model-container.h:171
ns3::DeviceEnergyModelContainer::DeviceEnergyModelContainer
DeviceEnergyModelContainer()
Creates an empty DeviceEnergyModelContainer.
Definition:
device-energy-model-container.cc:31
ns3::DeviceEnergyModelContainer::Clear
void Clear(void)
Removes all elements in the container.
Definition:
device-energy-model-container.cc:115
Generated on Wed Nov 7 2018 10:01:52 for ns-3 by
1.8.14