SUMO - Simulation of Urban MObility
ODDistrictCont Class Reference

A container for districts. More...

#include <ODDistrictCont.h>

Inheritance diagram for ODDistrictCont:
NamedObjectCont< ODDistrict * >

Public Types

typedef std::map< std::string,
ODDistrict * > 
IDMap
 Definition of the key to pointer map type.

Public Member Functions

virtual bool add (const std::string &id, ODDistrict *item)
 Adds an item.
const std::vector< ODDistrict * > & buildAndGetStaticVector () const
void clear ()
 Removes all items from the container (deletes them, too)
bool erase (const std::string &id)
 Removes the named item from the container.
ODDistrictget (const std::string &id) const
 Retrieves an item.
const IDMapgetMyMap () const
std::string getRandomSinkFromDistrict (const std::string &name) const throw (OutOfBoundsException, InvalidArgument)
 Returns the id of a random sink from the named district.
std::string getRandomSourceFromDistrict (const std::string &name) const throw (OutOfBoundsException, InvalidArgument)
 Returns the id of a random source from the named district.
std::vector< ODDistrict * > getTempVector () const
void insertIDs (std::vector< std::string > &into) const
 ODDistrictCont ()
 Constructor.
virtual bool remove (const std::string &id)
 Removes an item.
unsigned int size () const
 Returns the number of items within the container.
 ~ODDistrictCont ()
 Destructor.

Private Member Functions

 ODDistrictCont (const ODDistrictCont &s)
 invalidated copy constructor
ODDistrictContoperator= (const ODDistrictCont &s)
 invalidated assignment operator

Detailed Description

A container for districts.

Besides the inherited methods for adding/removing districts, this container allows to retrieve a random source or sink from a named district.

Definition at line 47 of file ODDistrictCont.h.


Member Typedef Documentation

typedef std::map< std::string, ODDistrict * > NamedObjectCont< ODDistrict * >::IDMap [inherited]

Definition of the key to pointer map type.

Definition at line 56 of file NamedObjectCont.h.


Constructor & Destructor Documentation

Constructor.

Definition at line 47 of file ODDistrictCont.cpp.

Destructor.

Definition at line 50 of file ODDistrictCont.cpp.

invalidated copy constructor


Member Function Documentation

virtual bool NamedObjectCont< ODDistrict * >::add ( const std::string &  id,
ODDistrict item 
) [inline, virtual, inherited]

Adds an item.

If another item with the same name is already known, false is reported and the item is not added.

Parameters:
[in]idThe id of the item to add
[in]itemThe item to add
Returns:
If the item could been added (no item with the same id was within the container before)

Definition at line 79 of file NamedObjectCont.h.

const std::vector<ODDistrict * >& NamedObjectCont< ODDistrict * >::buildAndGetStaticVector ( ) const [inline, inherited]

Definition at line 178 of file NamedObjectCont.h.

void NamedObjectCont< ODDistrict * >::clear ( ) [inline, inherited]

Removes all items from the container (deletes them, too)

Definition at line 122 of file NamedObjectCont.h.

bool NamedObjectCont< ODDistrict * >::erase ( const std::string &  id) [inline, inherited]

Removes the named item from the container.

If the named object exists, it is deleted, the key is removed from the map, and true is returned. If the id was not known, false is returned.

Parameters:
[in]idThe id of the item to delete
Returns:
Whether the object could be deleted (was within the map)

Definition at line 150 of file NamedObjectCont.h.

ODDistrict * NamedObjectCont< ODDistrict * >::get ( const std::string &  id) const [inline, inherited]

Retrieves an item.

Returns 0 when no item with the given id is stored within the container

Parameters:
[in]idThe id of the item to retrieve
Returns:
The item stored under the given id, or 0 if no such item exists

Definition at line 112 of file NamedObjectCont.h.

const IDMap& NamedObjectCont< ODDistrict * >::getMyMap ( ) const [inline, inherited]

Definition at line 223 of file NamedObjectCont.h.

std::string ODDistrictCont::getRandomSinkFromDistrict ( const std::string &  name) const throw (OutOfBoundsException, InvalidArgument)

Returns the id of a random sink from the named district.

At first, the named district is retrieved. If this fails, an InvalidArgument-exception is thrown. Otherwise, a sink (edge) is chosen randomly from this district using this district's getRandomSink-method which throws an OutOfBoundsException-exception if this district does not contain a sink.

Parameters:
[in]nameThe id of the district to get a random sink from
Returns:
The id of a randomly chosen sink
Exceptions:
InvalidArgumentIf the named district is not known
OutOfBoundsExceptionIf the named district has no sinks
See also:
ODDistrict::getRandomSink

Definition at line 64 of file ODDistrictCont.cpp.

References ODDistrict::getRandomSink().

Referenced by ODMatrix::computeDeparts().

std::string ODDistrictCont::getRandomSourceFromDistrict ( const std::string &  name) const throw (OutOfBoundsException, InvalidArgument)

Returns the id of a random source from the named district.

At first, the named district is retrieved. If this fails, an InvalidArgument-exception is thrown. Otherwise, a source (edge) is chosen randomly from this district using this district's getRandomSource-method which throws an OutOfBoundsException-exception if this district does not contain a source.

Parameters:
[in]nameThe id of the district to get a random source from
Returns:
The id of a randomly chosen source
Exceptions:
InvalidArgumentIf the named district is not known
OutOfBoundsExceptionIf the named district has no sources
See also:
ODDistrict::getRandomSource

Definition at line 54 of file ODDistrictCont.cpp.

References ODDistrict::getRandomSource().

Referenced by ODMatrix::computeDeparts().

std::vector<ODDistrict * > NamedObjectCont< ODDistrict * >::getTempVector ( ) const [inline, inherited]

Definition at line 198 of file NamedObjectCont.h.

void NamedObjectCont< ODDistrict * >::insertIDs ( std::vector< std::string > &  into) const [inline, inherited]

Definition at line 211 of file NamedObjectCont.h.

ODDistrictCont& ODDistrictCont::operator= ( const ODDistrictCont s) [private]

invalidated assignment operator

virtual bool NamedObjectCont< ODDistrict * >::remove ( const std::string &  id) [inline, virtual, inherited]

Removes an item.

Parameters:
[in]idThe id of the item to remove
Returns:
If the item could been removed (an item with the id was within the container before)

Definition at line 93 of file NamedObjectCont.h.

unsigned int NamedObjectCont< ODDistrict * >::size ( ) const [inline, inherited]

Returns the number of items within the container.

Returns:
The number of stored items

Definition at line 136 of file NamedObjectCont.h.


The documentation for this class was generated from the following files:
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Defines