ldas-tools-al 2.6.7
|
Object Registry. More...
#include <objectregistry.hh>
Classes | |
class | AutoLock |
Ensure release of resource lock. More... | |
struct | StateInfo |
State information for registered object. 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. | |
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 Types | |
typedef data_container_type::const_iterator | const_iterator |
Protected Member Functions | |
const_iterator | begin () const |
Obtain the start of the list (read-only) | |
const_iterator | end () const |
Obtain the end of the list (read-only) | |
const_iterator | begin () const |
Obtain the start of the list (read-only) | |
const_iterator | end () const |
Obtain the end of the list (read-only) | |
Protected Attributes | |
LDASTools::AL::ReadWriteLock::baton_type | m_lock |
Ensure only one thread accesses the registry at a time. | |
Private Types | |
typedef std::map< T *, StateInfo > | data_container_type |
Container of managed pointer data. | |
typedef data_container_type::iterator | iterator |
Private Member Functions | |
iterator | begin () |
Obtain the start of the list. | |
iterator | end () |
Obtain the end of the list. | |
void | lock (T *Object) |
Lock an object. | |
void | unlock (T *Object) |
Unlock an object. | |
iterator | begin () |
Obtain the start of the list. | |
iterator | end () |
Obtain the end of the list. | |
void | lock (T *Object) |
Lock an object. | |
void | unlock (T *Object) |
Unlock an object. | |
Private Attributes | |
data_container_type | mData |
Collection of data members. | |
Friends | |
class | AutoLock |
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.
|
protected |
|
private |
Container of managed pointer data.
This container type holds the collection of managed pointers and their related meta data.
|
private |
ObjectRegistry< T >::ObjectRegistry | ( | ) |
Constructor.
ObjectRegistry< T >::~ObjectRegistry | ( | ) |
Destructor.
ObjectRegistry< T >::ObjectRegistry | ( | ) |
Constructor.
ObjectRegistry< T >::~ObjectRegistry | ( | ) |
Destructor.
|
inlineprivate |
Obtain the start of the list.
Get Beginning Iterator.
Returns an iterator positioned at the beginning of the registry.
|
private |
Obtain the start of the list.
|
inlineprotected |
Obtain the start of the list (read-only)
Get Beginning Const Iterator.
Returns a constant iterator positioned at the beginning of the registry.
|
protected |
Obtain the start of the list (read-only)
bool ObjectRegistry< T >::destructObject | ( | T * | o | ) |
Remove an object from the list and deletes the object.
bool ObjectRegistry< T >::destructObject | ( | T * | o | ) |
Remove an object from the list and deletes the object.
|
inlineprivate |
Obtain the end of the list.
Get End Iterator.
Returns an iterator positioned at the end of the registry.
|
private |
Obtain the end of the list.
|
inlineprotected |
Obtain the end of the list (read-only)
Get End Const Iterator.
Returns a constant iterator positioned at the end of the registry.
|
protected |
Obtain the end of the list (read-only)
Execute a function for each member of the list.
Execute a function for each member of the list.
bool ObjectRegistry< T >::isRegistered | ( | const T * | o | ) | const |
Check if the object is one of managed objects.
bool ObjectRegistry< T >::isRegistered | ( | const T * | o | ) | const |
Check if the object is one of managed objects.
|
private |
Lock an object.
|
private |
Lock an object.
void ObjectRegistry< T >::registerObject | ( | T * | o | ) |
Add an object to the list of managed objects.
void ObjectRegistry< T >::registerObject | ( | T * | o | ) |
Add an object to the list of managed objects.
bool ObjectRegistry< T >::removeObject | ( | T * | o | ) |
Remove an object from the list of managed objects.
bool ObjectRegistry< T >::removeObject | ( | T * | o | ) |
Remove an object from the list of managed objects.
void ObjectRegistry< T >::reset | ( | ) |
Clears the list of managed objects.
void ObjectRegistry< T >::reset | ( | ) |
Clears the list of managed objects.
size_t ObjectRegistry< T >::size | ( | ) | const |
The number of objects being managed.
size_t ObjectRegistry< T >::size | ( | ) | const |
The number of objects being managed.
|
private |
Unlock an object.
|
private |
Unlock an object.
|
friend |
|
mutableprotected |
Ensure only one thread accesses the registry at a time.
|
private |
Collection of data members.