SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
NamedObjectCont< T > Class Template Reference

A map of named object pointers. More...

#include <NamedObjectCont.h>

Public Types

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

Public Member Functions

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

Private Types

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

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

Definition of the container type iterator.

Definition at line 230 of file NamedObjectCont.h.

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

Definition objects vector.

Definition at line 236 of file NamedObjectCont.h.

Constructor & Destructor Documentation

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

Constructor.

Definition at line 59 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,
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)

Reimplemented in ROVehicleCont.

Definition at line 79 of file NamedObjectCont.h.

Referenced by MSDetectorControl::add(), MSNet::addBusStop(), RONet::addEdge(), RONet::addNode(), RONet::addRouteDef(), RONet::addVehicleType(), ODDistrictHandler::closeDistrict(), NLJunctionControlBuilder::closeJunction(), and RONet::RONet().

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

Definition at line 178 of file NamedObjectCont.h.

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

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

Reimplemented in ROVehicleCont.

Definition at line 122 of file NamedObjectCont.h.

Referenced by 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)

Reimplemented in ROVehicleCont.

Definition at line 150 of file NamedObjectCont.h.

template<class T>
T NamedObjectCont< T >::get ( const std::string &  id) const
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 112 of file NamedObjectCont.h.

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

template<class T>
std::vector<T> NamedObjectCont< T >::getTempVector ( ) const
inline

Definition at line 198 of file NamedObjectCont.h.

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
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::addVehicleType(), and GUIShapeContainer::removePoI().

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

Returns the number of items within the container.

Returns
The number of stored items

Definition at line 136 of file NamedObjectCont.h.

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

Field Documentation

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

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