A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
device-energy-model-container.cc
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 NS_LOG_COMPONENT_DEFINE ("DeviceEnergyModelContainer");
28 
29 namespace ns3 {
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 
59 DeviceEnergyModelContainer::Iterator
61 {
62  NS_LOG_FUNCTION (this);
63  return m_models.begin ();
64 }
65 
66 DeviceEnergyModelContainer::Iterator
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
smart pointer class similar to boost::intrusive_ptr
Definition: ptr.h:59
#define NS_LOG_FUNCTION(parameters)
Definition: log.h:311
#define NS_ASSERT(condition)
Definition: assert.h:64
#define NS_LOG_COMPONENT_DEFINE(name)
Definition: log.h:122
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.
Iterator Begin(void) const
Get an iterator which refers to the first DeviceEnergyModel pointer in the container.
Iterator End(void) const
Get an iterator which refers to the last DeviceEnergyModel pointer in the container.
uint32_t GetN(void) const
Get the number of Ptr<DeviceEnergyModel> stored in this container.
void Clear(void)
Removes all elements in the container.