Eclipse 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 | |
bool | add (const std::string &id, ODDistrict * item) |
Adds an item. | |
IDMap::const_iterator | begin () const |
Returns a reference to the begin iterator for the internal map. | |
bool | changeID (const std::string &oldId, const std::string &newId) |
change ID of a stored object | |
void | clear () |
Removes all items from the container (deletes them, too) | |
IDMap::const_iterator | end () const |
Returns a reference to the end iterator for the internal map. | |
ODDistrict * | get (const std::string &id) const |
Retrieves an item. | |
std::string | getRandomSinkFromDistrict (const std::string &name) const |
Returns the id of a random sink from the named district. | |
std::string | getRandomSourceFromDistrict (const std::string &name) const |
Returns the id of a random source from the named district. | |
void | insertIDs (std::vector< std::string > &into) const |
void | loadDistricts (std::vector< std::string > files) |
load districts from files | |
void | makeDistricts (const std::map< std::string, std::pair< std::vector< std::string >, std::vector< std::string > > > &districts) |
create districts from description | |
ODDistrictCont () | |
Constructor. | |
bool | remove (const std::string &id, const bool del=true) |
Removes an item. | |
int | size () const |
Returns the number of stored items within the container. | |
~ODDistrictCont () | |
Destructor. | |
Private Member Functions | |
ODDistrictCont (const ODDistrictCont &s) | |
invalidated copy constructor | |
ODDistrictCont & | operator= (const ODDistrictCont &s) |
invalidated assignment operator | |
Private Attributes | |
IDMap | myMap |
The map from key to object. | |
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 39 of file ODDistrictCont.h.
|
inherited |
Definition of the key to pointer map type.
Definition at line 44 of file NamedObjectCont.h.
ODDistrictCont::ODDistrictCont | ( | ) |
Constructor.
Definition at line 41 of file ODDistrictCont.cpp.
ODDistrictCont::~ODDistrictCont | ( | ) |
Destructor.
Definition at line 44 of file ODDistrictCont.cpp.
|
private |
invalidated copy constructor
|
inlineinherited |
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 66 of file NamedObjectCont.h.
|
inlineinherited |
Returns a reference to the begin iterator for the internal map.
Definition at line 146 of file NamedObjectCont.h.
|
inlineinherited |
change ID of a stored object
Definition at line 132 of file NamedObjectCont.h.
|
inlineinherited |
Removes all items from the container (deletes them, too)
Definition at line 110 of file NamedObjectCont.h.
|
inlineinherited |
Returns a reference to the end iterator for the internal map.
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 100 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 58 of file ODDistrictCont.cpp.
References NamedObjectCont< ODDistrict * >::get(), and 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 48 of file ODDistrictCont.cpp.
References NamedObjectCont< ODDistrict * >::get(), and ODDistrict::getRandomSource().
Referenced by ODMatrix::computeDeparts().
|
inlineinherited |
Definition at line 125 of file NamedObjectCont.h.
void ODDistrictCont::loadDistricts | ( | std::vector< std::string > | files | ) |
load districts from files
Definition at line 68 of file ODDistrictCont.cpp.
References FileHelpers::isReadable(), PROGRESS_BEGIN_MESSAGE, PROGRESS_DONE_MESSAGE, PROGRESS_FAILED_MESSAGE, XMLSubSys::runParser(), and TLF.
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 87 of file ODDistrictCont.cpp.
References NamedObjectCont< ODDistrict * >::add(), ODDistrict::addSink(), ODDistrict::addSource(), and Named::getID().
Referenced by main().
|
private |
invalidated assignment operator
|
inlineinherited |
Removes an item.
[in] | id | The id of the item to remove |
[in] | del | delete item after removing of container |
Definition at line 80 of file NamedObjectCont.h.
|
inlineinherited |
Returns the number of stored items within the container.
Definition at line 118 of file NamedObjectCont.h.
|
privateinherited |
The map from key to object.
Definition at line 158 of file NamedObjectCont.h.