Controller< T > Class Template Reference

Controller template. Helps managing a collection of objects. More...

#include <Controller.h>

List of all members.

Public Types

typedef map< string, T >::iterator TIterator
typedef pair< TIterator,
TIterator
TIterPair

Public Member Functions

 Controller ()
 Constructor.
 ~Controller ()
 Destructor.
T * exists (string s)
 Find an object using the key and return a pointer to it.
bool remove (string s)
 remove an object from collection
void registerReference (string s)
 Tells the controller to consider the instance referenced as in use.
void unregisterReference (string s)
 Tells the controller that one reference to the given instance is not used anymore.
pair< TIterator, TIteratorgetMapIterators ()
int cleanup ()

Protected Member Functions

T * _create (string) throw (ControlerInsertError)
 Internal creation function.

Protected Attributes

map< string, T > ObjectMap
map< string, int > ReferenceMap

Static Protected Attributes

static LoggerPtr logger

Private Member Functions

bool check_remove (T)

Detailed Description

template<class T>
class Controller< T >

Controller template. Helps managing a collection of objects.


Member Typedef Documentation

template<class T>
typedef map<string, T>::iterator Controller< T >::TIterator
template<class T>
typedef pair<TIterator, TIterator> Controller< T >::TIterPair

Constructor & Destructor Documentation

template<class T >
Controller< T >::Controller (  )  [inline]

Constructor.

template<class T >
Controller< T >::~Controller (  )  [inline]

Destructor.


Member Function Documentation

template<class T >
T * Controller< T >::_create ( string  s  )  throw (ControlerInsertError) [inline, protected]

Internal creation function.

Try to create a new object instance and insert it in the map. Return a new instance or throw an exception if already exists. Each specialization of the Controller template should *

Parameters:
s the key of the object in the map
Returns:
a pointer to the freshly created object or the already existing object

Here is the call graph for this function:

template<class T>
bool Controller< T >::check_remove ( obj  )  [inline, private]

Here is the caller graph for this function:

template<class T >
int Controller< T >::cleanup (  )  [inline]

Scan the ObjectMap and destroy the instances that are not referenced. Before destruction, calls the prepareCleanup of each referenced object. This step depends on each Controller specialization.

Returns:
the number of instances removed

Here is the caller graph for this function:

template<class T >
T * Controller< T >::exists ( string  s  )  [inline]

Find an object using the key and return a pointer to it.

Parameters:
s the key to search for
Returns:
a pointer to the object if found. NULL otherwise.

Here is the caller graph for this function:

template<class T >
Controller< T >::TIterPair Controller< T >::getMapIterators (  )  [inline]

Allows access to the object map

Returns:
a pair of iterators (begin, end)
template<class T >
void Controller< T >::registerReference ( string  s  )  [inline]

Tells the controller to consider the instance referenced as in use.

Increments the accounting map for this reference

Parameters:
s the reference of the instance to register as used.

Here is the caller graph for this function:

template<class T >
bool Controller< T >::remove ( string  s  )  [inline]

remove an object from collection

Parameters:
s the key of the object to remove
Returns:
true if removed, false otherwise

Here is the call graph for this function:

template<class T >
void Controller< T >::unregisterReference ( string  s  )  [inline]

Tells the controller that one reference to the given instance is not used anymore.

Parameters:
s the reference of the instance to register as used.

Here is the caller graph for this function:


Member Data Documentation

template<class T>
LoggerPtr Controller< T >::logger [inline, static, protected]
template<class T>
map<string, T> Controller< T >::ObjectMap [protected]
template<class T>
map<string, int> Controller< T >::ReferenceMap [protected]

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

Generated on 4 Mar 2010 for TReqS by  doxygen 1.6.1