ERC CISST - cisst software

cmnNamedMap< _elementType > Class Template Reference
[Common Tools]

#include <cmnNamedMap.h>

Collaboration diagram for cmnNamedMap< _elementType >:

Collaboration graph
[legend]
List of all members.

Detailed Description

template<class _elementType>
class cmnNamedMap< _elementType >

cmnNamedMap provides a map (lookup table), where the key is a string and the value (item) is specified by the template parameter. The map actually contains a pointer to the value. In cisstMultiTask, this class is used to maintain the lists of interfaces per task/device, as well as the lists of commands per interface.

The cmnNamedMap class is a small "wrapper" around std::map that was created to factorize some code that would otherwise be duplicated.

Definition at line 55 of file cmnNamedMap.h.

Public Types

Public Member Functions

Protected Member Functions

Protected Attributes


Member Typedef Documentation

template<class _elementType>
typedef std::map<std::string, _elementType *> cmnNamedMap< _elementType >::MapType

Type of the actual map

Definition at line 59 of file cmnNamedMap.h.

template<class _elementType>
typedef void(_elementType::*) cmnNamedMap< _elementType >::VoidMethodPointer(void)

Type of void method in class _elementType

Definition at line 175 of file cmnNamedMap.h.


Constructor & Destructor Documentation

template<class _elementType>
cmnNamedMap< _elementType >::cmnNamedMap ( bool  takesOwnership = false  )  [inline]

Default constructor, initialize the internal map and set the map name to "undefined"

Definition at line 102 of file cmnNamedMap.h.

template<class _elementType>
cmnNamedMap< _elementType >::cmnNamedMap ( const char *  mapName,
bool  takesOwnership = false 
) [inline]

Constructor with a map name. The map name is useful for all human readable log messages as well as string streaming (e.g. std::cout)

Definition at line 112 of file cmnNamedMap.h.

template<class _elementType>
cmnNamedMap< _elementType >::cmnNamedMap ( const std::string &  mapName,
const cmnGenericObject owner,
bool  takesOwnership = false 
) [inline]

Constructor with a map name and a pointer a cmnGenericObject (in most cases, use "*this"). The map name is useful for all human readable log messages as well as string streaming (e.g. std::cout). The cmnGenericObject level of detail will be used to filter the messages.

Definition at line 131 of file cmnNamedMap.h.

template<class _elementType>
cmnNamedMap< _elementType >::~cmnNamedMap (  )  [inline]

Destructor. Relies on std::map destructor.

Definition at line 140 of file cmnNamedMap.h.


Member Function Documentation

template<class _elementType>
const cmnClassServicesBase* cmnNamedMap< _elementType >::Services ( void   )  const [inline, protected]

Method use to emulate the cmnGenericObject interface used by CMN_LOG_CLASS macros.

Definition at line 90 of file cmnNamedMap.h.

References cmnNamedMap< _elementType >::OwnerServices.

template<class _elementType>
cmnLogger::StreamBufType* cmnNamedMap< _elementType >::GetLogMultiplexer ( void   )  const [inline, protected]

Method use to emulate the cmnGenericObject interface used by CMN_LOG_CLASS macros.

Definition at line 94 of file cmnNamedMap.h.

References cmnLogger::GetMultiplexer().

template<class _elementType>
void cmnNamedMap< _elementType >::SetOwner ( const cmnGenericObject owner  )  [inline]

Set the map owner

Definition at line 145 of file cmnNamedMap.h.

References cmnNamedMap< _elementType >::OwnerServices, and cmnGenericObject::Services().

template<class _elementType>
bool cmnNamedMap< _elementType >::AddItem ( const std::string &  name,
_elementType *  item,
cmnLogLoD  lod = CMN_LOG_LOD_RUN_ERROR 
)

Add an item to the internal map. The log level of details is used to determine the lod of a message if the item can not be added.

Definition at line 232 of file cmnNamedMap.h.

References CMN_LOG, CMN_LOG_CLASS, cmnNamedMap< _elementType >::Map, and cmnNamedMap< _elementType >::MapName.

Referenced by mtsInterfaceRequired::AddEventHandlerWrite(), and mtsInterfaceRequired::AddEventHandlerWriteGeneric().

template<class _elementType>
_elementType * cmnNamedMap< _elementType >::GetItem ( const std::string &  name,
cmnLogLoD  lod = CMN_LOG_LOD_RUN_WARNING 
) const

Get an item by name

Definition at line 251 of file cmnNamedMap.h.

References CMN_LOG, CMN_LOG_CLASS, cmnNamedMap< _elementType >::Map, and cmnNamedMap< _elementType >::MapName.

Referenced by mtsInterfaceRequired::AddEventHandlerWrite(), and mtsInterfaceRequired::AddEventHandlerWriteGeneric().

template<class _elementType>
bool cmnNamedMap< _elementType >::FindItem ( const std::string &  itemName  )  const

Find an item by name

Definition at line 266 of file cmnNamedMap.h.

References cmnNamedMap< _elementType >::Map.

template<class _elementType>
bool cmnNamedMap< _elementType >::RemoveItem ( const std::string &  name,
cmnLogLoD  lod = CMN_LOG_LOD_RUN_ERROR 
)

Remove an item from the internal map. The log level of details is used to determine the lod of a message if the item can not be removed.

Definition at line 273 of file cmnNamedMap.h.

References CMN_LOG, CMN_LOG_CLASS, cmnNamedMap< _elementType >::Map, and cmnNamedMap< _elementType >::MapName.

template<class _elementType>
void cmnNamedMap< _elementType >::GetNames ( std::vector< std::string > &  placeHolder  )  const

List of names used, i.e. list of keys in the map

Definition at line 295 of file cmnNamedMap.h.

References cmnNamedMap< _elementType >::end(), and cmnNamedMap< _elementType >::Map.

template<class _elementType>
std::vector< std::string > cmnNamedMap< _elementType >::GetNames ( void   )  const

List of names used, i.e. list of keys in the map

Definition at line 308 of file cmnNamedMap.h.

template<class _elementType>
void cmnNamedMap< _elementType >::ForEachVoid ( VoidMethodPointer  method  ) 

Execute a method on all objects contained in the map

Definition at line 316 of file cmnNamedMap.h.

References cmnNamedMap< _elementType >::end(), and cmnNamedMap< _elementType >::Map.

template<class _elementType>
const MapType& cmnNamedMap< _elementType >::GetMap ( void   )  const [inline]

Reference on the internal map

Definition at line 182 of file cmnNamedMap.h.

References cmnNamedMap< _elementType >::Map.

template<class _elementType>
MapType& cmnNamedMap< _elementType >::GetMap ( void   )  [inline]

Reference on the internal map

Definition at line 185 of file cmnNamedMap.h.

References cmnNamedMap< _elementType >::Map.

template<class _elementType>
void cmnNamedMap< _elementType >::ToStream ( std::ostream &  outputStream  )  const

Print the content of the map as well as its name

Definition at line 327 of file cmnNamedMap.h.

References cmnNamedMap< _elementType >::end(), cmnNamedMap< _elementType >::Map, and cmnNamedMap< _elementType >::MapName.

template<class _elementType>
void cmnNamedMap< _elementType >::DeleteAll ( void   ) 

Delete all content while preserving keys, i.e. the map contains pairs of names and null pointers.

Definition at line 342 of file cmnNamedMap.h.

References cmnNamedMap< _elementType >::end(), and cmnNamedMap< _elementType >::Map.

template<class _elementType>
size_type cmnNamedMap< _elementType >::size ( void   )  const [inline]

STL compatible size

Definition at line 200 of file cmnNamedMap.h.

References cmnNamedMap< _elementType >::Map.


Member Data Documentation

template<class _elementType>
MapType cmnNamedMap< _elementType >::Map [protected]

Map data member, uses an std::map

Definition at line 70 of file cmnNamedMap.h.

Referenced by cmnNamedMap< _elementType >::AddItem(), cmnNamedMap< _elementType >::begin(), cmnNamedMap< _elementType >::clear(), cmnNamedMap< _elementType >::DeleteAll(), cmnNamedMap< _elementType >::empty(), cmnNamedMap< _elementType >::end(), cmnNamedMap< _elementType >::FindItem(), cmnNamedMap< _elementType >::ForEachVoid(), cmnNamedMap< _elementType >::GetItem(), cmnNamedMap< _elementType >::GetMap(), cmnNamedMap< _elementType >::GetNames(), cmnNamedMap< _elementType >::RemoveItem(), cmnNamedMap< _elementType >::size(), and cmnNamedMap< _elementType >::ToStream().

template<class _elementType>
bool cmnNamedMap< _elementType >::TakesOwnership [protected]

Flag set to determine if the map "takes ownership" of data. If the map takes ownership it will perform the required `delete` on its data when necessary. The default is false, i.e. the map destructor will not attempt to delete its objects.

Definition at line 76 of file cmnNamedMap.h.

template<class _elementType>
std::string cmnNamedMap< _elementType >::MapName [protected]

Name of the map, mostly for logging purposes.

Definition at line 79 of file cmnNamedMap.h.

Referenced by cmnNamedMap< _elementType >::AddItem(), cmnNamedMap< _elementType >::GetItem(), cmnNamedMap< _elementType >::RemoveItem(), and cmnNamedMap< _elementType >::ToStream().

template<class _elementType>
const cmnClassServicesBase* cmnNamedMap< _elementType >::OwnerServices [protected]

Pointer on existing services. This allows to use the class name and level of detail of another class, e.g. the class that owns this map. To set the "Owner", use the method SetOwner after the cmnNamedMap is constructed.

Definition at line 85 of file cmnNamedMap.h.

Referenced by cmnNamedMap< _elementType >::Services(), and cmnNamedMap< _elementType >::SetOwner().


The documentation for this class was generated from the following file:
erc-cisst-devel<at>lists.johnshopkins.edu