Geant4  10.03.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4Allocator< Type > Class Template Reference

#include <G4Allocator.hh>

Inheritance diagram for G4Allocator< Type >:
Collaboration diagram for G4Allocator< 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

 G4Allocator () throw ()
 
 ~G4Allocator () throw ()
 
Type * MallocSingle ()
 
void FreeSingle (Type *anElement)
 
void ResetStorage ()
 
size_t GetAllocatedSize () const
 
int GetNoPages () const
 
size_t GetPageSize () const
 
void IncreasePageSize (unsigned int sz)
 
const char * GetPoolType () const
 
template<class U >
 G4Allocator (const G4Allocator< U > &right) throw ()
 
pointer address (reference r) const
 
const_pointer address (const_reference r) const
 
pointer allocate (size_type n, void *=0)
 
void deallocate (pointer p, size_type n)
 
void construct (pointer p, const Type &val)
 
void destroy (pointer p)
 
size_type max_size () const throw ()
 
- Public Member Functions inherited from G4AllocatorBase
 G4AllocatorBase ()
 
virtual ~G4AllocatorBase ()
 

Public Attributes

G4AllocatorPool mem
 

Detailed Description

template<class Type>
class G4Allocator< Type >

Definition at line 67 of file G4Allocator.hh.

Member Typedef Documentation

template<class Type>
typedef const Type* G4Allocator< Type >::const_pointer

Definition at line 110 of file G4Allocator.hh.

template<class Type>
typedef const Type& G4Allocator< Type >::const_reference

Definition at line 112 of file G4Allocator.hh.

template<class Type>
typedef ptrdiff_t G4Allocator< Type >::difference_type

Definition at line 108 of file G4Allocator.hh.

template<class Type>
typedef Type* G4Allocator< Type >::pointer

Definition at line 109 of file G4Allocator.hh.

template<class Type>
typedef Type& G4Allocator< Type >::reference

Definition at line 111 of file G4Allocator.hh.

template<class Type>
typedef size_t G4Allocator< Type >::size_type

Definition at line 107 of file G4Allocator.hh.

template<class Type>
typedef Type G4Allocator< Type >::value_type

Definition at line 106 of file G4Allocator.hh.

Constructor & Destructor Documentation

template<class Type >
G4Allocator< Type >::G4Allocator ( )
throw (
)

Definition at line 182 of file G4Allocator.hh.

183  : mem(sizeof(Type))
184 {
185  tname = typeid(Type).name();
186 }
const XML_Char * name
Definition: expat.h:151
G4AllocatorPool mem
Definition: G4Allocator.hh:160
template<class Type >
G4Allocator< Type >::~G4Allocator ( )
throw (
)

Definition at line 193 of file G4Allocator.hh.

194 {
195 }
template<class Type>
template<class U >
G4Allocator< Type >::G4Allocator ( const G4Allocator< U > &  right)
throw (
)
inline

Definition at line 114 of file G4Allocator.hh.

115  : mem(right.mem) {}
G4AllocatorPool mem
Definition: G4Allocator.hh:160

Member Function Documentation

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

Definition at line 118 of file G4Allocator.hh.

118 { return &r; }
template<class Type>
const_pointer G4Allocator< Type >::address ( const_reference  r) const
inline

Definition at line 119 of file G4Allocator.hh.

119 { return &r; }
template<class Type>
pointer G4Allocator< Type >::allocate ( size_type  n,
void = 0 
)
inline

Definition at line 122 of file G4Allocator.hh.

123  {
124  // Allocates space for n elements of type Type, but does not initialise
125  //
126  Type* mem_alloc = 0;
127  if (n == 1)
128  mem_alloc = MallocSingle();
129  else
130  mem_alloc = static_cast<Type*>(::operator new(n*sizeof(Type)));
131  return mem_alloc;
132  }
Type * MallocSingle()
Definition: G4Allocator.hh:202
const G4int n
template<class Type>
void G4Allocator< Type >::construct ( pointer  p,
const Type &  val 
)
inline

Definition at line 144 of file G4Allocator.hh.

144 { new((void*)p) Type(val); }
const char * p
Definition: xmltok.h:285
template<class Type>
void G4Allocator< Type >::deallocate ( pointer  p,
size_type  n 
)
inline

Definition at line 133 of file G4Allocator.hh.

134  {
135  // Deallocates n elements of type Type, but doesn't destroy
136  //
137  if (n == 1)
138  FreeSingle(p);
139  else
140  ::operator delete((void*)p);
141  return;
142  }
const char * p
Definition: xmltok.h:285
void FreeSingle(Type *anElement)
Definition: G4Allocator.hh:212
const G4int n
template<class Type>
void G4Allocator< Type >::destroy ( pointer  p)
inline

Definition at line 146 of file G4Allocator.hh.

146 { p->~Type(); }
const char * p
Definition: xmltok.h:285
template<class Type>
void G4Allocator< Type >::FreeSingle ( Type *  anElement)
inline

Definition at line 212 of file G4Allocator.hh.

213 {
214  mem.Free(anElement);
215  return;
216 }
G4AllocatorPool mem
Definition: G4Allocator.hh:160
void Free(void *b)

Here is the caller graph for this function:

template<class Type >
size_t G4Allocator< Type >::GetAllocatedSize ( ) const
inlinevirtual

Implements G4AllocatorBase.

Definition at line 236 of file G4Allocator.hh.

237 {
238  return mem.Size();
239 }
unsigned int Size() const
G4AllocatorPool mem
Definition: G4Allocator.hh:160
template<class Type >
int G4Allocator< Type >::GetNoPages ( ) const
inlinevirtual

Implements G4AllocatorBase.

Definition at line 246 of file G4Allocator.hh.

247 {
248  return mem.GetNoPages();
249 }
G4AllocatorPool mem
Definition: G4Allocator.hh:160
int GetNoPages() const
template<class Type >
size_t G4Allocator< Type >::GetPageSize ( ) const
inlinevirtual

Implements G4AllocatorBase.

Definition at line 256 of file G4Allocator.hh.

257 {
258  return mem.GetPageSize();
259 }
G4AllocatorPool mem
Definition: G4Allocator.hh:160
unsigned int GetPageSize() const
template<class Type >
const char * G4Allocator< Type >::GetPoolType ( ) const
inlinevirtual

Implements G4AllocatorBase.

Definition at line 277 of file G4Allocator.hh.

278 {
279  return tname;
280 }
template<class Type >
void G4Allocator< Type >::IncreasePageSize ( unsigned int  sz)
inlinevirtual

Implements G4AllocatorBase.

Definition at line 266 of file G4Allocator.hh.

267 {
268  ResetStorage();
269  mem.GrowPageSize(sz);
270 }
void GrowPageSize(unsigned int factor)
G4AllocatorPool mem
Definition: G4Allocator.hh:160
void ResetStorage()
Definition: G4Allocator.hh:223
template<class Type >
Type * G4Allocator< Type >::MallocSingle ( )
inline

Definition at line 202 of file G4Allocator.hh.

203 {
204  return static_cast<Type*>(mem.Alloc());
205 }
G4AllocatorPool mem
Definition: G4Allocator.hh:160

Here is the caller graph for this function:

template<class Type>
size_type G4Allocator< Type >::max_size ( ) const
throw (
)
inline

Definition at line 149 of file G4Allocator.hh.

150  {
151  // Returns the maximum number of elements that can be allocated
152  //
153  return 2147483647/sizeof(Type);
154  }
template<class Type >
void G4Allocator< Type >::ResetStorage ( )
inlinevirtual

Implements G4AllocatorBase.

Definition at line 223 of file G4Allocator.hh.

224 {
225  // Clear all allocated storage and return it to the free store
226  //
227  mem.Reset();
228  return;
229 }
G4AllocatorPool mem
Definition: G4Allocator.hh:160

Member Data Documentation

template<class Type>
G4AllocatorPool G4Allocator< Type >::mem

Definition at line 160 of file G4Allocator.hh.


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