SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
ROVehicleCont Class Reference

A container for vehicles sorted by their departure time. More...

#include <ROVehicleCont.h>

Inheritance diagram for ROVehicleCont:
NamedObjectCont< ROVehicle * >

Public Types

typedef std::map< std::string,
ROVehicle * > 
IDMap
 Definition of the key to pointer map type. More...
 

Public Member Functions

virtual bool add (const std::string &id, ROVehicle *item)
 Adds a vehicle to the container. More...
 
const std::vector< ROVehicle * > & buildAndGetStaticVector () const
 
void clear ()
 Deletes all vehicles stored; clears the lists. More...
 
bool erase (const std::string &id)
 Tries to remove (and delete) the named vehicle. More...
 
ROVehicleget (const std::string &id) const
 Retrieves an item. More...
 
const IDMapgetMyMap () const
 
std::vector< ROVehicle * > getTempVector () const
 
const ROVehiclegetTopVehicle () const
 Returns the vehicle that departs most early. More...
 
void insertIDs (std::vector< std::string > &into) const
 
virtual bool remove (const std::string &id)
 Removes an item. More...
 
 ROVehicleCont ()
 Constructor. More...
 
unsigned int size () const
 Returns the number of items within the container. More...
 
 ~ROVehicleCont ()
 Destructor. More...
 

Private Member Functions

ROVehicleContoperator= (const ROVehicleCont &src)
 Invalidated assignment operator. More...
 
void rebuildSorted ()
 Rebuild the internal, sorted list. More...
 
 ROVehicleCont (const ROVehicleCont &src)
 Invalidated copy constructor. More...
 

Private Attributes

std::priority_queue< ROVehicle
*, std::vector< ROVehicle * >
, ROVehicleByDepartureComperator
mySorted
 The sorted vehicle list. More...
 

Detailed Description

A container for vehicles sorted by their departure time.

A map of vehicle-ids to the vehicles themselves. Besides the functionality implemented in NamedObjectCont, this class stores vehicles sorted by their departure time.

Definition at line 54 of file ROVehicleCont.h.

Member Typedef Documentation

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

Definition of the key to pointer map type.

Definition at line 57 of file NamedObjectCont.h.

Constructor & Destructor Documentation

ROVehicleCont::ROVehicleCont ( )

Constructor.

Definition at line 48 of file ROVehicleCont.cpp.

ROVehicleCont::~ROVehicleCont ( )

Destructor.

Definition at line 51 of file ROVehicleCont.cpp.

ROVehicleCont::ROVehicleCont ( const ROVehicleCont src)
private

Invalidated copy constructor.

Member Function Documentation

bool ROVehicleCont::add ( const std::string &  id,
ROVehicle item 
)
virtual

Adds a vehicle to the container.

Tries to add the vehicle to the container using NamedObjectCont::add. If this succeeds, the vehicle is also added to the internal sorted list of vehicles.

Returns the value from NamedObjectCont::add.

Parameters
[in]idThe id of the vehicle to add
[in]itemThe vehicle to add
Returns
Whether the vehicle could be added
See also
NamedObjectCont::add

Reimplemented from NamedObjectCont< ROVehicle * >.

Definition at line 64 of file ROVehicleCont.cpp.

References mySorted.

Referenced by RONet::addVehicle().

const std::vector<ROVehicle * >& NamedObjectCont< ROVehicle * >::buildAndGetStaticVector ( ) const
inlineinherited

Definition at line 179 of file NamedObjectCont.h.

void ROVehicleCont::clear ( )

Deletes all vehicles stored; clears the lists.

Calls NamedObjectCont::clear and replaces the internal, sorted list by an empty one.

See also
NamedObjectCont::clear

Definition at line 74 of file ROVehicleCont.cpp.

References NamedObjectCont< T >::clear(), and mySorted.

Referenced by RONet::~RONet().

bool ROVehicleCont::erase ( const std::string &  id)

Tries to remove (and delete) the named vehicle.

Calls NamedObjectCont::erase. If this succeeds, the vehicle is removed from the internal sorted list. This method takes care whether the vehicle to remove is the top-most one (the one with the earliest depart time). If not, the internal list is rebuild.

Parameters
[in]idThe id of the vehicle to remove
Returns
Whether the vehicle could be removed
See also
NamedObjectCont::erase

Definition at line 81 of file ROVehicleCont.cpp.

References ROVehicle::getID(), getTopVehicle(), mySorted, and rebuildSorted().

Referenced by RONet::saveAndRemoveRoutesUntil().

ROVehicle * NamedObjectCont< ROVehicle * >::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 113 of file NamedObjectCont.h.

const IDMap& NamedObjectCont< ROVehicle * >::getMyMap ( ) const
inlineinherited

Definition at line 224 of file NamedObjectCont.h.

Referenced by rebuildSorted().

std::vector<ROVehicle * > NamedObjectCont< ROVehicle * >::getTempVector ( ) const
inlineinherited

Definition at line 199 of file NamedObjectCont.h.

const ROVehicle * ROVehicleCont::getTopVehicle ( ) const

Returns the vehicle that departs most early.

Returns the first vehicle from the internal list of sorted vehicles or 0 if this list is empty.

Returns
The vehicle that departs most early

Definition at line 55 of file ROVehicleCont.cpp.

References mySorted, and NamedObjectCont< ROVehicle * >::size().

Referenced by erase(), and RONet::saveAndRemoveRoutesUntil().

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

Definition at line 212 of file NamedObjectCont.h.

ROVehicleCont& ROVehicleCont::operator= ( const ROVehicleCont src)
private

Invalidated assignment operator.

void ROVehicleCont::rebuildSorted ( )
private

Rebuild the internal, sorted list.

Rebuilds the internal, sorted list by clearing it, first, and then adding all vehicles stored.

See also
NamedObjectCont::clear

Definition at line 97 of file ROVehicleCont.cpp.

References NamedObjectCont< ROVehicle * >::getMyMap(), and mySorted.

Referenced by erase().

virtual bool NamedObjectCont< ROVehicle * >::remove ( const std::string &  id)
inlinevirtualinherited

Removes an item.

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

Definition at line 94 of file NamedObjectCont.h.

unsigned int NamedObjectCont< ROVehicle * >::size ( ) const
inlineinherited

Returns the number of items within the container.

Returns
The number of stored items

Definition at line 137 of file NamedObjectCont.h.

Referenced by getTopVehicle().

Field Documentation

std::priority_queue<ROVehicle*, std::vector<ROVehicle*>, ROVehicleByDepartureComperator> ROVehicleCont::mySorted
mutableprivate

The sorted vehicle list.

Definition at line 127 of file ROVehicleCont.h.

Referenced by add(), clear(), erase(), getTopVehicle(), and rebuildSorted().


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