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
building-container.h
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2008 INRIA
3
* Copyright (c) 2011 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC)
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
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr> (original node-container.h)
19
* Nicola Baldo (wrote building-container.h based on node-container.h)
20
*/
21
#ifndef BUILDING_CONTAINER_H
22
#define BUILDING_CONTAINER_H
23
24
#include <ns3/building.h>
25
26
#include <stdint.h>
27
#include <vector>
28
29
namespace
ns3
30
{
31
32
/**
33
* \ingroup buildings
34
*
35
* \brief keep track of a set of building pointers.
36
*
37
* Some ns-3 helpers operate on more than one building at a time. For example
38
* a PositionAllocator may want to position nodes on a set of buildings.
39
* The helper methods will then usually take a BuildingContainer as a
40
* parameter. BuildingContainers hold the multiple Ptr<Building> which are used
41
* to refer to the buildings.
42
*/
43
class
BuildingContainer
44
{
45
public
:
46
/// Const iterator
47
typedef
std::vector<Ptr<Building>>::const_iterator
Iterator
;
48
49
/**
50
* Create an empty BuildingContainer.
51
*/
52
BuildingContainer
();
53
54
/**
55
* Create a BuildingContainer with exactly one building which has been previously
56
* instantiated. The single Building is specified by a smart pointer.
57
*
58
* \param building The Ptr<Building> to add to the container.
59
*/
60
BuildingContainer
(
Ptr<Building>
building);
61
62
/**
63
* Create a BuildingContainer with exactly one building which has been previously
64
* instantiated and assigned a name using the Object Name Service. This
65
* Building is then specified by its assigned name.
66
*
67
* \param buildingName The name of the Building Object to add to the container.
68
*/
69
BuildingContainer
(std::string buildingName);
70
71
/**
72
* \brief Get an iterator which refers to the first Building in the
73
* container.
74
*
75
* Buildings can be retrieved from the container in two ways. First,
76
* directly by an index into the container, and second, using an iterator.
77
* This method is used in the iterator method and is typically used in a
78
* for-loop to run through the Buildings
79
*
80
* \code
81
* BuildingContainer::Iterator i;
82
* for (i = container.Begin (); i != container.End (); ++i)
83
* {
84
* (*i)->method (); // some Building method
85
* }
86
* \endcode
87
*
88
* \returns an iterator which refers to the first Building in the container.
89
*/
90
Iterator
Begin
()
const
;
91
92
/**
93
* \brief Get an iterator which indicates past-the-last Building in the
94
* container.
95
*
96
* Buildings can be retrieved from the container in two ways. First,
97
* directly by an index into the container, and second, using an iterator.
98
* This method is used in the iterator method and is typically used in a
99
* for-loop to run through the Buildings
100
*
101
* \code
102
* BuildingContainer::Iterator i;
103
* for (i = container.Begin (); i != container.End (); ++i)
104
* {
105
* (*i)->method (); // some Building method
106
* }
107
* \endcode
108
*
109
* \returns an iterator which indicates an ending condition for a loop.
110
*/
111
Iterator
End
()
const
;
112
113
/**
114
* \brief Get the number of Ptr<Building> stored in this container.
115
*
116
* Buildings 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 direct method and is typically used to
119
* define an ending condition in a for-loop that runs through the stored
120
* Buildings
121
*
122
* \code
123
* uint32_t nBuildings = container.GetN ();
124
* for (uint32_t i = 0 i < nBuildings; ++i)
125
* {
126
* Ptr<Building> p = container.Get (i)
127
* i->method (); // some Building method
128
* }
129
* \endcode
130
*
131
* \returns the number of Ptr<Building> stored in this container.
132
*/
133
uint32_t
GetN
()
const
;
134
135
/**
136
* \brief Get the Ptr<Building> stored in this container at a given
137
* index.
138
*
139
* Buildings can be retrieved from the container in two ways. First,
140
* directly by an index into the container, and second, using an iterator.
141
* This method is used in the direct method and is used to retrieve the
142
* indexed Ptr<Application>.
143
*
144
* \code
145
* uint32_t nBuildings = container.GetN ();
146
* for (uint32_t i = 0 i < nBuildings; ++i)
147
* {
148
* Ptr<Building> p = container.Get (i)
149
* i->method (); // some Building method
150
* }
151
* \endcode
152
*
153
* \param i the index of the requested building pointer.
154
* \returns the requested building pointer.
155
*/
156
Ptr<Building>
Get
(
uint32_t
i)
const
;
157
158
/**
159
* \brief Create n buildings and append pointers to them to the end of this
160
* BuildingContainer.
161
*
162
* Buildings are at the heart of any ns-3 simulation. One of the first tasks that
163
* any simulation needs to do is to create a number of buildings. This method
164
* automates that task.
165
*
166
* \param n The number of Buildings to create
167
*/
168
void
Create
(
uint32_t
n);
169
170
/**
171
* \brief Append the contents of another BuildingContainer to the end of
172
* this container.
173
*
174
* \param other The BuildingContainer to append.
175
*/
176
void
Add
(
BuildingContainer
other);
177
178
/**
179
* \brief Append a single Ptr<Building> to this container.
180
*
181
* \param building The Ptr<Building> to append.
182
*/
183
void
Add
(
Ptr<Building>
building);
184
185
/**
186
* \brief Append to this container the single Ptr<Building> referred to
187
* via its object name service registered name.
188
*
189
* \param buildingName The name of the Building Object to add to the container.
190
*/
191
void
Add
(std::string buildingName);
192
193
/**
194
* \brief Create a BuildingContainer that contains a list of _all_ buildings
195
* stored in the ns3::BuildingList.
196
*
197
* Whenever a Building is created, a Ptr<Building> is added to a global list of all
198
* buildings in the system. It is sometimes useful to be able to get to all
199
* buildings in one place. This method creates a BuildingContainer that is
200
* initialized to contain all of the simulation buildings,
201
*
202
* \returns a BuildingContainer which contains a list of all Buildings.
203
*/
204
static
BuildingContainer
GetGlobal
();
205
206
private
:
207
std::vector<Ptr<Building>>
m_buildings
;
//!< Building container
208
};
209
210
}
// namespace ns3
211
212
#endif
/* BUILDING_CONTAINER_H */
ns3::BuildingContainer
keep track of a set of building pointers.
Definition:
building-container.h:44
ns3::BuildingContainer::End
Iterator End() const
Get an iterator which indicates past-the-last Building in the container.
Definition:
building-container.cc:51
ns3::BuildingContainer::m_buildings
std::vector< Ptr< Building > > m_buildings
Building container.
Definition:
building-container.h:207
ns3::BuildingContainer::Create
void Create(uint32_t n)
Create n buildings and append pointers to them to the end of this BuildingContainer.
Definition:
building-container.cc:69
ns3::BuildingContainer::Iterator
std::vector< Ptr< Building > >::const_iterator Iterator
Const iterator.
Definition:
building-container.h:47
ns3::BuildingContainer::BuildingContainer
BuildingContainer()
Create an empty BuildingContainer.
Definition:
building-container.cc:29
ns3::BuildingContainer::GetN
uint32_t GetN() const
Get the number of Ptr<Building> stored in this container.
Definition:
building-container.cc:57
ns3::BuildingContainer::GetGlobal
static BuildingContainer GetGlobal()
Create a BuildingContainer that contains a list of all buildings stored in the ns3::BuildingList.
Definition:
building-container.cc:100
ns3::BuildingContainer::Add
void Add(BuildingContainer other)
Append the contents of another BuildingContainer to the end of this container.
Definition:
building-container.cc:78
ns3::BuildingContainer::Begin
Iterator Begin() const
Get an iterator which refers to the first Building in the container.
Definition:
building-container.cc:45
ns3::BuildingContainer::Get
Ptr< Building > Get(uint32_t i) const
Get the Ptr<Building> stored in this container at a given index.
Definition:
building-container.cc:63
ns3::Ptr
Smart pointer class similar to boost::intrusive_ptr.
Definition:
ptr.h:77
uint32_t
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
src
buildings
helper
building-container.h
Generated on Tue May 28 2024 23:34:15 for ns-3 by
1.9.6