SUMO - Simulation of Urban MObility
|
A container for districts. More...
#include <ODDistrictCont.h>
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. | |
ODDistrict * | get (const std::string &id) const |
Retrieves an item. | |
const IDMap & | getMyMap () 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 | |
ODDistrictCont & | operator= (const ODDistrictCont &s) |
invalidated assignment operator |
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.
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.
Definition at line 47 of file ODDistrictCont.cpp.
Destructor.
Definition at line 50 of file ODDistrictCont.cpp.
ODDistrictCont::ODDistrictCont | ( | const ODDistrictCont & | s | ) | [private] |
invalidated copy constructor
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.
[in] | id | The id of the item to add |
[in] | item | The item to add |
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.
[in] | id | The id of the item to delete |
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
[in] | id | The id of the item to retrieve |
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.
[in] | name | The id of the district to get a random sink from |
InvalidArgument | If the named district is not known |
OutOfBoundsException | If the named district has no sinks |
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.
[in] | name | The id of the district to get a random source from |
InvalidArgument | If the named district is not known |
OutOfBoundsException | If the named district has no sources |
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.
[in] | id | The id of the item to remove |
Definition at line 93 of file NamedObjectCont.h.
unsigned int NamedObjectCont< ODDistrict * >::size | ( | ) | const [inline, inherited] |
Returns the number of items within the container.
Definition at line 136 of file NamedObjectCont.h.