![]() |
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::vector< std::string > files) |
load districts from files More... | |
void | makeDistricts (const std::map< std::string, std::pair< std::vector< std::string >, std::vector< std::string > > > &districts) |
create districts from description More... | |
ODDistrictCont () | |
Constructor. More... | |
virtual bool | remove (const std::string &id) |
Removes an item. More... | |
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 49 of file ODDistrictCont.h.
|
inherited |
Definition of the key to pointer map type.
Definition at line 57 of file NamedObjectCont.h.
ODDistrictCont::ODDistrictCont | ( | ) |
Constructor.
Definition at line 50 of file ODDistrictCont.cpp.
ODDistrictCont::~ODDistrictCont | ( | ) |
Destructor.
Definition at line 53 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 80 of file NamedObjectCont.h.
Referenced by makeDistricts().
|
inlineinherited |
Definition at line 179 of file NamedObjectCont.h.
|
inlineinherited |
Removes all items from the container (deletes them, too)
Definition at line 123 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 151 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 113 of file NamedObjectCont.h.
|
inlineinherited |
Definition at line 224 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 67 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 57 of file ODDistrictCont.cpp.
References ODDistrict::getRandomSource().
Referenced by ODMatrix::computeDeparts().
|
inlineinherited |
Definition at line 199 of file NamedObjectCont.h.
|
inlineinherited |
Definition at line 212 of file NamedObjectCont.h.
void ODDistrictCont::loadDistricts | ( | std::vector< std::string > | files | ) |
load districts from files
Definition at line 77 of file ODDistrictCont.cpp.
References FileHelpers::isReadable(), PROGRESS_BEGIN_MESSAGE, PROGRESS_DONE_MESSAGE, PROGRESS_FAILED_MESSAGE, and XMLSubSys::runParser().
Referenced by main().
void ODDistrictCont::makeDistricts | ( | const std::map< std::string, std::pair< std::vector< std::string >, std::vector< std::string > > > & | districts | ) |
create districts from description
Definition at line 96 of file ODDistrictCont.cpp.
References NamedObjectCont< ODDistrict *>::add(), ODDistrict::addSink(), ODDistrict::addSource(), and Named::getID().
Referenced by main().
|
private |
invalidated assignment operator
|
inlinevirtualinherited |
Removes an item.
[in] | id | The id of the item to remove |
Definition at line 94 of file NamedObjectCont.h.
|
inlineinherited |
Returns the number of items within the container.
Definition at line 137 of file NamedObjectCont.h.