A Discrete-Event Network Simulator
API
building-container.cc
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2008 INRIA
4  * Copyright (c) 2011 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC)
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 as
8  * published by the Free Software Foundation;
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  *
19  * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr> (original node-container.cc)
20  * Nicola Baldo (wrote building-container.cc based on node-container.cc)
21  */
22 #include "building-container.h"
23 #include "ns3/building-list.h"
24 #include "ns3/names.h"
25 
26 namespace ns3 {
27 
29 {
30 }
31 
33 {
34  m_buildings.push_back (building);
35 }
36 BuildingContainer::BuildingContainer (std::string buildingName)
37 {
38  Ptr<Building> building = Names::Find<Building> (buildingName);
39  m_buildings.push_back (building);
40 }
41 
44 {
45  return m_buildings.begin ();
46 }
49 {
50  return m_buildings.end ();
51 }
52 
53 uint32_t
55 {
56  return m_buildings.size ();
57 }
59 BuildingContainer::Get (uint32_t i) const
60 {
61  return m_buildings[i];
62 }
63 void
65 {
66  for (uint32_t i = 0; i < n; i++)
67  {
68  m_buildings.push_back (CreateObject<Building> ());
69  }
70 }
71 void
73 {
74  for (Iterator i = other.Begin (); i != other.End (); i++)
75  {
76  m_buildings.push_back (*i);
77  }
78 }
79 void
81 {
82  m_buildings.push_back (building);
83 }
84 void
85 BuildingContainer::Add (std::string buildingName)
86 {
87  Ptr<Building> building = Names::Find<Building> (buildingName);
88  m_buildings.push_back (building);
89 }
90 
93 {
96  {
97  c.Add (*i);
98  }
99  return c;
100 }
101 
102 } // namespace ns3
keep track of a set of building pointers.
std::vector< Ptr< Building > > m_buildings
Building container.
void Create(uint32_t n)
Create n buildings and append pointers to them to the end of this BuildingContainer.
BuildingContainer()
Create an empty BuildingContainer.
Iterator End(void) const
Get an iterator which indicates past-the-last Building in the container.
void Add(BuildingContainer other)
Append the contents of another BuildingContainer to the end of this container.
Ptr< Building > Get(uint32_t i) const
Get the Ptr<Building> stored in this container at a given index.
Iterator Begin(void) const
Get an iterator which refers to the first Building in the container.
static BuildingContainer GetGlobal(void)
Create a BuildingContainer that contains a list of all buildings stored in the ns3::BuildingList.
uint32_t GetN(void) const
Get the number of Ptr<Building> stored in this container.
std::vector< Ptr< Building > >::const_iterator Iterator
Const iterator.
std::vector< Ptr< Building > >::const_iterator Iterator
Const Iterator.
Definition: building-list.h:40
static Iterator End(void)
static Iterator Begin(void)
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:74
Every class exported by the ns3 library is enclosed in the ns3 namespace.