SUMO - Simulation of Urban MObility
NamedObjectCont< T > Class Template Reference

A map of named object pointers. More...

#include <NamedObjectCont.h>

Collaboration diagram for NamedObjectCont< T >:
Collaboration graph

Public Types

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

Public Member Functions

virtual bool add (const std::string &id, T item)
 Adds an item. More...
 
bool changeID (const std::string &oldId, const std::string &newId)
 change ID of a stored object More...
 
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...
 
T get (const std::string &id) const
 Retrieves an item. More...
 
const IDMap & getMyMap () const
 Returns a reference to the internal map. More...
 
void insertIDs (std::vector< std::string > &into) const
 
 NamedObjectCont ()
 Constructor. More...
 
virtual bool remove (const std::string &id)
 Removes an item. More...
 
int size () const
 Returns the number of stored items within the container. More...
 
virtual ~NamedObjectCont ()
 Destructor. More...
 

Private Types

typedef IDMap::iterator myContIt
 Definition of the container type iterator. More...
 
typedef std::vector< T > ObjectVector
 Definition objects vector. More...
 

Private Attributes

bool myHaveChanged
 Information whether the vector is out of sync with the map. More...
 
IDMap myMap
 The map from key to object. More...
 
ObjectVector myVector
 The stored vector of all known items. More...
 

Detailed Description

template<class T>
class NamedObjectCont< T >

A map of named object pointers.

An associative storage (map) for objects (pointers to them to be exact), which do have a name. In order to get the stored objects as a list, each insertion/deletion sets the internal state value "myHaveChanged" to true, indicating the list must be rebuild.

Definition at line 54 of file NamedObjectCont.h.

Member Typedef Documentation

template<class T>
typedef std::map< std::string, T > NamedObjectCont< T >::IDMap

Definition of the key to pointer map type.

Definition at line 57 of file NamedObjectCont.h.

template<class T>
typedef IDMap::iterator NamedObjectCont< T >::myContIt
private

Definition of the container type iterator.

Definition at line 196 of file NamedObjectCont.h.

template<class T>
typedef std::vector<T> NamedObjectCont< T >::ObjectVector
private

Definition objects vector.

Definition at line 202 of file NamedObjectCont.h.

Constructor & Destructor Documentation

template<class T>
NamedObjectCont< T >::NamedObjectCont ( )
inline

Constructor.

Definition at line 60 of file NamedObjectCont.h.

template<class T>
virtual NamedObjectCont< T >::~NamedObjectCont ( )
inlinevirtual

Destructor.

Definition at line 63 of file NamedObjectCont.h.

Member Function Documentation

template<class T>
virtual bool NamedObjectCont< T >::add ( const std::string &  id,
T  item 
)
inlinevirtual

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

Definition at line 79 of file NamedObjectCont.h.

Referenced by ShapeContainer::add(), MSNet::addBusStop(), MSNet::addChargingStation(), MSNet::addContainerStop(), RONet::addEdge(), RONet::addFlow(), RONet::addNode(), MSNet::addParkingArea(), GUIShapeContainer::addPOI(), GNENet::addPOI(), GUIShapeContainer::addPolygon(), GNENet::addPolygon(), RONet::addRouteDef(), RONet::addVehicleType(), ODDistrictHandler::closeDistrict(), NLJunctionControlBuilder::closeJunction(), and RONet::RONet().

template<class T>
bool NamedObjectCont< T >::changeID ( const std::string &  oldId,
const std::string &  newId 
)
inline

change ID of a stored object

Definition at line 175 of file NamedObjectCont.h.

Referenced by GNENet::changePOIID(), and GNENet::changePolygonID().

template<class T>
void NamedObjectCont< T >::clear ( )
inline

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

Definition at line 122 of file NamedObjectCont.h.

Referenced by PCPolyContainer::~PCPolyContainer(), and RONet::~RONet().

template<class T>
bool NamedObjectCont< T >::erase ( const std::string &  id)
inline

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.

Parameters
[in]idThe id of the item to delete
Returns
Whether the object could be deleted (was within the map)

Definition at line 145 of file NamedObjectCont.h.

Referenced by RONet::checkFlows(), RONet::saveAndRemoveRoutesUntil(), and RONet::~RONet().

template<class T>
T NamedObjectCont< T >::get ( const std::string &  id) const
inline
template<class T>
void NamedObjectCont< T >::insertIDs ( std::vector< std::string > &  into) const
inline
template<class T>
virtual bool NamedObjectCont< T >::remove ( const std::string &  id)
inlinevirtual

Removes an item.

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

Definition at line 93 of file NamedObjectCont.h.

Referenced by RONet::checkVType(), ShapeContainer::removePOI(), GUIShapeContainer::removePOI(), GNENet::removePOI(), ShapeContainer::removePolygon(), GUIShapeContainer::removePolygon(), and GNENet::removePolygon().

template<class T>
int NamedObjectCont< T >::size ( ) const
inline

Field Documentation

template<class T>
bool NamedObjectCont< T >::myHaveChanged
mutableprivate

Information whether the vector is out of sync with the map.

Definition at line 208 of file NamedObjectCont.h.

Referenced by NamedObjectCont< RONode * >::add(), NamedObjectCont< RONode * >::clear(), NamedObjectCont< RONode * >::erase(), and NamedObjectCont< RONode * >::remove().

template<class T>
ObjectVector NamedObjectCont< T >::myVector
mutableprivate

The stored vector of all known items.

Definition at line 205 of file NamedObjectCont.h.

Referenced by NamedObjectCont< RONode * >::clear(), and NamedObjectCont< RONode * >::erase().


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