cisst-saw
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Static Public Member Functions | Protected Member Functions | List of all members
cmnObjectRegister Class Reference

Object Register. More...

#include <cmnObjectRegister.h>

Static Public Member Functions

static cmnObjectRegisterInstance (void)
 
static bool Register (const std::string &objectName, cmnGenericObject *objectPointer)
 
static bool Remove (const std::string &objectName)
 
static cmnGenericObjectFindObject (const std::string &objectName)
 
static std::string FindName (cmnGenericObject *objectPointer)
 
static std::string ToString (void)
 
static void ToStream (std::ostream &outputStream)
 
static const_iterator begin (void)
 
static const_iterator end (void)
 

Protected Member Functions

 cmnObjectRegister ()
 
virtual ~cmnObjectRegister ()
 
typedef
ContainerType::const_iterator 
const_iterator
 
typedef
ContainerType::const_reverse_iterator 
const_reverse_iterator
 

Detailed Description

Object Register.

The class register allows to register some objects by name. Since the object register is implemented as a singleton, it allows to retrieve an object from anywhere.

This mechanism can be used to share an object between different threads. Another example is the embedding of a scripting language such as Python. In this case, the programmer can use the Register() method to register an object with a given name. Within the Python shell, it is then possible to retrieve by name a "pointer" on the same object.

The main restriction is that all the registered objects must be derived from cmnGenericObject.

Member Typedef Documentation

typedef ContainerType::const_iterator cmnObjectRegister::const_iterator
typedef ContainerType::const_reverse_iterator cmnObjectRegister::const_reverse_iterator

Constructor & Destructor Documentation

cmnObjectRegister::cmnObjectRegister ( )
inlineprotected

Constructor. The only constructor must be private in order to ensure that the object register is a singleton.

virtual cmnObjectRegister::~cmnObjectRegister ( )
inlineprotectedvirtual

Destructor. Does nothing specific.

Member Function Documentation

static const_iterator cmnObjectRegister::begin ( void  )
inlinestatic

Begin const iterator.

static const_iterator cmnObjectRegister::end ( void  )
inlinestatic

End const iterator.

static std::string cmnObjectRegister::FindName ( cmnGenericObject objectPointer)
inlinestatic

Get the name of an object. Returns "undefined" if the object is not registered.

Parameters
objectPointerThe object to look up.
static cmnGenericObject* cmnObjectRegister::FindObject ( const std::string &  objectName)
inlinestatic

Get the object by name. Returns null if the object is not registered.

Parameters
objectNameThe name to look up.
Returns
The pointer to the cmnGenericObject object corresponding to the className, or null if not registered.
static cmnObjectRegister* cmnObjectRegister::Instance ( void  )
static

The object register is instantiated as a singleton. To access the unique instantiation, one needs to use this static method. The instantiated object register is created at the first call of this method since it is a static variable declared in this method's scope.

Returns
A pointer to the object register.
static bool cmnObjectRegister::Register ( const std::string &  objectName,
cmnGenericObject objectPointer 
)
inlinestatic

The Register method registers an object pointer with a given name in the static register.

Parameters
objectNameThe name given to the soon registered object.
objectPointerThe pointer to the cmnGenericObject object (or any derived class).
Returns
True if successful, false if the object has already been registered or the name has already been used.
static bool cmnObjectRegister::Remove ( const std::string &  objectName)
inlinestatic

The remove method allows to "un-register" a registered object. It doesn't affect the object itself.

Parameters
objectNameThe name given to the object when it was registered.
Returns
True if the object was actually registered, false if the object was not registered.
static void cmnObjectRegister::ToStream ( std::ostream &  outputStream)
inlinestatic

Print the register content to a text stream

static std::string cmnObjectRegister::ToString ( void  )
inlinestatic

Print the register content to an STL string and returns a copy of this string


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