| The Gaudi Framework v28r2-patches (bc4ad17a)

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

Classes | Public Types | Public Member Functions | Private Attributes | List of all members
GaudiUtils::Allocator< Type > Class Template Reference

Allocator. More...

`#include <GaudiKernel/Allocator.h>`

Collaboration diagram for GaudiUtils::Allocator< Type >:
[legend]

## Classes
struct | rebind

## Public Types
typedef Type | value_type
typedef size_t | size_type
typedef ptrdiff_t | difference_type
typedef Type * | pointer
typedef const Type * | const_pointer
typedef Type & | reference
typedef const Type & | const_reference

## Public Member Functions
| Allocator () throw ()
| Constructor. More...
| ~Allocator () throw ()
| destructor More...
Type * | MallocSingle ()
| Malloc and Free methods to be used when overloading new and delete operators in the client <Type> object. More...
void | FreeSingle (Type *anElement)
void | ResetStorage ()
| Returns allocated storage to the free store, resets allocator and page sizes. More...
size_t | GetAllocatedSize () const
| Returns the size of the total memory allocated. More...
template<class U >
| Allocator (const Allocator< U > &right) throw ()
| Copy constructor. More...
pointer | address (reference r) const
| Returns the address of values. More...
const_pointer | address (const_reference r) const
pointer | allocate (size_type n, void *=0)
| Allocates space for n elements of type Type, but does not initialise. More...
void | deallocate (pointer p, size_type n)
| Deallocates n elements of type Type, but doesn't destroy. More...
void | construct (pointer p, const Type &val)
| Initialises *p by val. More...
void | destroy (pointer p)
| Destroy *p but doesn't deallocate. More...
size_type | max_size () const throw ()
| Returns the maximum number of elements that can be allocated. More...

## Private Attributes
GaudiUtils::AllocatorPool | mem

## Detailed Description

### template<class Type>
class GaudiUtils::Allocator< Type >

Allocator.

The class is imported from Geant4 project

Date
  2006-02-10

Definition at line 71 of file Allocator.h.

## Member Typedef Documentation

template<class Type>

typedef const Type* GaudiUtils::Allocator< Type >::const_pointer

Definition at line 109 of file Allocator.h.

template<class Type>

typedef const Type& GaudiUtils::Allocator< Type >::const_reference

Definition at line 111 of file Allocator.h.

template<class Type>

typedef ptrdiff_t GaudiUtils::Allocator< Type >::difference_type

Definition at line 107 of file Allocator.h.

template<class Type>

typedef Type* GaudiUtils::Allocator< Type >::pointer

Definition at line 108 of file Allocator.h.

template<class Type>

typedef Type& GaudiUtils::Allocator< Type >::reference

Definition at line 110 of file Allocator.h.

template<class Type>

typedef size_t GaudiUtils::Allocator< Type >::size_type

Definition at line 106 of file Allocator.h.

template<class Type>

typedef Type GaudiUtils::Allocator< Type >::value_type

Definition at line 105 of file Allocator.h.

## Constructor & Destructor Documentation

template<class Type >

GaudiUtils::Allocator< Type >::Allocator | ( |  | ) |
throw | ( |
| ) |  |

Constructor.

Definition at line 185 of file Allocator.h.

186 : mem(sizeof(Type))
187 {
188 }
GaudiUtils::Allocator::mem
GaudiUtils::AllocatorPool mem
Definition: Allocator.h:166
Tuples::Type
Type
the list of available types for ntuples
Definition: TupleObj.h:79
template<class Type >

GaudiUtils::Allocator< Type >::~Allocator | ( |  | ) |
throw | ( |
| ) |  |

destructor

Definition at line 195 of file Allocator.h.

196 {
197 }
template<class Type>
template<class U >

GaudiUtils::Allocator< Type >::Allocator | ( | const Allocator< U > & | right | ) |
throw | ( |
| ) |  |
| inline

Copy constructor.

Definition at line 115 of file Allocator.h.

116 : mem(right.mem) {}
std::right
T right(T...args)
GaudiUtils::Allocator::mem
GaudiUtils::AllocatorPool mem
Definition: Allocator.h:166

## Member Function Documentation

template<class Type>

pointer GaudiUtils::Allocator< Type >::address | ( | reference | r | ) | const
| inline

Returns the address of values.

Definition at line 119 of file Allocator.h.

119 { return &r; }
template<class Type>

const_pointer GaudiUtils::Allocator< Type >::address | ( | const_reference | r | ) | const
| inline

Definition at line 120 of file Allocator.h.

120 { return &r; }
template<class Type>

pointer GaudiUtils::Allocator< Type >::allocate | ( | size_type | n,
|  | void * | = `0`
| ) |  |
| inline

Allocates space for n elements of type Type, but does not initialise.

Definition at line 123 of file Allocator.h.

124 {
125 // Allocates space for n elements of type Type, but does not initialise
126 //
127 Type* mem_alloc = 0;
128 if (n == 1)
129 mem_alloc = MallocSingle();
130 else
131 mem_alloc = static_cast<Type*>(::operator new(n*sizeof(Type)));
132 return mem_alloc;
133 }
GaudiUtils::Allocator::MallocSingle
Type * MallocSingle()
Malloc and Free methods to be used when overloading new and delete operators in the client <Type> obj...
Definition: Allocator.h:204
GaudiPluginService.cpluginsvc.n
n
Definition: cpluginsvc.py:217
Tuples::Type
Type
the list of available types for ntuples
Definition: TupleObj.h:79
template<class Type>

void GaudiUtils::Allocator< Type >::construct | ( | pointer | p,
|  | const Type & | val
| ) |  |
| inline

Initialises *p by val.

Definition at line 148 of file Allocator.h.

148 { new((void*)p) Type(val); }
Tuples::Type
Type
the list of available types for ntuples
Definition: TupleObj.h:79
template<class Type>

void GaudiUtils::Allocator< Type >::deallocate | ( | pointer | p,
|  | size_type | n
| ) |  |
| inline

Deallocates n elements of type Type, but doesn't destroy.

Definition at line 136 of file Allocator.h.

137 {
138 // Deallocates n elements of type Type, but doesn't destroy
139 //
140 if (n == 1)
141 FreeSingle(p);
142 else
143 ::operator delete((void*)p);
144 return;
145 }
GaudiUtils::Allocator::FreeSingle
void FreeSingle(Type *anElement)
Definition: Allocator.h:214
GaudiPluginService.cpluginsvc.n
n
Definition: cpluginsvc.py:217
template<class Type>

void GaudiUtils::Allocator< Type >::destroy | ( | pointer | p | ) |
| inline

Destroy *p but doesn't deallocate.

Definition at line 150 of file Allocator.h.

150 { p->~Type(); }
template<class Type >

void GaudiUtils::Allocator< Type >::FreeSingle | ( | Type * | anElement | ) |
| inline

Definition at line 214 of file Allocator.h.

215 {
216 mem.Free(anElement);
217 return;
218 }
GaudiUtils::Allocator::mem
GaudiUtils::AllocatorPool mem
Definition: Allocator.h:166
GaudiUtils::AllocatorPool::Free
void Free(void *b)
Return an element back to the pool.
Definition: AllocatorPool.h:137
template<class Type >

size_t GaudiUtils::Allocator< Type >::GetAllocatedSize | ( |  | ) | const
| inline

Returns the size of the total memory allocated.

Definition at line 238 of file Allocator.h.

239 {
240 return mem.Size();
241 }
GaudiUtils::AllocatorPool::Size
unsigned int Size() const
Return storage size.
Definition: AllocatorPool.h:149
GaudiUtils::Allocator::mem
GaudiUtils::AllocatorPool mem
Definition: Allocator.h:166
template<class Type >

Type * GaudiUtils::Allocator< Type >::MallocSingle | ( |  | ) |
| inline

Malloc and Free methods to be used when overloading new and delete operators in the client <Type> object.

Definition at line 204 of file Allocator.h.

205 {
206 return static_cast<Type*>(mem.Alloc());
207 }
GaudiUtils::Allocator::mem
GaudiUtils::AllocatorPool mem
Definition: Allocator.h:166
GaudiUtils::AllocatorPool::Alloc
void * Alloc()
Allocate one element.
Definition: AllocatorPool.h:124
Tuples::Type
Type
the list of available types for ntuples
Definition: TupleObj.h:79
template<class Type>

size_type GaudiUtils::Allocator< Type >::max_size | ( |  | ) | const
throw | ( |
| ) |  |
| inline

Returns the maximum number of elements that can be allocated.

Definition at line 153 of file Allocator.h.

154 {
155 // Returns the maximum number of elements that can be allocated
156 //
157 return 2147483647/sizeof(Type);
158 }
Tuples::Type
Type
the list of available types for ntuples
Definition: TupleObj.h:79
template<class Type >

void GaudiUtils::Allocator< Type >::ResetStorage | ( |  | ) |
| inline

Returns allocated storage to the free store, resets allocator and page sizes.

Note: contents in memory are lost using this call !

Definition at line 225 of file Allocator.h.

226 {
227 // Clear all allocated storage and return it to the free store
228 //
229 mem.Reset();
230 return;
231 }
GaudiUtils::Allocator::mem
GaudiUtils::AllocatorPool mem
Definition: Allocator.h:166
GaudiUtils::AllocatorPool::Reset
void Reset()
Return storage to the free store.
Definition: AllocatorPool.cpp:93

## Member Data Documentation

template<class Type>

GaudiUtils::AllocatorPool GaudiUtils::Allocator< Type >::mem
| private

Definition at line 166 of file Allocator.h.

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

- GaudiKernel/GaudiKernel/Allocator.h