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