gatelib  2.1
g_cont_AllocationPolicyMoveableAbstract.h
1 #pragma once
2 
3 #include "g_cont_HeapAbstract.h"
4 #include "g_cont_AllocationPolicyAbstract.h"
5 
6 namespace g
7 {
8 namespace cont
9 {
10 class G_LIB_ITEM MoveableDataPacketHeader
11 {
12 public:
13  virtual ~MoveableDataPacketHeader(){}
14  virtual int getCardinality ( ) const = 0;//-1 for refs
15  virtual int getNumRefs ( ) const = 0;
16  virtual void incNumRefs ( ) = 0;
17  virtual int decNumRefs ( ) = 0;
18  virtual void* getDataLocation( ) = 0;
19 };
20 
21 //MoveableMemPivotMarker and MoveableMemPivotMarker are supposed to have the same size
23 {
24  MoveableDataPacketHeader* moveableDataPacketHeaderP;
25 };
26 
28 {
29 public:
32 
33  virtual MoveableMemPivotMarker* reserveMarker ( ) = 0;
34  virtual void freeMarker ( MoveableMemPivotMarker* ) = 0;
35  // implement moving of moveable data packet (pointed by pivot)
36  virtual MoveableDataPacketHeader* resizeMoveableDataPacket ( MoveableDataPacketHeader* , size_t aTypeSize , size_t old_cardinality , size_t aCardinality ) = 0;
37  //override for implementing all allocator
38  virtual void compactAll ( ) = 0;
39  //-1 is for scalar types
40  virtual MoveableDataPacketHeader* instanciateMoveableDataPacket ( MoveableMemPivotMarker* pivot_marker , size_t type_size , int cardinality = -1 ) = 0;
41 
42  virtual int getNumRefs ( MemMarker* ) const;
43  virtual void incRef ( MemMarker* );
44  virtual int decRef ( MemMarker* );
45  virtual void* getRefDataLocation ( MemMarker* );
46  virtual void* getResizableDataLocation ( MemMarker* );
47  virtual MemMarker* reserveRef ( size_t ref_type_size );
48  //version for array (data ref)
49  virtual MemMarker* reserveResizableData ( size_t item_type_size , size_t set_cardinality );
50  virtual MemMarker* resizeResizableData ( MemMarker* , size_t aTypeSize , size_t old_cardinality , size_t aCardinality );
51  //ask the heap for freeing ref data
52  virtual void freeRef ( MemMarker* );
53  //ask the heap for freeing sizable data
54  virtual void freeResizableData ( MemMarker* );
55 
56 protected:
57  //override for implementing data moving
58  virtual void mCompactPivotLocation ( MoveableMemPivotMarker* ) = 0;
59 };
60 
61 }//namespace g
62 }//namespace cont
Definition: g_cont_AllocationPolicyMoveableAbstract.h:27
Definition: g_cont_AllocationPolicyAbstract.h:16
Definition: g.mthread.ThreadSimpleEvent.h:5
Definition: g_cont_AllocationPolicyMoveableAbstract.h:22
Definition: g_cont_HeapAbstract.h:20
Definition: g_cont_AllocationPolicyAbstract.h:13
Definition: g_cont_AllocationPolicyMoveableAbstract.h:10