A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
API
building-container.cc
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.cc)
19
* Nicola Baldo (wrote building-container.cc based on node-container.cc)
20
*/
21
#include "
building-container.h
"
22
23
#include "ns3/building-list.h"
24
#include "ns3/names.h"
25
26
namespace
ns3
27
{
28
29
BuildingContainer::BuildingContainer
()
30
{
31
}
32
33
BuildingContainer::BuildingContainer
(
Ptr<Building>
building)
34
{
35
m_buildings
.push_back(building);
36
}
37
38
BuildingContainer::BuildingContainer
(std::string buildingName)
39
{
40
Ptr<Building>
building = Names::Find<Building>(buildingName);
41
m_buildings
.push_back(building);
42
}
43
44
BuildingContainer::Iterator
45
BuildingContainer::Begin
()
const
46
{
47
return
m_buildings
.begin();
48
}
49
50
BuildingContainer::Iterator
51
BuildingContainer::End
()
const
52
{
53
return
m_buildings
.end();
54
}
55
56
uint32_t
57
BuildingContainer::GetN
()
const
58
{
59
return
m_buildings
.size();
60
}
61
62
Ptr<Building>
63
BuildingContainer::Get
(uint32_t i)
const
64
{
65
return
m_buildings
[i];
66
}
67
68
void
69
BuildingContainer::Create
(uint32_t n)
70
{
71
for
(uint32_t i = 0; i < n; i++)
72
{
73
m_buildings
.push_back(CreateObject<Building>());
74
}
75
}
76
77
void
78
BuildingContainer::Add
(
BuildingContainer
other)
79
{
80
for
(
auto
i = other.
Begin
(); i != other.
End
(); i++)
81
{
82
m_buildings
.push_back(*i);
83
}
84
}
85
86
void
87
BuildingContainer::Add
(
Ptr<Building>
building)
88
{
89
m_buildings
.push_back(building);
90
}
91
92
void
93
BuildingContainer::Add
(std::string buildingName)
94
{
95
Ptr<Building>
building = Names::Find<Building>(buildingName);
96
m_buildings
.push_back(building);
97
}
98
99
BuildingContainer
100
BuildingContainer::GetGlobal
()
101
{
102
BuildingContainer
c;
103
for
(
auto
i =
BuildingList::Begin
(); i !=
BuildingList::End
(); ++i)
104
{
105
c.
Add
(*i);
106
}
107
return
c;
108
}
109
110
}
// namespace ns3
building-container.h
ns3::BuildingContainer
keep track of a set of building pointers.
Definition:
building-container.h:42
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:205
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::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::BuildingContainer::Iterator
std::vector< Ptr< Building > >::const_iterator Iterator
Const iterator.
Definition:
building-container.h:45
ns3::BuildingList::End
static Iterator End()
Definition:
building-list.cc:230
ns3::BuildingList::Begin
static Iterator Begin()
Definition:
building-list.cc:224
ns3::Ptr
Smart pointer class similar to boost::intrusive_ptr.
Definition:
ptr.h:77
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
src
buildings
helper
building-container.cc
Generated on Sun Mar 3 2024 17:10:54 for ns-3 by
1.9.1