cisst-saw
|
#include <cmnNamedMap.h>
Public Types | |
typedef std::map< std::string, _elementType * > | MapType |
typedef MapType::iterator | iterator |
typedef MapType::const_iterator | const_iterator |
typedef MapType::reverse_iterator | reverse_iterator |
typedef MapType::const_reverse_iterator | const_reverse_iterator |
typedef MapType::size_type | size_type |
typedef _elementType | element_type |
typedef void(_elementType::* | VoidMethodPointer )(void) |
Public Member Functions | |
cmnNamedMap (bool takesOwnership=false) | |
cmnNamedMap (const char *mapName, bool takesOwnership=false) | |
cmnNamedMap (const std::string &mapName, bool takesOwnership=false) | |
cmnNamedMap (const std::string &mapName, const cmnGenericObject &owner, bool takesOwnership=false) | |
~cmnNamedMap () | |
void | SetOwner (const cmnGenericObject &owner) |
bool | AddItem (const std::string &name, _elementType *item, cmnLogLevel lod=CMN_LOG_LEVEL_RUN_ERROR) |
_elementType * | GetItem (const std::string &name, cmnLogLevel lod=CMN_LOG_LEVEL_RUN_DEBUG) const |
bool | FindItem (const std::string &itemName) const |
bool | RemoveItem (const std::string &name, cmnLogLevel lod=CMN_LOG_LEVEL_RUN_ERROR) |
void | ForEachVoid (VoidMethodPointer method) |
void | ToStream (std::ostream &outputStream) const |
void | DeleteAll (void) |
size_type | size (void) const |
bool | empty (void) const |
void | clear (void) |
iterator | begin (void) |
const_iterator | begin (void) const |
iterator | end (void) |
const_iterator | end (void) const |
void | GetNames (std::vector< std::string > &placeHolder) const |
std::vector< std::string > | GetNames (void) const |
const MapType & | GetMap (void) const |
MapType & | GetMap (void) |
Protected Member Functions | |
const cmnClassServicesBase * | Services (void) const |
cmnLogger::StreamBufType * | GetLogMultiplexer (void) const |
Protected Attributes | |
MapType | Map |
bool | TakesOwnership |
std::string | MapName |
const cmnClassServicesBase * | OwnerServices |
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.
typedef MapType::const_iterator cmnNamedMap< _elementType >::const_iterator |
typedef MapType::const_reverse_iterator cmnNamedMap< _elementType >::const_reverse_iterator |
typedef _elementType cmnNamedMap< _elementType >::element_type |
typedef MapType::iterator cmnNamedMap< _elementType >::iterator |
typedef std::map<std::string, _elementType *> cmnNamedMap< _elementType >::MapType |
Type of the actual map
typedef MapType::reverse_iterator cmnNamedMap< _elementType >::reverse_iterator |
typedef MapType::size_type cmnNamedMap< _elementType >::size_type |
typedef void(_elementType::* cmnNamedMap< _elementType >::VoidMethodPointer)(void) |
Type of void method in class _elementType
|
inline |
Default constructor, initialize the internal map and set the map name to "undefined"
|
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)
|
inline |
|
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.
|
inline |
Destructor. Relies on std::map destructor.
bool cmnNamedMap< _elementType >::AddItem | ( | const std::string & | name, |
_elementType * | item, | ||
cmnLogLevel | lod = CMN_LOG_LEVEL_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.
|
inline |
|
inline |
|
inline |
void cmnNamedMap< _elementType >::DeleteAll | ( | void | ) |
Delete all content while preserving keys, i.e. the map contains pairs of names and null pointers.
|
inline |
|
inline |
|
inline |
bool cmnNamedMap< _elementType >::FindItem | ( | const std::string & | itemName | ) | const |
Find an item by name
void cmnNamedMap< _elementType >::ForEachVoid | ( | VoidMethodPointer | method | ) |
Execute a method on all objects contained in the map
_elementType * cmnNamedMap< _elementType >::GetItem | ( | const std::string & | name, |
cmnLogLevel | lod = CMN_LOG_LEVEL_RUN_DEBUG |
||
) | const |
Get an item by name
|
inlineprotected |
|
inline |
Reference on the internal map
|
inline |
void cmnNamedMap< _elementType >::GetNames | ( | std::vector< std::string > & | placeHolder | ) | const |
List of names used, i.e. list of keys in the map
std::vector< std::string > cmnNamedMap< _elementType >::GetNames | ( | void | ) | const |
bool cmnNamedMap< _elementType >::RemoveItem | ( | const std::string & | name, |
cmnLogLevel | lod = CMN_LOG_LEVEL_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.
|
inlineprotected |
Method use to emulate the cmnGenericObject interface used by CMN_LOG_CLASS macros.
|
inline |
Set the map owner
|
inline |
STL compatible size
void cmnNamedMap< _elementType >::ToStream | ( | std::ostream & | outputStream | ) | const |
Print the content of the map as well as its name
|
protected |
Map data member, uses an std::map
|
protected |
Name of the map, mostly for logging purposes.
|
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.
|
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.