| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

In This Package:

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.

inline code of class DataObject

void setRegistry (IRegistry *pRegistry)
 Set pointer to Registry.
IRegistryregistry () const
 Get pointer to Registry.
LinkManagerlinkMgr () const
 Retrieve Link manager.
unsigned char version () const
 Retrieve version number of this object representation.
void setVersion (unsigned char vsn)
 Set version number of this object representation.
unsigned long refCount () const
 Return the refcount.
virtual std::ostream & fillStream (std::ostream &s) const
 Fill the output stream (ASCII).
std::ostream & operator<< (std::ostream &s, const DataObject &obj)
 Output operator (ASCII).

Public Types

typedef T contained_type
typedef contained_typevalue_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_typestorage_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 agument n is not zero, n objects are instantiated.
virtual ~TransientFastContainer ()
 Delete all the recorded objects.
virtual void clear ()
 Set the internal conter 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 objetcs.
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_typeoperator[] (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_typeat (size_type index) const
 Same as operator[]() const.
virtual unsigned long addRef ()
 Add reference to object.
virtual unsigned long release ()
 release reference to object
virtual const CLIDclID () const
 Retrieve reference to class definition structure.
const std::string & name () const
 Retreive DataObject name. It is the name when registered in the store.
virtual StreamBufferserialize (StreamBuffer &s)
 Serialization mechanism: Serialize the object for reading.
virtual StreamBufferserialize (StreamBuffer &s) const
 Serialization mechanism: Serialize the object for writing.

Static Public Member Functions

static const CLIDclassID ()
 Retrieve reference to class definition structure (static access).

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 ar 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  ) 

Standard constructor. If the agument 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 (  )  [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 (  )  [virtual]

Set the internal conter 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 (  )  [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 objetcs.

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 (  )  [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  )  [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 }

virtual unsigned long DataObject::addRef (  )  [virtual, inherited]

Add reference to object.

virtual unsigned long DataObject::release (  )  [virtual, inherited]

release reference to object

virtual const CLID& DataObject::clID (  )  const [virtual, inherited]

Retrieve reference to class definition structure.

Reimplemented in AlgorithmHistory, AlgToolHistory, DataHistory, HistoryObj, JobHistory, KeyedContainer< DATATYPE, MAPPING >, NTuple::Directory, NTuple::File, NTuple::ColumnWiseTuple, NTuple::RowWiseTuple, ObjectList< TYPE >, ObjectVector< TYPE >, RefTable1to1< FROM, TO >, RefTable1toN< FROM, TO >, ServiceHistory, and SharedObjectsContainer< TYPE >.

static const CLID& DataObject::classID (  )  [static, inherited]

Retrieve reference to class definition structure (static access).

Reimplemented in AlgorithmHistory, AlgToolHistory, DataHistory, HistoryObj, JobHistory, KeyedContainer< DATATYPE, MAPPING >, NTuple::Directory, NTuple::File, NTuple::ColumnWiseTuple, NTuple::RowWiseTuple, ObjectList< TYPE >, ObjectVector< TYPE >, ServiceHistory, and SharedObjectsContainer< TYPE >.

const std::string& DataObject::name (  )  const [inherited]

Retreive DataObject name. It is the name when registered in the store.

Reimplemented in NTuple::File, and ServiceHistory.

virtual StreamBuffer& DataObject::serialize ( StreamBuffer s  )  [virtual, inherited]

Serialization mechanism: Serialize the object for reading.

Reimplemented in RefTableBase< FROM, MAPENTRY >, RefTableBase< FROM, SmartRefVector< TO > >, and RefTableBase< FROM, SmartRef< TO > >.

virtual StreamBuffer& DataObject::serialize ( StreamBuffer s  )  const [virtual, inherited]

Serialization mechanism: Serialize the object for writing.

Reimplemented in RefTableBase< FROM, MAPENTRY >, RefTableBase< FROM, SmartRefVector< TO > >, and RefTableBase< FROM, SmartRef< TO > >.

void DataObject::setRegistry ( IRegistry pRegistry  )  [inline, inherited]

Set pointer to Registry.

Definition at line 67 of file DataObject.h.

00067                                             {
00068     m_pRegistry = pRegistry;
00069   }

IRegistry* DataObject::registry (  )  const [inline, inherited]

Get pointer to Registry.

Definition at line 71 of file DataObject.h.

00071                                 {
00072     return m_pRegistry;
00073   }

LinkManager* DataObject::linkMgr (  )  const [inline, inherited]

Retrieve Link manager.

Definition at line 75 of file DataObject.h.

00075                                     {
00076     return m_pLinkMgr;
00077   }

unsigned char DataObject::version (  )  const [inline, inherited]

Retrieve version number of this object representation.

Definition at line 79 of file DataObject.h.

00079                                     {
00080     return m_version;
00081   }

void DataObject::setVersion ( unsigned char  vsn  )  [inline, inherited]

Set version number of this object representation.

Definition at line 83 of file DataObject.h.

00083                                         {
00084     m_version = vsn;
00085   }

unsigned long DataObject::refCount (  )  const [inline, inherited]

Return the refcount.

Definition at line 87 of file DataObject.h.

00087                                  {
00088     return m_refCount;
00089   }

virtual std::ostream& DataObject::fillStream ( std::ostream &  s  )  const [inline, virtual, inherited]

Fill the output stream (ASCII).

Reimplemented in ObjectList< TYPE >, and ObjectVector< TYPE >.

Definition at line 91 of file DataObject.h.

00091                                                         {
00092     s << "DataObject at " << std::hex << this;
00093     return s;
00094   }


Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  s,
const DataObject obj 
) [friend, inherited]

Output operator (ASCII).

Definition at line 96 of file DataObject.h.

00096                                                                          {
00097     return obj.fillStream(s);
00098   }


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:
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

Generated on Mon Apr 11 19:57:15 2011 for GaudiKernel by doxygen 1.4.7