SUMO - Simulation of Urban MObility

NamedObjectCont< T > Class Template Reference

A map of named object pointers. More...

#include <NamedObjectCont.h>

Public Member Functions

virtual bool add (const std::string &id, T item) throw ()
 Adds an item.
const std::vector< T > & buildAndGetStaticVector () const throw ()
void clear () throw ()
 Removes all items from the container (deletes them, too)
bool erase (const std::string &id) throw ()
 Removes the named item from the container.
T get (const std::string &id) const throw ()
 Retrieves an item.
const std::map< std::string, T > & getMyMap () const throw ()
std::vector< T > getTempVector () const throw ()
void insertIDs (std::vector< std::string > &into) const throw ()
 NamedObjectCont () throw ()
 Constructor.
virtual bool remove (const std::string &id) throw ()
 Removes an item.
unsigned int size () const throw ()
 Returns the number of items within the container.
virtual ~NamedObjectCont () throw ()
 Destructor.

Private Types

typedef std::map< std::string, T > IDMap
 Definition of the key to pointer map type.
typedef IDMap::iterator myContIt
 Definition of the container type iterator.
typedef std::vector< T > ObjectVector
 Definition objects vector.

Private Attributes

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

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


Member Typedef Documentation

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

Definition of the key to pointer map type.

Definition at line 225 of file NamedObjectCont.h.

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

Definition of the container type iterator.

Definition at line 228 of file NamedObjectCont.h.

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

Definition objects vector.

Definition at line 234 of file NamedObjectCont.h.


Constructor & Destructor Documentation

template<class T>
NamedObjectCont< T >::NamedObjectCont ( ) throw () [inline]

Constructor.

Definition at line 54 of file NamedObjectCont.h.

template<class T>
virtual NamedObjectCont< T >::~NamedObjectCont ( ) throw () [inline, virtual]

Destructor.

Definition at line 58 of file NamedObjectCont.h.


Member Function Documentation

template<class T>
virtual bool NamedObjectCont< T >::add ( const std::string &  id,
T  item 
) throw () [inline, virtual]

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)

Reimplemented in ROVehicleCont.

Definition at line 74 of file NamedObjectCont.h.

Referenced by MSDetectorControl::add(), MSNet::addBusStop(), ODDistrictHandler::closeDistrict(), and NLJunctionControlBuilder::closeJunction().

template<class T>
const std::vector<T>& NamedObjectCont< T >::buildAndGetStaticVector ( ) const throw () [inline]

Definition at line 173 of file NamedObjectCont.h.

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

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

Reimplemented in ROVehicleCont.

Definition at line 117 of file NamedObjectCont.h.

Referenced by RONet::~RONet().

template<class T>
bool NamedObjectCont< T >::erase ( const std::string &  id) throw () [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)

Reimplemented in ROVehicleCont.

Definition at line 145 of file NamedObjectCont.h.

template<class T>
T NamedObjectCont< T >::get ( const std::string &  id) const throw () [inline]

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

Referenced by MSNet::getBusStop(), RONet::getEdge(), GUINet::getJunctionPosition(), RONet::getNode(), RONet::getRouteDef(), TraCIServerAPI_MeMeDetector::processGet(), TraCIServerAPI_Junction::processGet(), TraCIServerAPI_InductionLoop::processGet(), and GUIShapeContainer::removePoI().

template<class T>
const std::map<std::string, T>& NamedObjectCont< T >::getMyMap ( ) const throw () [inline]
template<class T>
std::vector<T> NamedObjectCont< T >::getTempVector ( ) const throw () [inline]

Definition at line 193 of file NamedObjectCont.h.

template<class T>
void NamedObjectCont< T >::insertIDs ( std::vector< std::string > &  into) const throw () [inline]
template<class T>
virtual bool NamedObjectCont< T >::remove ( const std::string &  id) throw () [inline, virtual]

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

Referenced by GUIShapeContainer::removePoI().

template<class T>
unsigned int NamedObjectCont< T >::size ( ) const throw () [inline]

Returns the number of items within the container.

Returns:
The number of stored items

Definition at line 131 of file NamedObjectCont.h.

Referenced by RONet::furtherStored(), RONet::getEdgeNo(), GUINet::initGUIStructures(), main(), and RONet::saveAndRemoveRoutesUntil().


Field Documentation

template<class T>
ObjectVector NamedObjectCont< T >::myVector [mutable, private]

The documentation for this class was generated from the following file:
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Defines