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.h
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
22
#ifndef DEVICE_ENERGY_MODEL_CONTAINER_H
23
#define DEVICE_ENERGY_MODEL_CONTAINER_H
24
25
#include "
device-energy-model.h
"
26
27
#include <stdint.h>
28
#include <vector>
29
30
namespace
ns3
31
{
32
namespace
energy
33
{
34
35
/**
36
* \ingroup energy
37
* \brief Holds a vector of ns3::DeviceEnergyModel pointers.
38
*
39
* DeviceEnergyModelContainer returns a list of DeviceEnergyModel pointers
40
* installed on a node. Users can use this list to access DeviceEnergyModel
41
* objects to obtain total device energy consumption on a node easily.
42
*
43
* \see NetDeviceContainer
44
*
45
*/
46
class
DeviceEnergyModelContainer
47
{
48
public
:
49
/// Const iterator of DeviceEnergyModel container
50
typedef
std::vector<Ptr<DeviceEnergyModel>>::const_iterator
Iterator
;
51
52
public
:
53
/**
54
* Creates an empty DeviceEnergyModelContainer.
55
*/
56
DeviceEnergyModelContainer
();
57
58
/**
59
* \param model Pointer to a DeviceEnergyModel.
60
*
61
* Creates a DeviceEnergyModelContainer with exactly one DeviceEnergyModel
62
* previously instantiated.
63
*/
64
DeviceEnergyModelContainer
(
Ptr<DeviceEnergyModel>
model);
65
66
/**
67
* \param modelName Name of DeviceEnergyModel.
68
*
69
* Creates an DeviceEnergyModelContainer with exactly one DeviceEnergyModel
70
* previously instantiated and assigned a name using the Object name service.
71
* This DeviceEnergyModel is specified by its assigned name.
72
*/
73
DeviceEnergyModelContainer
(std::string modelName);
74
75
/**
76
* \param a A DeviceEnergyModelContainer.
77
* \param b Another DeviceEnergyModelContainer.
78
*
79
* Creates a DeviceEnergyModelContainer by concatenating DeviceEnergyModelContainer b
80
* to DeviceEnergyModelContainer a.
81
*
82
* \note Can be used to concatenate 2 Ptr<DeviceEnergyModel> directly. C++
83
* will be calling DeviceEnergyModelContainer constructor with Ptr<DeviceEnergyModel>
84
* first.
85
*/
86
DeviceEnergyModelContainer
(
const
DeviceEnergyModelContainer
& a,
87
const
DeviceEnergyModelContainer
& b);
88
89
/**
90
* \brief Get an iterator which refers to the first DeviceEnergyModel pointer
91
* in the container.
92
*
93
* \returns An iterator which refers to the first DeviceEnergyModel in container.
94
*
95
* DeviceEnergyModels can be retrieved from the container in two ways. First,
96
* directly by an index into the container, and second, using an iterator.
97
* This method is used in the iterator method and is typically used in a
98
* for-loop to run through the DeviceEnergyModels.
99
*
100
* \code
101
* DeviceEnergyModelContainer::Iterator i;
102
* for (i = container.Begin (); i != container.End (); ++i)
103
* {
104
* (*i)->method (); // some DeviceEnergyModel method
105
* }
106
* \endcode
107
*/
108
Iterator
Begin
()
const
;
109
110
/**
111
* \brief Get an iterator which refers to the last DeviceEnergyModel pointer
112
* in the container.
113
*
114
* \returns An iterator which refers to the last DeviceEnergyModel in container.
115
*
116
* DeviceEnergyModels can be retrieved from the container in two ways. First,
117
* directly by an index into the container, and second, using an iterator.
118
* This method is used in the iterator method and is typically used in a
119
* for-loop to run through the DeviceEnergyModels.
120
*
121
* \code
122
* DeviceEnergyModelContainer::Iterator i;
123
* for (i = container.Begin (); i != container.End (); ++i)
124
* {
125
* (*i)->method (); // some DeviceEnergyModel method
126
* }
127
* \endcode
128
*/
129
Iterator
End
()
const
;
130
131
/**
132
* \brief Get the number of Ptr<DeviceEnergyModel> stored in this container.
133
*
134
* \returns The number of Ptr<DeviceEnergyModel> stored in this container.
135
*/
136
uint32_t
GetN
()
const
;
137
138
/**
139
* \brief Get the i-th Ptr<DeviceEnergyModel> stored in this container.
140
*
141
* \param i Index of the requested Ptr<DeviceEnergyModel>.
142
* \returns The requested Ptr<DeviceEnergyModel>.
143
*/
144
Ptr<DeviceEnergyModel>
Get
(
uint32_t
i)
const
;
145
146
/**
147
* \param container Another DeviceEnergyModelContainer.
148
*
149
* Appends the contents of another DeviceEnergyModelContainer to the end of
150
* this DeviceEnergyModelContainer.
151
*/
152
void
Add
(
DeviceEnergyModelContainer
container);
153
154
/**
155
* \brief Append a single Ptr<DeviceEnergyModel> to the end of this container.
156
*
157
* \param model Pointer to an DeviceEnergyModel.
158
*/
159
void
Add
(
Ptr<DeviceEnergyModel>
model);
160
161
/**
162
* \brief Append a single Ptr<DeviceEnergyModel> referred to by its object
163
* name to the end of this container.
164
*
165
* \param modelName Name of DeviceEnergyModel object.
166
*/
167
void
Add
(std::string modelName);
168
169
/**
170
* \brief Removes all elements in the container.
171
*/
172
void
Clear
();
173
174
private
:
175
std::vector<Ptr<DeviceEnergyModel>>
m_models
;
//!< Container of Energy models
176
};
177
178
}
// namespace energy
179
}
// namespace ns3
180
181
#endif
/* DEVICE_ENERGY_MODEL_CONTAINER_H */
ns3::Ptr
Smart pointer class similar to boost::intrusive_ptr.
Definition:
ptr.h:77
ns3::energy::DeviceEnergyModelContainer
Holds a vector of ns3::DeviceEnergyModel pointers.
Definition:
device-energy-model-container.h:47
ns3::energy::DeviceEnergyModelContainer::Add
void Add(DeviceEnergyModelContainer container)
Definition:
device-energy-model-container.cc:91
ns3::energy::DeviceEnergyModelContainer::Iterator
std::vector< Ptr< DeviceEnergyModel > >::const_iterator Iterator
Const iterator of DeviceEnergyModel container.
Definition:
device-energy-model-container.h:50
ns3::energy::DeviceEnergyModelContainer::m_models
std::vector< Ptr< DeviceEnergyModel > > m_models
Container of Energy models.
Definition:
device-energy-model-container.h:175
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:84
ns3::energy::DeviceEnergyModelContainer::DeviceEnergyModelContainer
DeviceEnergyModelContainer()
Creates an empty DeviceEnergyModelContainer.
Definition:
device-energy-model-container.cc:34
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:70
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:63
ns3::energy::DeviceEnergyModelContainer::Clear
void Clear()
Removes all elements in the container.
Definition:
device-energy-model-container.cc:118
ns3::energy::DeviceEnergyModelContainer::GetN
uint32_t GetN() const
Get the number of Ptr<DeviceEnergyModel> stored in this container.
Definition:
device-energy-model-container.cc:77
uint32_t
device-energy-model.h
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
src
energy
model
device-energy-model-container.h
Generated on Tue May 28 2024 23:35:17 for ns-3 by
1.9.6