ldas-tools-al
2.5.7
|
Object Registry. More...
#include <objectregistry.hh>
Classes | |
class | AutoLock |
Ensure release of resource lock. More... | |
Public Member Functions | |
ObjectRegistry () | |
Constructor. | |
~ObjectRegistry () | |
Destructor. | |
bool | isRegistered (const T *o) const |
Check if the object is one of managed objects. | |
size_t | size () const |
The number of objects being managed. | |
void | reset () |
Clears the list of managed objects. | |
void | registerObject (T *o) |
Add an object to the list of managed objects. | |
bool | destructObject (T *o) |
Remove an object from the list and deletes the object. | |
bool | removeObject (T *o) |
Remove an object from the list of managed objects. | |
template<class Op > | |
Op | for_each (Op Function) const |
Execute a function for each member of the list. | |
Protected Member Functions | |
const_iterator | begin () const |
Obtain the start of the list (read-only) More... | |
const_iterator | end () const |
Obtain the end of the list (read-only) More... | |
Protected Attributes | |
LDASTools::AL::ReadWriteLock::baton_type | m_lock |
Ensure only one thread accesses the registry at a time. | |
Object Registry.
This class implements a registry for objects. The registry provides a mechanism for keeping track of pointers. The class contains methods to add/remove pointers to the registry, as well as to check for the existence of a pointer in the registry.
The registry owns its objects. That is, when the registry is destructed it destructs any objects which are registered with it.
A STL set is used to store pointers to the registered objects.
This class is used by the LDAS API's to keep track of pointer objects returned to the TCL layer. To avoid segmentation faults, when the C++ layer receives a pointer from TCL, the appropriate ObjectRegistry object is checked to ensure that the pointer exists. Furthermore, the resetApi command causes the C++ layer to empty the ObjectRegistry objects, thereby ensuring that memory isn't leaked by the TCL layer failing to destruct C+ objects.
|
inlineprotected |
Obtain the start of the list (read-only)
Get Beginning Const Iterator.
Returns a constant iterator positioned at the beginning of the registry.
|
inlineprotected |
Obtain the end of the list (read-only)
Get End Const Iterator.
Returns a constant iterator positioned at the end of the registry.