cisst-saw
|
Object Register. More...
#include <cmnObjectRegister.h>
Static Public Member Functions | |
static cmnObjectRegister * | Instance (void) |
static bool | Register (const std::string &objectName, cmnGenericObject *objectPointer) |
static bool | Remove (const std::string &objectName) |
static cmnGenericObject * | FindObject (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 |
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.
typedef ContainerType::const_iterator cmnObjectRegister::const_iterator |
typedef ContainerType::const_reverse_iterator cmnObjectRegister::const_reverse_iterator |
|
inlineprotected |
Constructor. The only constructor must be private in order to ensure that the object register is a singleton.
|
inlineprotectedvirtual |
Destructor. Does nothing specific.
|
inlinestatic |
Begin const iterator.
|
inlinestatic |
End const iterator.
|
inlinestatic |
Get the name of an object. Returns "undefined" if the object is not registered.
objectPointer | The object to look up. |
|
inlinestatic |
Get the object by name. Returns null if the object is not registered.
objectName | The name to look up. |
|
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.
|
inlinestatic |
The Register method registers an object pointer with a given name in the static register.
objectName | The name given to the soon registered object. |
objectPointer | The pointer to the cmnGenericObject object (or any derived class). |
|
inlinestatic |
The remove method allows to "un-register" a registered object. It doesn't affect the object itself.
objectName | The name given to the object when it was registered. |
|
inlinestatic |
Print the register content to a text stream
|
inlinestatic |
Print the register content to an STL string and returns a copy of this string