The Gaudi Framework  master (ff829712)
Loading...
Searching...
No Matches
GaudiUtils::Allocator< Type > Class Template Reference

Allocator. More...

#include <GaudiKernel/Allocator.h>

Collaboration diagram for GaudiUtils::Allocator< Type >:

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.
 
 ~Allocator () throw ()
 destructor
 
Type * MallocSingle ()
 Malloc and Free methods to be used when overloading new and delete operators in the client <Type> object.
 
void FreeSingle (Type *anElement)
 
void ResetStorage ()
 Returns allocated storage to the free store, resets allocator and page sizes.
 
size_t GetAllocatedSize () const
 Returns the size of the total memory allocated.
 
template<class U>
 Allocator (const Allocator< U > &right) throw ()
 Copy constructor.
 
pointer address (reference r) const
 Returns the address of values.
 
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.
 
void deallocate (pointer p, size_type n)
 Deallocates n elements of type Type, but doesn't destroy.
 
void construct (pointer p, const Type &val)
 Initialises *p by val.
 
void destroy (pointer p)
 Destroy *p but doesn't deallocate.
 
size_type max_size () const throw ()
 Returns the maximum number of elements that can be allocated.
 

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 69 of file Allocator.h.

Member Typedef Documentation

◆ const_pointer

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

Definition at line 104 of file Allocator.h.

◆ const_reference

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

Definition at line 106 of file Allocator.h.

◆ difference_type

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

Definition at line 102 of file Allocator.h.

◆ pointer

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

Definition at line 103 of file Allocator.h.

◆ reference

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

Definition at line 105 of file Allocator.h.

◆ size_type

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

Definition at line 101 of file Allocator.h.

◆ value_type

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

Definition at line 100 of file Allocator.h.

Constructor & Destructor Documentation

◆ Allocator() [1/2]

template<class Type>
GaudiUtils::Allocator< Type >::Allocator ( )
throw ( )

Constructor.

Definition at line 177 of file Allocator.h.

177: mem( sizeof( Type ) ) {}
GaudiUtils::AllocatorPool mem
Definition Allocator.h:158

◆ ~Allocator()

template<class Type>
GaudiUtils::Allocator< Type >::~Allocator ( )
throw ( )
inline

destructor

Definition at line 74 of file Allocator.h.

74{}

◆ Allocator() [2/2]

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

Copy constructor.

Definition at line 110 of file Allocator.h.

110: mem( right.mem ) {}

Member Function Documentation

◆ address() [1/2]

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

Definition at line 114 of file Allocator.h.

114{ return &r; }

◆ address() [2/2]

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

Returns the address of values.

Definition at line 113 of file Allocator.h.

113{ return &r; }

◆ allocate()

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 117 of file Allocator.h.

117 {
118 // Allocates space for n elements of type Type, but does not initialise
119 //
120 Type* mem_alloc = 0;
121 if ( n == 1 )
123 else
124 mem_alloc = static_cast<Type*>( ::operator new( n * sizeof( Type ) ) );
125 return mem_alloc;
126 }
Type * MallocSingle()
Malloc and Free methods to be used when overloading new and delete operators in the client <Type> obj...
Definition Allocator.h:184

◆ construct()

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

Initialises *p by val.

Definition at line 140 of file Allocator.h.

140{ new ( (void*)p ) Type( val ); }

◆ deallocate()

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 129 of file Allocator.h.

129 {
130 // Deallocates n elements of type Type, but doesn't destroy
131 //
132 if ( n == 1 )
133 FreeSingle( p );
134 else
135 ::operator delete( (void*)p );
136 return;
137 }
void FreeSingle(Type *anElement)
Definition Allocator.h:193

◆ destroy()

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

Destroy *p but doesn't deallocate.

Definition at line 142 of file Allocator.h.

142{ p->~Type(); }

◆ FreeSingle()

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

Definition at line 193 of file Allocator.h.

193 {
194 mem.Free( anElement );
195 return;
196}

◆ GetAllocatedSize()

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

Returns the size of the total memory allocated.

Definition at line 215 of file Allocator.h.

215 {
216 return mem.Size();
217}

◆ MallocSingle()

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 184 of file Allocator.h.

184 {
185 return static_cast<Type*>( mem.Alloc() );
186}

◆ max_size()

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 145 of file Allocator.h.

145 {
146 // Returns the maximum number of elements that can be allocated
147 //
148 return 2147483647 / sizeof( Type );
149 }

◆ ResetStorage()

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 203 of file Allocator.h.

203 {
204 // Clear all allocated storage and return it to the free store
205 //
206 mem.Reset();
207 return;
208}

Member Data Documentation

◆ mem

template<class Type>
GaudiUtils::AllocatorPool GaudiUtils::Allocator< Type >::mem
private

Definition at line 158 of file Allocator.h.


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