| # Gaudi Framework, version v21r10p1 |

Home |  | Generated: 29 Jul 2010

# TransientFastContainer< T, CLEANER > Class Template Reference

Container providing internal memory management. More...

`#include <GaudiKernel/TransientFastContainer.h>`

Inheritance diagram for TransientFastContainer< T, CLEANER >:

[legend]
Collaboration diagram for TransientFastContainer< T, CLEANER >:

[legend]

List of all members.

## Public Types
typedef T | contained_type
typedef contained_type * | value_type
typedef value_type | pointer
typedef const value_type | const_pointer
typedef value_type | reference
typedef const value_type | const_reference
typedef std::vector< value_type > | storage_type
typedef storage_type::size_type | size_type
typedef storage_type::iterator | iterator
typedef storage_type::const_iterator | const_iterator
typedef CLEANER | cleaner_type
## Public Member Functions
| TransientFastContainer (size_type n=0)
| Standard constructor. If the argument n is not zero, n objects are instantiated.
virtual | ~TransientFastContainer ()
| Delete all the recorded objects.
virtual void | clear ()
| Set the internal counter to 0 without actually deleting the objects.
virtual void | free ()
| Delete all the contained objects to free memory.
virtual const std::type_info & | containedType () const
| Return type information on the contained objects.
pointer | New ()
| Add a new object to the container or reuse one of the already available objects (after cleaning), and return a pointer to it.
pointer | Add (const T &rhs)
| Add a new object to the container or reuse one of the already available objects (after cleaning), and return a pointer to it.
pointer | NewPointer ()
| Get a pointer to a non-initialized chunk of memory either destructing an already existing object or creating a new one and destructing it.
iterator | begin ()
| Iterator pointing to the first object of the container.
const_iterator | begin () const
| Const iterator pointing to the first object of the container.
iterator | end ()
| Iterator pointing after the last used object in the container.
const_iterator | end () const
| Const iterator pointing after the last used object in the container.
size_type | size () const
| Returns the number of used objects in the container.
pointer | operator[] (size_type index)
| Accessor to the object at the given index. Throws std::out_of_range if index is greater than size().
const contained_type * | operator[] (size_type index) const
| Const accessor to the object at the given index. Throws std::out_of_range if index is greater than size().
pointer | at (size_type index)
| Same as operator[]().
const contained_type * | at (size_type index) const
| Same as operator[]() const.
## Private Member Functions
pointer | i_new ()
| Implementation function that instantiate a new object.
pointer | i_new (const T &rhs)
| Implementation function that instantiate a new object using the copy constructor.
## Private Attributes
size_type | m_counter
| Internal counter.
size_type | m_current_size
| Number of already allocated objects.
storage_type | m_storage
| Repository of allocated objects.
iterator | m_end
| Iterator that is returned by end().
cleaner_type | m_cleaner
| Instance of the class that cleans new objects.

## Detailed Description

### template<class T, class CLEANER = DefaultObjectCleaner<T>>
class TransientFastContainer< T, CLEANER >

Container providing internal memory management.

New objects are added to the container using the member function New(). Those are not deleted until destruction of the container. When the method clear() is called, the internal of the container is set to 0 and it behaves as if it is, but it still has memory of all the created object. When the New() is invoked on a "cleared" container, it returns the pointer of the first non-used of the known objects after calling an instance of CLEANER on it, or a new object if all the know objects are already in use.

Author:
  Marco Clemencic

Date:
  2006-05-02

Definition at line 83 of file TransientFastContainer.h.

## Member Typedef Documentation

template<class T, class CLEANER = DefaultObjectCleaner<T>>

typedef T TransientFastContainer< T, CLEANER >::contained_type

Definition at line 86 of file TransientFastContainer.h.

template<class T, class CLEANER = DefaultObjectCleaner<T>>

typedef contained_type* TransientFastContainer< T, CLEANER >::value_type

Definition at line 87 of file TransientFastContainer.h.

template<class T, class CLEANER = DefaultObjectCleaner<T>>

typedef value_type TransientFastContainer< T, CLEANER >::pointer

Definition at line 89 of file TransientFastContainer.h.

template<class T, class CLEANER = DefaultObjectCleaner<T>>

typedef const value_type TransientFastContainer< T, CLEANER >::const_pointer

Definition at line 90 of file TransientFastContainer.h.

template<class T, class CLEANER = DefaultObjectCleaner<T>>

typedef value_type TransientFastContainer< T, CLEANER >::reference

Definition at line 92 of file TransientFastContainer.h.

template<class T, class CLEANER = DefaultObjectCleaner<T>>

typedef const value_type TransientFastContainer< T, CLEANER >::const_reference

Definition at line 93 of file TransientFastContainer.h.

template<class T, class CLEANER = DefaultObjectCleaner<T>>

typedef std::vector<value_type> TransientFastContainer< T, CLEANER >::storage_type

Definition at line 95 of file TransientFastContainer.h.

template<class T, class CLEANER = DefaultObjectCleaner<T>>

typedef storage_type::size_type TransientFastContainer< T, CLEANER >::size_type

Definition at line 97 of file TransientFastContainer.h.

template<class T, class CLEANER = DefaultObjectCleaner<T>>

typedef storage_type::iterator TransientFastContainer< T, CLEANER >::iterator

Definition at line 99 of file TransientFastContainer.h.

template<class T, class CLEANER = DefaultObjectCleaner<T>>

typedef storage_type::const_iterator TransientFastContainer< T, CLEANER >::const_iterator

Definition at line 100 of file TransientFastContainer.h.

template<class T, class CLEANER = DefaultObjectCleaner<T>>

typedef CLEANER TransientFastContainer< T, CLEANER >::cleaner_type

Definition at line 102 of file TransientFastContainer.h.

## Constructor & Destructor Documentation

template<class T, class CLEANER>

TransientFastContainer< T, CLEANER >::TransientFastContainer | ( | size_type | n = `0` | ) | `[inline]`

Standard constructor. If the argument n is not zero, n objects are instantiated.

Definition at line 186 of file TransientFastContainer.h.

    00186                                                                     :
    00187   TransientFastContainerBase(),
    00188   m_counter(0),
    00189   m_current_size(0),
    00190   m_storage(),
    00191   m_end(m_storage.begin()),
    00192   m_cleaner()
    00193 {
    00194   if (n>0) {
    00195     m_storage.reserve(n);
    00196     for(;n>0;--n) New();
    00197     clear();
    00198   }
    00199 }

template<class T, class CLEANER>

TransientFastContainer< T, CLEANER >::~TransientFastContainer | ( |  | ) | `[inline, virtual]`

Delete all the recorded objects.

Definition at line 202 of file TransientFastContainer.h.

    00203 {
    00204   free();
    00205 }

## Member Function Documentation

template<class T, class CLEANER>

void TransientFastContainer< T, CLEANER >::clear | ( |  | ) | `[inline, virtual]`

Set the internal counter to 0 without actually deleting the objects.

Implements TransientFastContainerBase.

Definition at line 209 of file TransientFastContainer.h.

    00209                                               {
    00210   m_counter = 0;
    00211   m_end = m_storage.begin();
    00212 }

template<class T, class CLEANER>

void TransientFastContainer< T, CLEANER >::free | ( |  | ) | `[inline, virtual]`

Delete all the contained objects to free memory.

Implements TransientFastContainerBase.

Definition at line 215 of file TransientFastContainer.h.

    00215                                              {
    00216   for( typename storage_type::iterator i = m_storage.begin();
    00217        i != m_storage.end();
    00218        ++i ) {
    00219     delete *i;
    00220   }
    00221   m_storage.clear();
    00222   m_counter = m_current_size = 0;
    00223   m_end = m_storage.begin();
    00224 }

template<class T, class CLEANER = DefaultObjectCleaner<T>>

virtual const std::type_info& TransientFastContainer< T, CLEANER >::containedType | ( |  | ) | const`[inline, virtual]`

Return type information on the contained objects.

Implements TransientFastContainerBase.

Definition at line 119 of file TransientFastContainer.h.

    00119 { return typeid(contained_type); }

template<class T, class CLEANER = DefaultObjectCleaner<T>>

pointer TransientFastContainer< T, CLEANER >::New | ( |  | ) | `[inline]`

Add a new object to the container or reuse one of the already available objects (after cleaning), and return a pointer to it.

Definition at line 125 of file TransientFastContainer.h.

    00125 { return ( m_counter++ < m_current_size ) ? m_cleaner(*(m_end++)) : i_new(); }

template<class T, class CLEANER = DefaultObjectCleaner<T>>

pointer TransientFastContainer< T, CLEANER >::Add | ( | const T & | rhs | ) | `[inline]`

Add a new object to the container or reuse one of the already available objects (after cleaning), and return a pointer to it.

Definition at line 129 of file TransientFastContainer.h.

    00129 { return ( m_counter++ < m_current_size ) ? m_cleaner(*(m_end++),rhs) : i_new(rhs); }

template<class T, class CLEANER = DefaultObjectCleaner<T>>

pointer TransientFastContainer< T, CLEANER >::NewPointer | ( |  | ) | `[inline]`

Get a pointer to a non-initialized chunk of memory either destructing an already existing object or creating a new one and destructing it.

Definition at line 133 of file TransientFastContainer.h.

    00134   { return ( m_counter++ < m_current_size ) ?  m_cleaner.destruct(*(m_end++)) : m_cleaner.destruct(i_new()); }

template<class T, class CLEANER = DefaultObjectCleaner<T>>

iterator TransientFastContainer< T, CLEANER >::begin | ( |  | ) | `[inline]`

Iterator pointing to the first object of the container.

Definition at line 137 of file TransientFastContainer.h.

    00137 { return m_storage.begin(); }

template<class T, class CLEANER = DefaultObjectCleaner<T>>

const_iterator TransientFastContainer< T, CLEANER >::begin | ( |  | ) | const`[inline]`

Const iterator pointing to the first object of the container.

Definition at line 139 of file TransientFastContainer.h.

    00139 { return m_storage.begin(); }

template<class T, class CLEANER = DefaultObjectCleaner<T>>

iterator TransientFastContainer< T, CLEANER >::end | ( |  | ) | `[inline]`

Iterator pointing after the last used object in the container.

Definition at line 142 of file TransientFastContainer.h.

    00142 { return m_end; }

template<class T, class CLEANER = DefaultObjectCleaner<T>>

const_iterator TransientFastContainer< T, CLEANER >::end | ( |  | ) | const`[inline]`

Const iterator pointing after the last used object in the container.

Definition at line 144 of file TransientFastContainer.h.

    00144 { return m_end; }

template<class T, class CLEANER = DefaultObjectCleaner<T>>

size_type TransientFastContainer< T, CLEANER >::size | ( |  | ) | const`[inline]`

Returns the number of used objects in the container.

Definition at line 147 of file TransientFastContainer.h.

    00147 { return m_counter; }

template<class T, class CLEANER = DefaultObjectCleaner<T>>

pointer TransientFastContainer< T, CLEANER >::operator[] | ( | size_type | index | ) | `[inline]`

Accessor to the object at the given index. Throws std::out_of_range if index is greater than size().

Definition at line 150 of file TransientFastContainer.h.

    00151   { return (index < size()) ? m_storage[index] : throw std::out_of_range("index out of range"), (pointer)NULL; }

template<class T, class CLEANER = DefaultObjectCleaner<T>>

const contained_type* TransientFastContainer< T, CLEANER >::operator[] | ( | size_type | index | ) | const`[inline]`

Const accessor to the object at the given index. Throws std::out_of_range if index is greater than size().

Definition at line 153 of file TransientFastContainer.h.

    00154   { return (index < size()) ? m_storage[index] : throw std::out_of_range("index out of range"), (const_pointer)NULL; }

template<class T, class CLEANER = DefaultObjectCleaner<T>>

pointer TransientFastContainer< T, CLEANER >::at | ( | size_type | index | ) | `[inline]`

Same as operator[]().

Definition at line 157 of file TransientFastContainer.h.

    00157 { return operator[] (index); }

template<class T, class CLEANER = DefaultObjectCleaner<T>>

const contained_type* TransientFastContainer< T, CLEANER >::at | ( | size_type | index | ) | const`[inline]`

Same as operator[]() const.

Definition at line 159 of file TransientFastContainer.h.

    00159 { return operator[] (index); }

template<class T, class CLEANER>

TransientFastContainer< T, CLEANER >::pointer TransientFastContainer< T, CLEANER >::i_new | ( |  | ) | `[inline, private]`

Implementation function that instantiate a new object.

Definition at line 227 of file TransientFastContainer.h.

    00227                                                                                            {
    00228   //++m_counter; // already incremented in New()
    00229   ++m_current_size;
    00230   pointer ptr = new T();
    00231   m_storage.push_back(ptr);
    00232   m_end = m_storage.end();
    00233   return ptr;
    00234 }

template<class T, class CLEANER>

TransientFastContainer< T, CLEANER >::pointer TransientFastContainer< T, CLEANER >::i_new | ( | const T & | rhs | ) | `[inline, private]`

Implementation function that instantiate a new object using the copy constructor.

Definition at line 237 of file TransientFastContainer.h.

    00237                                                                                                        {
    00238   //++m_counter; // already incremented in New()
    00239   ++m_current_size;
    00240   pointer ptr = new T(rhs);
    00241   m_storage.push_back(ptr);
    00242   m_end = m_storage.end();
    00243   return ptr;
    00244 }

## Member Data Documentation

template<class T, class CLEANER = DefaultObjectCleaner<T>>

size_type TransientFastContainer< T, CLEANER >::m_counter`[private]`

Internal counter.

Definition at line 170 of file TransientFastContainer.h.

template<class T, class CLEANER = DefaultObjectCleaner<T>>

size_type TransientFastContainer< T, CLEANER >::m_current_size`[private]`

Number of already allocated objects.

Definition at line 173 of file TransientFastContainer.h.

template<class T, class CLEANER = DefaultObjectCleaner<T>>

storage_type TransientFastContainer< T, CLEANER >::m_storage`[private]`

Repository of allocated objects.

Definition at line 176 of file TransientFastContainer.h.

template<class T, class CLEANER = DefaultObjectCleaner<T>>

iterator TransientFastContainer< T, CLEANER >::m_end`[private]`

Iterator that is returned by end().

Definition at line 179 of file TransientFastContainer.h.

template<class T, class CLEANER = DefaultObjectCleaner<T>>

cleaner_type TransientFastContainer< T, CLEANER >::m_cleaner`[private]`

Instance of the class that cleans new objects.

Definition at line 182 of file TransientFastContainer.h.

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

- /afs/cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v21r10p1/GaudiKernel/GaudiKernel/TransientFastContainer.h