SUMO - Simulation of Urban MObility

ODDistrictCont Class Reference

A container for districts. More...

#include <ODDistrictCont.h>

Inheritance diagram for ODDistrictCont:
NamedObjectCont< ODDistrict * >

Public Member Functions

virtual bool add (const std::string &id, ODDistrict *item) throw ()
 Adds an item.
const std::vector< ODDistrict * > & buildAndGetStaticVector () const throw ()
void clear () throw ()
 Removes all items from the container (deletes them, too)
bool erase (const std::string &id) throw ()
 Removes the named item from the container.
ODDistrict * get (const std::string &id) const throw ()
 Retrieves an item.
const std::map< std::string,
ODDistrict * > & 
getMyMap () const throw ()
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 throw ()
void insertIDs (std::vector< std::string > &into) const throw ()
 ODDistrictCont () throw ()
 Constructor.
virtual bool remove (const std::string &id) throw ()
 Removes an item.
unsigned int size () const throw ()
 Returns the number of items within the container.
 ~ODDistrictCont () throw ()
 Destructor.

Private Member Functions

 ODDistrictCont (const ODDistrictCont &s)
 invalidated copy constructor
ODDistrictCont & operator= (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 46 of file ODDistrictCont.h.


Constructor & Destructor Documentation

ODDistrictCont::ODDistrictCont ( ) throw ()

Constructor.

Definition at line 45 of file ODDistrictCont.cpp.

ODDistrictCont::~ODDistrictCont ( ) throw ()

Destructor.

Definition at line 48 of file ODDistrictCont.cpp.

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

invalidated copy constructor


Member Function Documentation

virtual bool NamedObjectCont< ODDistrict * >::add ( const std::string &  id,
ODDistrict *  item 
) throw () [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 74 of file NamedObjectCont.h.

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

Definition at line 173 of file NamedObjectCont.h.

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

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

Definition at line 117 of file NamedObjectCont.h.

bool NamedObjectCont< ODDistrict * >::erase ( const std::string &  id) throw () [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 145 of file NamedObjectCont.h.

ODDistrict * NamedObjectCont< ODDistrict * >::get ( const std::string &  id) const throw () [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 107 of file NamedObjectCont.h.

const std::map<std::string, ODDistrict * >& NamedObjectCont< ODDistrict * >::getMyMap ( ) const throw () [inline, inherited]

Definition at line 218 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 62 of file ODDistrictCont.cpp.

References ODDistrict::getRandomSink().

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 52 of file ODDistrictCont.cpp.

References ODDistrict::getRandomSource().

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

Definition at line 193 of file NamedObjectCont.h.

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

Definition at line 206 of file NamedObjectCont.h.

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

invalidated assignment operator

virtual bool NamedObjectCont< ODDistrict * >::remove ( const std::string &  id) throw () [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 88 of file NamedObjectCont.h.

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

Returns the number of items within the container.

Returns:
The number of stored items

Definition at line 131 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