Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
ODDistrictCont Class Reference

A container for districts. More...

#include <ODDistrictCont.h>

Inheritance diagram for ODDistrictCont:
[legend]
Collaboration diagram for ODDistrictCont:
[legend]

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.
ODDistrictget (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
ODDistrictContoperator= (const ODDistrictCont &s)
 invalidated assignment operator

Private Attributes

IDMap myMap
 The map from key to object.

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 39 of file ODDistrictCont.h.

Member Typedef Documentation

◆ IDMap

typedef std::map< std::string, ODDistrict * > NamedObjectCont< ODDistrict * >::IDMap
inherited

Definition of the key to pointer map type.

Definition at line 44 of file NamedObjectCont.h.

Constructor & Destructor Documentation

◆ ODDistrictCont() [1/2]

ODDistrictCont::ODDistrictCont ( )

Constructor.

Definition at line 41 of file ODDistrictCont.cpp.

Referenced by ODDistrictCont(), and operator=().

Here is the caller graph for this function:

◆ ~ODDistrictCont()

ODDistrictCont::~ODDistrictCont ( )

Destructor.

Definition at line 44 of file ODDistrictCont.cpp.

◆ ODDistrictCont() [2/2]

ODDistrictCont::ODDistrictCont ( const ODDistrictCont & s)
private

invalidated copy constructor

References ODDistrictCont().

Member Function Documentation

◆ add()

bool NamedObjectCont< ODDistrict * >::add ( const std::string & id,
ODDistrict * item )
inlineinherited

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 be added (no item with the same id was within the container before)

Definition at line 66 of file NamedObjectCont.h.

Referenced by ODDistrictCont::makeDistricts().

Here is the caller graph for this function:

◆ begin()

IDMap::const_iterator NamedObjectCont< ODDistrict * >::begin ( ) const
inlineinherited

Returns a reference to the begin iterator for the internal map.

Definition at line 146 of file NamedObjectCont.h.

◆ changeID()

bool NamedObjectCont< ODDistrict * >::changeID ( const std::string & oldId,
const std::string & newId )
inlineinherited

change ID of a stored object

Definition at line 132 of file NamedObjectCont.h.

◆ clear()

void NamedObjectCont< ODDistrict * >::clear ( )
inlineinherited

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

Definition at line 110 of file NamedObjectCont.h.

◆ end()

IDMap::const_iterator NamedObjectCont< ODDistrict * >::end ( ) const
inlineinherited

Returns a reference to the end iterator for the internal map.

Definition at line 151 of file NamedObjectCont.h.

◆ get()

ODDistrict * NamedObjectCont< ODDistrict * >::get ( const std::string & id) const
inlineinherited

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 100 of file NamedObjectCont.h.

Referenced by ODDistrictCont::getRandomSinkFromDistrict(), and ODDistrictCont::getRandomSourceFromDistrict().

Here is the caller graph for this function:

◆ getRandomSinkFromDistrict()

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.

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

References NamedObjectCont< ODDistrict * >::get(), ODDistrict::getRandomSink(), and TLF.

◆ getRandomSourceFromDistrict()

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.

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

References NamedObjectCont< ODDistrict * >::get(), ODDistrict::getRandomSource(), and TLF.

◆ insertIDs()

void NamedObjectCont< ODDistrict * >::insertIDs ( std::vector< std::string > & into) const
inlineinherited

Definition at line 125 of file NamedObjectCont.h.

◆ loadDistricts()

void ODDistrictCont::loadDistricts ( std::vector< std::string > files)

load districts from files

Definition at line 80 of file ODDistrictCont.cpp.

References FileHelpers::isReadable(), PROGRESS_BEGIN_MESSAGE, PROGRESS_DONE_MESSAGE, PROGRESS_FAILED_MESSAGE, XMLSubSys::runParser(), and TLF.

Referenced by main().

Here is the caller graph for this function:

◆ makeDistricts()

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

References NamedObjectCont< ODDistrict * >::add(), ODDistrict::addSink(), ODDistrict::addSource(), and Named::getID().

Referenced by main().

Here is the caller graph for this function:

◆ operator=()

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

invalidated assignment operator

References ODDistrictCont().

◆ remove()

bool NamedObjectCont< ODDistrict * >::remove ( const std::string & id,
const bool del = true )
inlineinherited

Removes an item.

Parameters
[in]idThe id of the item to remove
[in]deldelete item after removing of container
Returns
If the item could be removed (an item with the id was within the container before)

Definition at line 80 of file NamedObjectCont.h.

◆ size()

int NamedObjectCont< ODDistrict * >::size ( ) const
inlineinherited

Returns the number of stored items within the container.

Definition at line 118 of file NamedObjectCont.h.

Field Documentation

◆ myMap

IDMap NamedObjectCont< ODDistrict * >::myMap
privateinherited

The map from key to object.

Definition at line 158 of file NamedObjectCont.h.


The documentation for this class was generated from the following files: