Документ взят из кэша поисковой машины. Адрес оригинального документа : http://www.atnf.csiro.au/computing/software/casacore/casacore-1.2.0/doc/html/classcasa_1_1ObjectPool.html
Дата изменения: Unknown
Дата индексирования: Mon Feb 14 21:36:39 2011
Кодировка:

Поисковые слова: vallis
casacore: casa::ObjectPool< T, Key > Class Template Reference
Public Member Functions | Private Member Functions | Private Attributes

casa::ObjectPool< T, Key > Class Template Reference
[Containers_module]

A parameterized stack of re-usable objects. More...

#include <ObjectPool.h>

List of all members.

Public Member Functions

 ObjectPool ()
 Create the pool.
 ~ObjectPool ()
 Delete the pool.
T * get (const Key key=Key())
 Get a pointer to an object in the pool with the specified parameter.
PoolStack< T, Key > & getStack (const Key key)
 Get the object stack for the given key.
void release (T *obj, const Key key=Key())
 Release an object obtained from the pool through get for re-use.
uInt nelements () const
 Get the number of object stacks in the pool.
void clearStacks ()
 Decimate the stacks by deleting all unused objects.
void clearStack (const Key key=Key())
void clear ()
 Decimate the stacks and remove any map entry that is completely unused.

Private Member Functions

 ObjectPool (const ObjectPool< T, Key > &other)
 Copy and assignment constructors and assignment (not implemented).
ObjectPool< T, Key > & operator= (const ObjectPool< T, Key > &other)

Private Attributes

Key defKey_p
 The default key and stack, and the last referenced one (for caching purposes).
PoolStack< T, Key > * defStack_p
Key cacheKey_p
PoolStack< T, Key > * cacheStack_p
SimpleOrderedMap< Key,
PoolStack< T, Key > * > 
map_p
 The pool map.

Detailed Description

template<class T, class Key>
class casa::ObjectPool< T, Key >

A parameterized stack of re-usable objects.

Intended use:

Public interface

Review Status

Reviewed By:
Ger van Diepen
Date Reviewed:
2001/07/04
Test programs:
tObjectPool

Prerequisite

Synopsis

An ObjectPool contains a set of pre-allocated Objects of the type T. A Map based on the Key values contains a stack of objects for each key value.

As an example, a <Vector<Double>, uInt> ObjectPool contains a SimpleOrderedMap<uInt,PoolStack<Vector<Double>,uInt>* > map. Each Stack will contain a stack of Vector<Double> objects, with a length of the key value each.

When an object is asked for with the get method, the correct stack is found using the parameter key. If no entry in the map exists, a new stack is created. If the relevant stack is empty, new elements are added to the stack.

Example

      // Create a pool of vectors
      ObjectPool<Vector<Double>, uInt> pool;
      // Get a pointer to a pre-defined vector of length 5
      Vector<Double> *el5(pool.get(5));
      // and one of length 10
      Vector<Double> *el10(pool.get(10));
      ..\.
      // Release the objects for re-use
      pool.release(el5, 5);
      pool.release(el10, 10); 

Motivation

To improve the speed for the auto differentiating class.

Template Type Argument Requirements (T)

Template Type Argument Requirements (Key)

To Do

Definition at line 99 of file ObjectPool.h.


Constructor & Destructor Documentation

template<class T, class Key>
casa::ObjectPool< T, Key >::ObjectPool (  ) 

Create the pool.

template<class T, class Key>
casa::ObjectPool< T, Key >::~ObjectPool (  ) 

Delete the pool.

template<class T, class Key>
casa::ObjectPool< T, Key >::ObjectPool ( const ObjectPool< T, Key > &  other  )  [private]

Copy and assignment constructors and assignment (not implemented).


Member Function Documentation

template<class T, class Key>
void casa::ObjectPool< T, Key >::clear (  ) 

Decimate the stacks and remove any map entry that is completely unused.

template<class T, class Key>
void casa::ObjectPool< T, Key >::clearStack ( const Key  key = Key()  ) 
template<class T, class Key>
void casa::ObjectPool< T, Key >::clearStacks (  ) 

Decimate the stacks by deleting all unused objects.

template<class T, class Key>
T* casa::ObjectPool< T, Key >::get ( const Key  key = Key()  )  [inline]

Get a pointer to an object in the pool with the specified parameter.

The object is detached from the stack, and has to be returned with the release method. The object should not be deleted by caller.

Definition at line 48 of file ObjectPool.h.

template<class T, class Key>
PoolStack<T, Key>& casa::ObjectPool< T, Key >::getStack ( const Key  key  ) 

Get the object stack for the given key.

template<class T, class Key>
uInt casa::ObjectPool< T, Key >::nelements (  )  const [inline]

Get the number of object stacks in the pool.

Definition at line 59 of file ObjectPool.h.

template<class T, class Key>
ObjectPool<T, Key>& casa::ObjectPool< T, Key >::operator= ( const ObjectPool< T, Key > &  other  )  [private]
template<class T, class Key>
void casa::ObjectPool< T, Key >::release ( T *  obj,
const Key  key = Key() 
)

Release an object obtained from the pool through get for re-use.

Referenced by casa::AutoDiff< Double >::release().


Member Data Documentation

template<class T, class Key>
Key casa::ObjectPool< T, Key >::cacheKey_p [private]

Definition at line 77 of file ObjectPool.h.

template<class T, class Key>
PoolStack<T, Key>* casa::ObjectPool< T, Key >::cacheStack_p [private]

Definition at line 78 of file ObjectPool.h.

template<class T, class Key>
Key casa::ObjectPool< T, Key >::defKey_p [private]

The default key and stack, and the last referenced one (for caching purposes).

Definition at line 75 of file ObjectPool.h.

template<class T, class Key>
PoolStack<T, Key>* casa::ObjectPool< T, Key >::defStack_p [private]

Definition at line 76 of file ObjectPool.h.

template<class T, class Key>
SimpleOrderedMap<Key, PoolStack<T, Key>* > casa::ObjectPool< T, Key >::map_p [private]

The pool map.

Definition at line 82 of file ObjectPool.h.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines