gatelib  2.1
g_cont_common.h
1 #pragma once
2 
3 #include "g_common.h"
4 
5 #define G_EXC_RAISE_CONT(amessage) G_EXC_RAISE_MSG(g::cont::ContException,amessage)
6 
7 #ifndef NULL
8 #define NULL 0
9 #endif
10 
11 #define G_CONT_INDEX_NOT_VALID -1
12 
13 //determinates the size of the bits with the following formula: size = 2^rbits (1<<rbits)
14 #ifndef G_LST_PAGE_MASK_BITS
15 # define G_LST_PAGE_MASK_BITS 4
16 #endif
17 
18 #ifndef G_VECT_AL_DELTA_MASK_BITS
19 # define G_VECT_AL_DELTA_MASK_BITS 4
20 #endif
21 
22 namespace g
23 {
24 namespace cont
25 {
26 //define the exception type ContException
27 G_EXC_DEFINE(ContException,Exception);
28 
29  enum IterFrom_t { head , tail };
30 
31  class HeapAbstract;
32  class AllocationPolicyAbstract;
33 
34  //standard getter for ref implementation
35  typedef HeapAbstract* (*StandardHeapPolicyPf)();
36  //standard getter for ref implementation
37  typedef AllocationPolicyAbstract* (*StandardRefImplPolicyPf)();
38  typedef void (*MoveDataPolicyPf_t) ( const char* aFrom , char* aTo , size_t aSize );
39 
40  extern void G_LIB_ITEM move_data_default ( const char* aFrom , char* aTo , size_t aSize );
41 
42  // acts as a container of g::cont policies:
43  // a policy is a way to implement a standard, app-domain valid behaviour in a certain topic (heap,ref implementation)
44  class G_LIB_ITEM Policies
45  {
46  public:
47  static MoveDataPolicyPf_t move_DataPolicyPf;
48  static StandardRefImplPolicyPf standard_RefImplpolicyPf;
49  };
50 
51  //used by iterators for implemenenting data collection walking
52  template < class T > class positioner_abstract
53  {
54  public:
55  virtual ~positioner_abstract ( ) {}
56 
57  virtual int first() const = 0;
58  virtual int last() const = 0;
59  virtual void forward ( int& , unsigned int aInc ) const = 0;
60  virtual void backward ( int& , unsigned int aDec ) const = 0;
61  virtual bool isIn ( int ) const = 0;
62  virtual T* getPtr ( int ) const = 0;
63  };
64 
65  //Implements the behaviour in case of moving data from a location to another (new and old location can be overlapped)
66  template < class T > inline void move_data ( const T* aFrom , T* aTo , size_t aCardinality = 1 ) { (*Policies::move_DataPolicyPf) ( (char*)aFrom ,(char*)(aTo), sizeof(T)*aCardinality ); }
67  template <> inline void move_data ( const void* aFrom , void* aTo , size_t aSize ) { move_data<char>((char*)aFrom,(char*)aTo,aSize); }
68 
69 }//namespace g
70 }//namespace cont
71 
Definition: g_cont_common.h:44
#define G_EXC_DEFINE(aexctypename, abaseexctypename)
Definition: g_exception_macros.h:39
Definition: g.mthread.ThreadSimpleEvent.h:5
Definition: g_cont_common.h:52