ldas-tools-al  2.6.5
Classes | Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | Private Types | Private Member Functions | Private Attributes | Friends | List of all members
ObjectRegistry< T > Class Template Reference

Object Registry. More...

#include <objectregistry.hh>

Collaboration diagram for ObjectRegistry< T >:
Collaboration graph
[legend]

Classes

class  AutoLock
 Ensure release of resource lock. More...
 
struct  StateInfo
 State information for registered object. More...
 

Public Member Functions

 ObjectRegistry ()
 Constructor. More...
 
 ~ObjectRegistry ()
 Destructor. More...
 
bool isRegistered (const T *o) const
 Check if the object is one of managed objects. More...
 
size_t size () const
 The number of objects being managed. More...
 
void reset ()
 Clears the list of managed objects. More...
 
void registerObject (T *o)
 Add an object to the list of managed objects. More...
 
bool destructObject (T *o)
 Remove an object from the list and deletes the object. More...
 
bool removeObject (T *o)
 Remove an object from the list of managed objects. More...
 
template<class Op >
Op for_each (Op Function) const
 Execute a function for each member of the list. More...
 
 ObjectRegistry ()
 Constructor. More...
 
 ~ObjectRegistry ()
 Destructor. More...
 
bool isRegistered (const T *o) const
 Check if the object is one of managed objects. More...
 
size_t size () const
 The number of objects being managed. More...
 
void reset ()
 Clears the list of managed objects. More...
 
void registerObject (T *o)
 Add an object to the list of managed objects. More...
 
bool destructObject (T *o)
 Remove an object from the list and deletes the object. More...
 
bool removeObject (T *o)
 Remove an object from the list of managed objects. More...
 
template<class Op >
Op for_each (Op Function) const
 Execute a function for each member of the list. More...
 
 ObjectRegistry ()
 Constructor. More...
 
 ~ObjectRegistry ()
 Destructor. More...
 
bool isRegistered (const T *o) const
 Check if the object is one of managed objects. More...
 
size_t size () const
 The number of objects being managed. More...
 
void reset ()
 Clears the list of managed objects. More...
 
void registerObject (T *o)
 Add an object to the list of managed objects. More...
 
bool destructObject (T *o)
 Remove an object from the list and deletes the object. More...
 
bool removeObject (T *o)
 Remove an object from the list of managed objects. More...
 
template<class Op >
Op for_each (Op Function) const
 Execute a function for each member of the list. More...
 

Protected Types

typedef data_container_type::const_iterator const_iterator
 
typedef data_container_type::const_iterator const_iterator
 
typedef data_container_type::const_iterator const_iterator
 

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...
 
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...
 
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. More...
 

Private Types

typedef LDASTools::AL::unordered_map< T *, StateInfo, LDASTools::AL::hash< const void *> > data_container_type
 Container of managed pointer data. More...
 
typedef data_container_type::iterator iterator
 
typedef LDASTools::AL::unordered_map< T *, StateInfo, LDASTools::AL::hash< const void *> > data_container_type
 Container of managed pointer data. More...
 
typedef data_container_type::iterator iterator
 
typedef LDASTools::AL::unordered_map< T *, StateInfo, LDASTools::AL::hash< const void *> > data_container_type
 Container of managed pointer data. More...
 
typedef data_container_type::iterator iterator
 

Private Member Functions

iterator begin ()
 Obtain the start of the list. More...
 
iterator end ()
 Obtain the end of the list. More...
 
void lock (T *Object)
 Lock an object. More...
 
void unlock (T *Object)
 Unlock an object. More...
 
iterator begin ()
 Obtain the start of the list. More...
 
iterator end ()
 Obtain the end of the list. More...
 
void lock (T *Object)
 Lock an object. More...
 
void unlock (T *Object)
 Unlock an object. More...
 
iterator begin ()
 Obtain the start of the list. More...
 
iterator end ()
 Obtain the end of the list. More...
 
void lock (T *Object)
 Lock an object. More...
 
void unlock (T *Object)
 Unlock an object. More...
 

Private Attributes

data_container_type mData
 Collection of data members. More...
 

Friends

class AutoLock
 

Detailed Description

template<class T>
class ObjectRegistry< T >

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.

Member Typedef Documentation

◆ const_iterator [1/3]

template<class T>
typedef data_container_type::const_iterator ObjectRegistry< T >::const_iterator
protected

◆ const_iterator [2/3]

template<class T>
typedef data_container_type::const_iterator ObjectRegistry< T >::const_iterator
protected

◆ const_iterator [3/3]

template<class T>
typedef data_container_type::const_iterator ObjectRegistry< T >::const_iterator
protected

◆ data_container_type [1/3]

template<class T>
typedef LDASTools::AL:: unordered_map< T*, StateInfo, LDASTools::AL::hash< const void* > > ObjectRegistry< T >::data_container_type
private

Container of managed pointer data.

This container type holds the collection of managed pointers and their related meta data.

◆ data_container_type [2/3]

template<class T>
typedef LDASTools::AL:: unordered_map< T*, StateInfo, LDASTools::AL::hash< const void* > > ObjectRegistry< T >::data_container_type
private

Container of managed pointer data.

This container type holds the collection of managed pointers and their related meta data.

◆ data_container_type [3/3]

template<class T>
typedef LDASTools::AL:: unordered_map< T*, StateInfo, LDASTools::AL::hash< const void* > > ObjectRegistry< T >::data_container_type
private

Container of managed pointer data.

This container type holds the collection of managed pointers and their related meta data.

◆ iterator [1/3]

template<class T>
typedef data_container_type::iterator ObjectRegistry< T >::iterator
private

◆ iterator [2/3]

template<class T>
typedef data_container_type::iterator ObjectRegistry< T >::iterator
private

◆ iterator [3/3]

template<class T>
typedef data_container_type::iterator ObjectRegistry< T >::iterator
private

Constructor & Destructor Documentation

◆ ObjectRegistry() [1/3]

template<class T>
ObjectRegistry< T >::ObjectRegistry ( )

Constructor.

◆ ~ObjectRegistry() [1/3]

template<class T>
ObjectRegistry< T >::~ObjectRegistry ( )

Destructor.

◆ ObjectRegistry() [2/3]

template<class T>
ObjectRegistry< T >::ObjectRegistry ( )

Constructor.

◆ ~ObjectRegistry() [2/3]

template<class T>
ObjectRegistry< T >::~ObjectRegistry ( )

Destructor.

◆ ObjectRegistry() [3/3]

template<class T>
ObjectRegistry< T >::ObjectRegistry ( )

Constructor.

◆ ~ObjectRegistry() [3/3]

template<class T>
ObjectRegistry< T >::~ObjectRegistry ( )

Destructor.

Member Function Documentation

◆ begin() [1/6]

template<class T >
ObjectRegistry< T >::const_iterator ObjectRegistry< T >::begin ( ) const
inlineprotected

Obtain the start of the list (read-only)

Get Beginning Const Iterator.

Returns a constant iterator positioned at the beginning of the registry.

Returns
const_iterator

◆ begin() [2/6]

template<class T>
const_iterator ObjectRegistry< T >::begin ( ) const
protected

Obtain the start of the list (read-only)

◆ begin() [3/6]

template<class T>
const_iterator ObjectRegistry< T >::begin ( ) const
protected

Obtain the start of the list (read-only)

◆ begin() [4/6]

template<class T>
iterator ObjectRegistry< T >::begin ( )
private

Obtain the start of the list.

◆ begin() [5/6]

template<class T >
ObjectRegistry< T >::iterator ObjectRegistry< T >::begin ( )
inlineprivate

Obtain the start of the list.

Get Beginning Iterator.

Returns an iterator positioned at the beginning of the registry.

Returns
iterator

◆ begin() [6/6]

template<class T>
iterator ObjectRegistry< T >::begin ( )
private

Obtain the start of the list.

◆ destructObject() [1/3]

template<class T>
bool ObjectRegistry< T >::destructObject ( T *  o)

Remove an object from the list and deletes the object.

◆ destructObject() [2/3]

template<class T>
bool ObjectRegistry< T >::destructObject ( T *  o)

Remove an object from the list and deletes the object.

◆ destructObject() [3/3]

template<class T>
bool ObjectRegistry< T >::destructObject ( T *  o)

Remove an object from the list and deletes the object.

◆ end() [1/6]

template<class T>
const_iterator ObjectRegistry< T >::end ( ) const
protected

Obtain the end of the list (read-only)

◆ end() [2/6]

template<class T >
ObjectRegistry< T >::const_iterator ObjectRegistry< T >::end ( ) const
inlineprotected

Obtain the end of the list (read-only)

Get End Const Iterator.

Returns a constant iterator positioned at the end of the registry.

Returns
const_iterator

◆ end() [3/6]

template<class T>
const_iterator ObjectRegistry< T >::end ( ) const
protected

Obtain the end of the list (read-only)

◆ end() [4/6]

template<class T>
iterator ObjectRegistry< T >::end ( )
private

Obtain the end of the list.

◆ end() [5/6]

template<class T >
ObjectRegistry< T >::iterator ObjectRegistry< T >::end ( )
inlineprivate

Obtain the end of the list.

Get End Iterator.

Returns an iterator positioned at the end of the registry.

Returns
iterator

◆ end() [6/6]

template<class T>
iterator ObjectRegistry< T >::end ( )
private

Obtain the end of the list.

◆ for_each() [1/3]

template<class T>
template<class Op >
Op ObjectRegistry< T >::for_each ( Op  Function) const

Execute a function for each member of the list.

◆ for_each() [2/3]

template<class T>
template<class Op >
Op ObjectRegistry< T >::for_each ( Op  Function) const

Execute a function for each member of the list.

◆ for_each() [3/3]

template<class T>
template<class Op >
Op ObjectRegistry< T >::for_each ( Op  Function) const

Execute a function for each member of the list.

◆ isRegistered() [1/3]

template<class T>
bool ObjectRegistry< T >::isRegistered ( const T *  o) const

Check if the object is one of managed objects.

◆ isRegistered() [2/3]

template<class T>
bool ObjectRegistry< T >::isRegistered ( const T *  o) const

Check if the object is one of managed objects.

◆ isRegistered() [3/3]

template<class T>
bool ObjectRegistry< T >::isRegistered ( const T *  o) const

Check if the object is one of managed objects.

◆ lock() [1/3]

template<class T>
void ObjectRegistry< T >::lock ( T *  Object)
private

Lock an object.

◆ lock() [2/3]

template<class T>
void ObjectRegistry< T >::lock ( T *  Object)
private

Lock an object.

◆ lock() [3/3]

template<class T>
void ObjectRegistry< T >::lock ( T *  Object)
private

Lock an object.

◆ registerObject() [1/3]

template<class T>
void ObjectRegistry< T >::registerObject ( T *  o)

Add an object to the list of managed objects.

◆ registerObject() [2/3]

template<class T>
void ObjectRegistry< T >::registerObject ( T *  o)

Add an object to the list of managed objects.

◆ registerObject() [3/3]

template<class T>
void ObjectRegistry< T >::registerObject ( T *  o)

Add an object to the list of managed objects.

◆ removeObject() [1/3]

template<class T>
bool ObjectRegistry< T >::removeObject ( T *  o)

Remove an object from the list of managed objects.

◆ removeObject() [2/3]

template<class T>
bool ObjectRegistry< T >::removeObject ( T *  o)

Remove an object from the list of managed objects.

◆ removeObject() [3/3]

template<class T>
bool ObjectRegistry< T >::removeObject ( T *  o)

Remove an object from the list of managed objects.

◆ reset() [1/3]

template<class T>
void ObjectRegistry< T >::reset ( )

Clears the list of managed objects.

◆ reset() [2/3]

template<class T>
void ObjectRegistry< T >::reset ( )

Clears the list of managed objects.

◆ reset() [3/3]

template<class T>
void ObjectRegistry< T >::reset ( )

Clears the list of managed objects.

◆ size() [1/3]

template<class T>
size_t ObjectRegistry< T >::size ( ) const

The number of objects being managed.

◆ size() [2/3]

template<class T>
size_t ObjectRegistry< T >::size ( ) const

The number of objects being managed.

◆ size() [3/3]

template<class T>
size_t ObjectRegistry< T >::size ( ) const

The number of objects being managed.

◆ unlock() [1/3]

template<class T>
void ObjectRegistry< T >::unlock ( T *  Object)
private

Unlock an object.

◆ unlock() [2/3]

template<class T>
void ObjectRegistry< T >::unlock ( T *  Object)
private

Unlock an object.

◆ unlock() [3/3]

template<class T>
void ObjectRegistry< T >::unlock ( T *  Object)
private

Unlock an object.

Friends And Related Function Documentation

◆ AutoLock

template<class T>
AutoLock
friend

Member Data Documentation

◆ m_lock

template<class T>
LDASTools::AL::ReadWriteLock::baton_type ObjectRegistry< T >::m_lock
mutableprotected

Ensure only one thread accesses the registry at a time.

◆ mData

template<class T>
data_container_type ObjectRegistry< T >::mData
private

Collection of data members.


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