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
* for (auto i = container.Begin(); i != container.End(); ++i)
71
* {
72
* (*i)->method(); // some Building method
73
* }
74
* @endcode
75
*
76
* @returns an iterator which refers to the first Building in the container.
77
*/
78
Iterator
Begin
()
const
;
79
80
/**
81
* @brief Get an iterator which indicates past-the-last Building in the
82
* container.
83
*
84
* Buildings can be retrieved from the container in two ways. First,
85
* directly by an index into the container, and second, using an iterator.
86
* This method is used in the iterator method and is typically used in a
87
* for-loop to run through the Buildings
88
*
89
* @code
90
* for (auto i = container.Begin(); i != container.End(); ++i)
91
* {
92
* (*i)->method(); // some Building method
93
* }
94
* @endcode
95
*
96
* @returns an iterator which indicates an ending condition for a loop.
97
*/
98
Iterator
End
()
const
;
99
100
/**
101
* @brief Get the number of Ptr<Building> stored in this container.
102
*
103
* Buildings can be retrieved from the container in two ways. First,
104
* directly by an index into the container, and second, using an iterator.
105
* This method is used in the direct method and is typically used to
106
* define an ending condition in a for-loop that runs through the stored
107
* Buildings
108
*
109
* @code
110
* uint32_t nBuildings = container.GetN ();
111
* for (uint32_t i = 0 i < nBuildings; ++i)
112
* {
113
* Ptr<Building> p = container.Get (i)
114
* i->method (); // some Building method
115
* }
116
* @endcode
117
*
118
* @returns the number of Ptr<Building> stored in this container.
119
*/
120
uint32_t
GetN
()
const
;
121
122
/**
123
* @brief Get the Ptr<Building> stored in this container at a given
124
* index.
125
*
126
* Buildings can be retrieved from the container in two ways. First,
127
* directly by an index into the container, and second, using an iterator.
128
* This method is used in the direct method and is used to retrieve the
129
* indexed Ptr<Application>.
130
*
131
* @code
132
* uint32_t nBuildings = container.GetN ();
133
* for (uint32_t i = 0 i < nBuildings; ++i)
134
* {
135
* Ptr<Building> p = container.Get (i)
136
* i->method (); // some Building method
137
* }
138
* @endcode
139
*
140
* @param i the index of the requested building pointer.
141
* @returns the requested building pointer.
142
*/
143
Ptr<Building>
Get
(
uint32_t
i)
const
;
144
145
/**
146
* @brief Create n buildings and append pointers to them to the end of this
147
* BuildingContainer.
148
*
149
* Buildings are at the heart of any ns-3 simulation. One of the first tasks that
150
* any simulation needs to do is to create a number of buildings. This method
151
* automates that task.
152
*
153
* @param n The number of Buildings to create
154
*/
155
void
Create
(
uint32_t
n);
156
157
/**
158
* @brief Append the contents of another BuildingContainer to the end of
159
* this container.
160
*
161
* @param other The BuildingContainer to append.
162
*/
163
void
Add
(
BuildingContainer
other);
164
165
/**
166
* @brief Append a single Ptr<Building> to this container.
167
*
168
* @param building The Ptr<Building> to append.
169
*/
170
void
Add
(
Ptr<Building>
building);
171
172
/**
173
* @brief Append to this container the single Ptr<Building> referred to
174
* via its object name service registered name.
175
*
176
* @param buildingName The name of the Building Object to add to the container.
177
*/
178
void
Add
(std::string buildingName);
179
180
/**
181
* @brief Create a BuildingContainer that contains a list of _all_ buildings
182
* stored in the ns3::BuildingList.
183
*
184
* Whenever a Building is created, a Ptr<Building> is added to a global list of all
185
* buildings in the system. It is sometimes useful to be able to get to all
186
* buildings in one place. This method creates a BuildingContainer that is
187
* initialized to contain all of the simulation buildings,
188
*
189
* @returns a BuildingContainer which contains a list of all Buildings.
190
*/
191
static
BuildingContainer
GetGlobal
();
192
193
private
:
194
std::vector<Ptr<Building>>
m_buildings
;
//!< Building container
195
};
196
197
}
// namespace ns3
198
199
#endif
/* BUILDING_CONTAINER_H */
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:194
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
ptr.h:70
uint32_t
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
src
buildings
helper
building-container.h
Generated on
for ns-3 by
1.15.0