![]() |
|
|
Generated: 18 Jul 2008 |
#include <GaudiKernel/TransientFastContainer.h>
Inheritance diagram for TransientFastContainer< T, CLEANER >:


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.
Definition at line 83 of file TransientFastContainer.h.
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 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_pointer | 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_pointer | 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. | |
| typedef T TransientFastContainer< T, CLEANER >::contained_type |
Definition at line 86 of file TransientFastContainer.h.
| typedef contained_type* TransientFastContainer< T, CLEANER >::value_type |
Definition at line 87 of file TransientFastContainer.h.
| typedef value_type TransientFastContainer< T, CLEANER >::pointer |
Definition at line 89 of file TransientFastContainer.h.
| typedef const value_type TransientFastContainer< T, CLEANER >::const_pointer |
Definition at line 90 of file TransientFastContainer.h.
| typedef value_type TransientFastContainer< T, CLEANER >::reference |
Definition at line 92 of file TransientFastContainer.h.
| typedef const value_type TransientFastContainer< T, CLEANER >::const_reference |
Definition at line 93 of file TransientFastContainer.h.
| typedef std::vector<value_type> TransientFastContainer< T, CLEANER >::storage_type |
Definition at line 95 of file TransientFastContainer.h.
| typedef storage_type::size_type TransientFastContainer< T, CLEANER >::size_type |
Definition at line 97 of file TransientFastContainer.h.
| typedef storage_type::iterator TransientFastContainer< T, CLEANER >::iterator |
Definition at line 99 of file TransientFastContainer.h.
| typedef storage_type::const_iterator TransientFastContainer< T, CLEANER >::const_iterator |
Definition at line 100 of file TransientFastContainer.h.
| typedef CLEANER TransientFastContainer< T, CLEANER >::cleaner_type |
Definition at line 102 of file TransientFastContainer.h.
| 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.
References TransientFastContainer< T, CLEANER >::clear(), TransientFastContainer< T, CLEANER >::m_storage, TransientFastContainer< T, CLEANER >::New(), and std::vector< _Tp, _Alloc >::reserve().
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 }
| TransientFastContainer< T, CLEANER >::~TransientFastContainer | ( | ) | [virtual] |
Delete all the recorded objects.
Definition at line 202 of file TransientFastContainer.h.
References TransientFastContainer< T, CLEANER >::free().
00203 { 00204 free(); 00205 }
| 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.
References std::vector< _Tp, _Alloc >::begin(), TransientFastContainer< T, CLEANER >::m_counter, TransientFastContainer< T, CLEANER >::m_end, and TransientFastContainer< T, CLEANER >::m_storage.
Referenced by TransientFastContainer< T, CLEANER >::TransientFastContainer().
| void TransientFastContainer< T, CLEANER >::free | ( | ) | [virtual] |
Delete all the contained objects to free memory.
Implements TransientFastContainerBase.
Definition at line 215 of file TransientFastContainer.h.
References std::vector< _Tp, _Alloc >::begin(), std::vector< _Tp, _Alloc >::clear(), std::vector< _Tp, _Alloc >::end(), TransientFastContainer< T, CLEANER >::m_counter, TransientFastContainer< T, CLEANER >::m_current_size, TransientFastContainer< T, CLEANER >::m_end, and TransientFastContainer< T, CLEANER >::m_storage.
Referenced by TransientFastContainer< T, CLEANER >::~TransientFastContainer().
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 }
| 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); }
| 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.
References TransientFastContainer< T, CLEANER >::i_new(), TransientFastContainer< T, CLEANER >::m_cleaner, TransientFastContainer< T, CLEANER >::m_counter, TransientFastContainer< T, CLEANER >::m_current_size, and TransientFastContainer< T, CLEANER >::m_end.
Referenced by TransientFastContainer< T, CLEANER >::TransientFastContainer().
00125 { return ( m_counter++ < m_current_size ) ? m_cleaner(*(m_end++)) : i_new(); }
| 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.
References TransientFastContainer< T, CLEANER >::i_new(), TransientFastContainer< T, CLEANER >::m_cleaner, TransientFastContainer< T, CLEANER >::m_counter, TransientFastContainer< T, CLEANER >::m_current_size, and TransientFastContainer< T, CLEANER >::m_end.
00129 { return ( m_counter++ < m_current_size ) ? m_cleaner(*(m_end++),rhs) : i_new(rhs); }
| 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.
References TransientFastContainer< T, CLEANER >::i_new(), TransientFastContainer< T, CLEANER >::m_cleaner, TransientFastContainer< T, CLEANER >::m_counter, TransientFastContainer< T, CLEANER >::m_current_size, and TransientFastContainer< T, CLEANER >::m_end.
00134 { return ( m_counter++ < m_current_size ) ? m_cleaner.destruct(*(m_end++)) : m_cleaner.destruct(i_new()); }
| iterator TransientFastContainer< T, CLEANER >::begin | ( | ) | [inline] |
Iterator pointing to the first object of the container.
Definition at line 137 of file TransientFastContainer.h.
References std::vector< _Tp, _Alloc >::begin(), and TransientFastContainer< T, CLEANER >::m_storage.
| 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.
References std::vector< _Tp, _Alloc >::begin(), and TransientFastContainer< T, CLEANER >::m_storage.
| iterator TransientFastContainer< T, CLEANER >::end | ( | ) | [inline] |
Iterator pointing after the last used object in the container.
Definition at line 142 of file TransientFastContainer.h.
References TransientFastContainer< T, CLEANER >::m_end.
00142 { return m_end; }
| 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.
References TransientFastContainer< T, CLEANER >::m_end.
00144 { return m_end; }
| 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.
References TransientFastContainer< T, CLEANER >::m_counter.
Referenced by TransientFastContainer< T, CLEANER >::operator[]().
00147 { return m_counter; }
| 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.
References TransientFastContainer< T, CLEANER >::m_storage, and TransientFastContainer< T, CLEANER >::size().
Referenced by TransientFastContainer< T, CLEANER >::at().
00151 { return (index < size()) ? m_storage[index] : throw std::out_of_range("index out of range"), (pointer)NULL; }
| const_pointer 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.
References TransientFastContainer< T, CLEANER >::m_storage, and TransientFastContainer< T, CLEANER >::size().
00154 { return (index < size()) ? m_storage[index] : throw std::out_of_range("index out of range"), (const_pointer)NULL; }
| pointer TransientFastContainer< T, CLEANER >::at | ( | size_type | index | ) | [inline] |
Same as operator[]().
Definition at line 157 of file TransientFastContainer.h.
References TransientFastContainer< T, CLEANER >::operator[]().
00157 { return operator[] (index); }
| const_pointer TransientFastContainer< T, CLEANER >::at | ( | size_type | index | ) | const [inline] |
Same as operator[]() const.
Definition at line 159 of file TransientFastContainer.h.
References TransientFastContainer< T, CLEANER >::operator[]().
00159 { return operator[] (index); }
| 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.
References std::vector< _Tp, _Alloc >::end(), TransientFastContainer< T, CLEANER >::m_current_size, TransientFastContainer< T, CLEANER >::m_end, TransientFastContainer< T, CLEANER >::m_storage, and std::vector< _Tp, _Alloc >::push_back().
Referenced by TransientFastContainer< T, CLEANER >::Add(), TransientFastContainer< T, CLEANER >::New(), and TransientFastContainer< T, CLEANER >::NewPointer().
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 }
| 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.
References std::vector< _Tp, _Alloc >::end(), TransientFastContainer< T, CLEANER >::m_current_size, TransientFastContainer< T, CLEANER >::m_end, TransientFastContainer< T, CLEANER >::m_storage, and std::vector< _Tp, _Alloc >::push_back().
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 }
size_type TransientFastContainer< T, CLEANER >::m_counter [private] |
Internal counter.
Definition at line 170 of file TransientFastContainer.h.
Referenced by TransientFastContainer< T, CLEANER >::Add(), TransientFastContainer< T, CLEANER >::clear(), TransientFastContainer< T, CLEANER >::free(), TransientFastContainer< T, CLEANER >::New(), TransientFastContainer< T, CLEANER >::NewPointer(), and TransientFastContainer< T, CLEANER >::size().
size_type TransientFastContainer< T, CLEANER >::m_current_size [private] |
Number of already allocated objects.
Definition at line 173 of file TransientFastContainer.h.
Referenced by TransientFastContainer< T, CLEANER >::Add(), TransientFastContainer< T, CLEANER >::free(), TransientFastContainer< T, CLEANER >::i_new(), TransientFastContainer< T, CLEANER >::New(), and TransientFastContainer< T, CLEANER >::NewPointer().
storage_type TransientFastContainer< T, CLEANER >::m_storage [private] |
Repository of allocated objects.
Definition at line 176 of file TransientFastContainer.h.
Referenced by TransientFastContainer< T, CLEANER >::begin(), TransientFastContainer< T, CLEANER >::clear(), TransientFastContainer< T, CLEANER >::free(), TransientFastContainer< T, CLEANER >::i_new(), TransientFastContainer< T, CLEANER >::operator[](), and TransientFastContainer< T, CLEANER >::TransientFastContainer().
iterator TransientFastContainer< T, CLEANER >::m_end [private] |
Iterator that is returned by end().
Definition at line 179 of file TransientFastContainer.h.
Referenced by TransientFastContainer< T, CLEANER >::Add(), TransientFastContainer< T, CLEANER >::clear(), TransientFastContainer< T, CLEANER >::end(), TransientFastContainer< T, CLEANER >::free(), TransientFastContainer< T, CLEANER >::i_new(), TransientFastContainer< T, CLEANER >::New(), and TransientFastContainer< T, CLEANER >::NewPointer().
cleaner_type TransientFastContainer< T, CLEANER >::m_cleaner [private] |
Instance of the class that cleans new objects.
Definition at line 182 of file TransientFastContainer.h.
Referenced by TransientFastContainer< T, CLEANER >::Add(), TransientFastContainer< T, CLEANER >::New(), and TransientFastContainer< T, CLEANER >::NewPointer().