SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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...
 
const std::vector< T > & buildAndGetStaticVector () const
 
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...
 
get (const std::string &id) const
 Retrieves an item. More...
 
const IDMapgetMyMap () const
 
std::vector< T > getTempVector () const
 
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 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 231 of file NamedObjectCont.h.

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

Definition objects vector.

Definition at line 237 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 64 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)

Definition at line 80 of file NamedObjectCont.h.

Referenced by ShapeContainer::add(), MSNet::addBusStop(), MSNet::addChargingStation(), MSNet::addContainerStop(), RONet::addEdge(), RONet::addFlow(), RONet::addNode(), GUIShapeContainer::addPOI(), GUIShapeContainer::addPolygon(), 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 179 of file NamedObjectCont.h.

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

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

Definition at line 123 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 151 of file NamedObjectCont.h.

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

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

Definition at line 199 of file NamedObjectCont.h.

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

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

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

Returns the number of items within the container.

Returns
The number of stored items

Definition at line 137 of file NamedObjectCont.h.

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

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: