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. More... | |
Public Member Functions | |
virtual bool | add (const std::string &id, ODDistrict *item) |
Adds an item. More... | |
const std::vector< ODDistrict * > & | buildAndGetStaticVector () const |
void | clear () |
Removes all items from the container (deletes them, too) More... | |
bool | erase (const std::string &id) |
Removes the named item from the container. More... | |
ODDistrict * | get (const std::string &id) const |
Retrieves an item. More... | |
const IDMap & | getMyMap () const |
std::string | getRandomSinkFromDistrict (const std::string &name) const |
Returns the id of a random sink from the named district. More... | |
std::string | getRandomSourceFromDistrict (const std::string &name) const |
Returns the id of a random source from the named district. More... | |
std::vector< ODDistrict * > | getTempVector () const |
void | insertIDs (std::vector< std::string > &into) const |
void | loadDistricts (std::string districtfile) |
ODDistrictCont () | |
Constructor. More... | |
virtual bool | remove (const std::string &id) |
Removes an item. More... | |
unsigned int | size () const |
Returns the number of items within the container. More... | |
~ODDistrictCont () | |
Destructor. More... | |
Private Member Functions | |
ODDistrictCont (const ODDistrictCont &s) | |
invalidated copy constructor More... | |
ODDistrictCont & | operator= (const ODDistrictCont &s) |
invalidated assignment operator More... | |
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.
|
inherited |
Definition of the key to pointer map type.
Definition at line 56 of file NamedObjectCont.h.
ODDistrictCont::ODDistrictCont | ( | ) |
Constructor.
Definition at line 53 of file ODDistrictCont.cpp.
ODDistrictCont::~ODDistrictCont | ( | ) |
Destructor.
Definition at line 56 of file ODDistrictCont.cpp.
|
private |
invalidated copy constructor
|
inlinevirtualinherited |
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.
|
inlineinherited |
Definition at line 178 of file NamedObjectCont.h.
|
inlineinherited |
Removes all items from the container (deletes them, too)
Definition at line 122 of file NamedObjectCont.h.
|
inlineinherited |
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.
|
inlineinherited |
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.
|
inlineinherited |
Definition at line 223 of file NamedObjectCont.h.
std::string ODDistrictCont::getRandomSinkFromDistrict | ( | const std::string & | name | ) | const |
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 70 of file ODDistrictCont.cpp.
References ODDistrict::getRandomSink().
Referenced by ODMatrix::computeDeparts().
std::string ODDistrictCont::getRandomSourceFromDistrict | ( | const std::string & | name | ) | const |
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 60 of file ODDistrictCont.cpp.
References ODDistrict::getRandomSource().
Referenced by ODMatrix::computeDeparts().
|
inlineinherited |
Definition at line 198 of file NamedObjectCont.h.
|
inlineinherited |
Definition at line 211 of file NamedObjectCont.h.
void ODDistrictCont::loadDistricts | ( | std::string | districtfile | ) |
Definition at line 79 of file ODDistrictCont.cpp.
References FileHelpers::exists(), PROGRESS_BEGIN_MESSAGE, PROGRESS_DONE_MESSAGE, PROGRESS_FAILED_MESSAGE, and XMLSubSys::runParser().
Referenced by main().
|
private |
invalidated assignment operator
|
inlinevirtualinherited |
Removes an item.
[in] | id | The id of the item to remove |
Definition at line 93 of file NamedObjectCont.h.
|
inlineinherited |
Returns the number of items within the container.
Definition at line 136 of file NamedObjectCont.h.