commore  1.0.6-SNAPSHOT
 All Classes Namespaces Functions Variables Typedefs Enumerations Pages
Allocator.h
1 //
2 // Copyright (c) 2006-2014 Raphael David / CANTOR
3 //
4 
5 
6 #ifndef CMR_ALLOCATOR_INCLUDED
7 #define CMR_ALLOCATOR_INCLUDED
8 
9 #include "Commore.h"
10 #include <new>
11 
12 namespace commore
13 {
14  class Dummy;
15 
19  template< typename T> class DefaultListAllocator
20  {
21  public:
22  typedef T value_type;
23  public:
29  static inline void constructor(Byte* data, const Byte* value)
30  {
31  if (value)
32  {
33  new(data) T(*(T*)value);
34  }
35  else
36  {
37  new(data) T();
38  }
39  }
44  static inline void destructor(Byte* data)
45  {
46  ((T*)data)->T::~T();
47  }
51  static inline int comparator(const Dummy& v1, const Dummy& v2)
52  {
53  const T& ov1 = (const T&)v1;
54  const T& ov2 = (const T&)v2;
55  return ov1 < ov2 ? - 1 : ov1 == ov2 ? 0 : 1;
56  }
57  };
58 
62  template< typename T> class CmrListAllocator
63  {
64  public:
65  static void CMREXD constructor(Byte* data, const Byte* value);
66  static void CMREXD destructor(Byte* data);
67  static int CMREXD comparator(const Dummy& v1, const Dummy& v2);
68  public:
69  typedef T value_type;
70  };
71 
75  template< typename T> class CmrScalarListAllocator
76  {
77  public:
78  typedef T value_type;
79  public:
80  static void CMREXD constructor(Byte* data, const Byte* value);
81  static void CMREXD destructor(Byte* data);
82  static int CMREXD comparator(const Dummy& v1, const Dummy& v2);
83  };
84 
88  typedef void (*FunctionConstructor)(Byte*, const Byte*);
89  typedef int (*FunctionComparator)(const Dummy&, const Dummy&);
90  typedef void (*FunctionDestructor)(Byte*);
91  typedef bool (*FunctionFilter)(const Long&);
92 }
93 #endif
Definition: Allocator.h:19
static void constructor(Byte *data, const Byte *value)
Definition: Allocator.h:29
Definition: Allocator.h:62
static void destructor(Byte *data)
Definition: Allocator.h:44
Definition: Allocator.h:75
static int comparator(const Dummy &v1, const Dummy &v2)
Definition: Allocator.h:51
unsigned char Byte
Definition: Type.h:64
void(* FunctionConstructor)(Byte *, const Byte *)
Definition: Allocator.h:88