A Discrete-Event Network Simulator
API
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 
24 #include "ns3/names.h"
25 #include "ns3/log.h"
26 
27 namespace ns3 {
28 
29 NS_LOG_COMPONENT_DEFINE ("DeviceEnergyModelContainer");
30 
32 {
33  NS_LOG_FUNCTION (this);
34 }
35 
37 {
38  NS_LOG_FUNCTION (this << model);
39  NS_ASSERT (model != NULL);
40  m_models.push_back (model);
41 }
42 
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 
53 {
54  NS_LOG_FUNCTION (this << &a << &b);
55  *this = a;
56  Add (b);
57 }
58 
61 {
62  NS_LOG_FUNCTION (this);
63  return m_models.begin ();
64 }
65 
68 {
69  NS_LOG_FUNCTION (this);
70  return m_models.end ();
71 }
72 
73 uint32_t
75 {
76  NS_LOG_FUNCTION (this);
77  return m_models.size ();
78 }
79 
82 {
83  NS_LOG_FUNCTION (this << i);
84  return m_models[i];
85 }
86 
87 void
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
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
116 {
117  NS_LOG_FUNCTION (this);
118  m_models.clear ();
119 }
120 
121 } // namespace ns3
std::vector< Ptr< DeviceEnergyModel > >::const_iterator Iterator
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:73
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
#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
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:202
void Add(DeviceEnergyModelContainer container)
Holds a vector of ns3::DeviceEnergyModel pointers.
Ptr< DeviceEnergyModel > Get(uint32_t i) const
Get the i-th Ptr<DeviceEnergyModel> stored in this container.
uint32_t GetN(void) const
Get the number of Ptr<DeviceEnergyModel> stored in this container.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Iterator End(void) const
Get an iterator which refers to the last DeviceEnergyModel pointer in the container.
Iterator Begin(void) const
Get an iterator which refers to the first DeviceEnergyModel pointer in the container.
std::vector< Ptr< DeviceEnergyModel > > m_models
DeviceEnergyModelContainer()
Creates an empty DeviceEnergyModelContainer.
void Clear(void)
Removes all elements in the container.