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