A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
ns3::BuildingContainer Class Reference

keep track of a set of building pointers. More...

#include "building-container.h"

+ Collaboration diagram for ns3::BuildingContainer:

Public Types

typedef std::vector< Ptr< Building > >::const_iterator Iterator
 Const iterator.
 

Public Member Functions

 BuildingContainer ()
 Create an empty BuildingContainer.
 
 BuildingContainer (Ptr< Building > building)
 Create a BuildingContainer with exactly one building which has been previously instantiated.
 
 BuildingContainer (std::string buildingName)
 Create a BuildingContainer with exactly one building which has been previously instantiated and assigned a name using the Object Name Service.
 
void Add (BuildingContainer other)
 Append the contents of another BuildingContainer to the end of this container.
 
void Add (Ptr< Building > building)
 Append a single Ptr<Building> to this container.
 
void Add (std::string buildingName)
 Append to this container the single Ptr<Building> referred to via its object name service registered name.
 
Iterator Begin () const
 Get an iterator which refers to the first Building in the container.
 
void Create (uint32_t n)
 Create n buildings and append pointers to them to the end of this BuildingContainer.
 
Iterator End () const
 Get an iterator which indicates past-the-last Building in the container.
 
Ptr< BuildingGet (uint32_t i) const
 Get the Ptr<Building> stored in this container at a given index.
 
uint32_t GetN () const
 Get the number of Ptr<Building> stored in this container.
 

Static Public Member Functions

static BuildingContainer GetGlobal ()
 Create a BuildingContainer that contains a list of all buildings stored in the ns3::BuildingList.
 

Private Attributes

std::vector< Ptr< Building > > m_buildings
 Building container.
 

Detailed Description

keep track of a set of building pointers.

Some ns-3 helpers operate on more than one building at a time. For example a PositionAllocator may want to position nodes on a set of buildings. The helper methods will then usually take a BuildingContainer as a parameter. BuildingContainers hold the multiple Ptr<Building> which are used to refer to the buildings.

Definition at line 32 of file building-container.h.

Member Typedef Documentation

◆ Iterator

typedef std::vector<Ptr<Building>>::const_iterator ns3::BuildingContainer::Iterator

Const iterator.

Definition at line 36 of file building-container.h.

Constructor & Destructor Documentation

◆ BuildingContainer() [1/3]

ns3::BuildingContainer::BuildingContainer ( )

Create an empty BuildingContainer.

Definition at line 18 of file building-container.cc.

◆ BuildingContainer() [2/3]

ns3::BuildingContainer::BuildingContainer ( Ptr< Building > building)

Create a BuildingContainer with exactly one building which has been previously instantiated.

The single Building is specified by a smart pointer.

Parameters
buildingThe Ptr<Building> to add to the container.

Definition at line 22 of file building-container.cc.

References m_buildings.

◆ BuildingContainer() [3/3]

ns3::BuildingContainer::BuildingContainer ( std::string buildingName)

Create a BuildingContainer with exactly one building which has been previously instantiated and assigned a name using the Object Name Service.

This Building is then specified by its assigned name.

Parameters
buildingNameThe name of the Building Object to add to the container.

Definition at line 27 of file building-container.cc.

References ns3::Names::Find(), and m_buildings.

+ Here is the call graph for this function:

Member Function Documentation

◆ Add() [1/3]

void ns3::BuildingContainer::Add ( BuildingContainer other)

Append the contents of another BuildingContainer to the end of this container.

Parameters
otherThe BuildingContainer to append.

Definition at line 67 of file building-container.cc.

References Begin(), End(), and m_buildings.

Referenced by ns3::GridBuildingAllocator::Create(), and GetGlobal().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Add() [2/3]

void ns3::BuildingContainer::Add ( Ptr< Building > building)

Append a single Ptr<Building> to this container.

Parameters
buildingThe Ptr<Building> to append.

Definition at line 76 of file building-container.cc.

References m_buildings.

◆ Add() [3/3]

void ns3::BuildingContainer::Add ( std::string buildingName)

Append to this container the single Ptr<Building> referred to via its object name service registered name.

Parameters
buildingNameThe name of the Building Object to add to the container.

Definition at line 82 of file building-container.cc.

References ns3::Names::Find(), and m_buildings.

+ Here is the call graph for this function:

◆ Begin()

BuildingContainer::Iterator ns3::BuildingContainer::Begin ( ) const

Get an iterator which refers to the first Building in the container.

Buildings can be retrieved from the container in two ways. First, directly by an index into the container, and second, using an iterator. This method is used in the iterator method and is typically used in a for-loop to run through the Buildings

for (i = container.Begin (); i != container.End (); ++i)
{
(*i)->method (); // some Building method
}
std::vector< Ptr< Building > >::const_iterator Iterator
Const iterator.
Returns
an iterator which refers to the first Building in the container.

Definition at line 34 of file building-container.cc.

References m_buildings.

Referenced by Add().

+ Here is the caller graph for this function:

◆ Create()

void ns3::BuildingContainer::Create ( uint32_t n)

Create n buildings and append pointers to them to the end of this BuildingContainer.

Buildings are at the heart of any ns-3 simulation. One of the first tasks that any simulation needs to do is to create a number of buildings. This method automates that task.

Parameters
nThe number of Buildings to create

Definition at line 58 of file building-container.cc.

References ns3::CreateObject(), and m_buildings.

+ Here is the call graph for this function:

◆ End()

BuildingContainer::Iterator ns3::BuildingContainer::End ( ) const

Get an iterator which indicates past-the-last Building in the container.

Buildings can be retrieved from the container in two ways. First, directly by an index into the container, and second, using an iterator. This method is used in the iterator method and is typically used in a for-loop to run through the Buildings

for (i = container.Begin (); i != container.End (); ++i)
{
(*i)->method (); // some Building method
}
Returns
an iterator which indicates an ending condition for a loop.

Definition at line 40 of file building-container.cc.

References m_buildings.

Referenced by Add().

+ Here is the caller graph for this function:

◆ Get()

Ptr< Building > ns3::BuildingContainer::Get ( uint32_t i) const

Get the Ptr<Building> stored in this container at a given index.

Buildings can be retrieved from the container in two ways. First, directly by an index into the container, and second, using an iterator. This method is used in the direct method and is used to retrieve the indexed Ptr<Application>.

uint32_t nBuildings = container.GetN ();
for (uint32_t i = 0 i < nBuildings; ++i)
{
Ptr<Building> p = container.Get (i)
i->method (); // some Building method
}
Smart pointer class similar to boost::intrusive_ptr.
Parameters
ithe index of the requested building pointer.
Returns
the requested building pointer.

Definition at line 52 of file building-container.cc.

References m_buildings.

◆ GetGlobal()

BuildingContainer ns3::BuildingContainer::GetGlobal ( )
static

Create a BuildingContainer that contains a list of all buildings stored in the ns3::BuildingList.

Whenever a Building is created, a Ptr<Building> is added to a global list of all buildings in the system. It is sometimes useful to be able to get to all buildings in one place. This method creates a BuildingContainer that is initialized to contain all of the simulation buildings,

Returns
a BuildingContainer which contains a list of all Buildings.

Definition at line 89 of file building-container.cc.

References Add(), ns3::BuildingList::Begin(), and ns3::BuildingList::End().

+ Here is the call graph for this function:

◆ GetN()

uint32_t ns3::BuildingContainer::GetN ( ) const

Get the number of Ptr<Building> stored in this container.

Buildings can be retrieved from the container in two ways. First, directly by an index into the container, and second, using an iterator. This method is used in the direct method and is typically used to define an ending condition in a for-loop that runs through the stored Buildings

uint32_t nBuildings = container.GetN ();
for (uint32_t i = 0 i < nBuildings; ++i)
{
Ptr<Building> p = container.Get (i)
i->method (); // some Building method
}
Returns
the number of Ptr<Building> stored in this container.

Definition at line 46 of file building-container.cc.

References m_buildings.

Member Data Documentation

◆ m_buildings

std::vector<Ptr<Building> > ns3::BuildingContainer::m_buildings
private

Building container.

Definition at line 196 of file building-container.h.

Referenced by BuildingContainer(), BuildingContainer(), Add(), Add(), Add(), Begin(), Create(), End(), Get(), and GetN().


The documentation for this class was generated from the following files: