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 BuildingContainer()28BuildingContainer::BuildingContainer () 29 { 30 } 31 BuildingContainer(Ptr<Building> building)32BuildingContainer::BuildingContainer (Ptr<Building> building) 33 { 34 m_buildings.push_back (building); 35 } BuildingContainer(std::string buildingName)36BuildingContainer::BuildingContainer (std::string buildingName) 37 { 38 Ptr<Building> building = Names::Find<Building> (buildingName); 39 m_buildings.push_back (building); 40 } 41 42 BuildingContainer::Iterator Begin(void) const43BuildingContainer::Begin (void) const 44 { 45 return m_buildings.begin (); 46 } 47 BuildingContainer::Iterator End(void) const48BuildingContainer::End (void) const 49 { 50 return m_buildings.end (); 51 } 52 53 uint32_t GetN(void) const54BuildingContainer::GetN (void) const 55 { 56 return m_buildings.size (); 57 } 58 Ptr<Building> Get(uint32_t i) const59BuildingContainer::Get (uint32_t i) const 60 { 61 return m_buildings[i]; 62 } 63 void Create(uint32_t n)64BuildingContainer::Create (uint32_t n) 65 { 66 for (uint32_t i = 0; i < n; i++) 67 { 68 m_buildings.push_back (CreateObject<Building> ()); 69 } 70 } 71 void Add(BuildingContainer other)72BuildingContainer::Add (BuildingContainer other) 73 { 74 for (Iterator i = other.Begin (); i != other.End (); i++) 75 { 76 m_buildings.push_back (*i); 77 } 78 } 79 void Add(Ptr<Building> building)80BuildingContainer::Add (Ptr<Building> building) 81 { 82 m_buildings.push_back (building); 83 } 84 void Add(std::string buildingName)85BuildingContainer::Add (std::string buildingName) 86 { 87 Ptr<Building> building = Names::Find<Building> (buildingName); 88 m_buildings.push_back (building); 89 } 90 91 BuildingContainer GetGlobal(void)92BuildingContainer::GetGlobal (void) 93 { 94 BuildingContainer c; 95 for (BuildingList::Iterator i = BuildingList::Begin (); i != BuildingList::End (); ++i) 96 { 97 c.Add (*i); 98 } 99 return c; 100 } 101 102 } // namespace ns3 103