OROCHI
 
Loading...
Searching...
No Matches
GxAllocatorFrame.h
Go to the documentation of this file.
1//===========================================================================
10//===========================================================================
11#pragma once
12
13GX_CORE_NAMESPACE_BEGIN()
14
15//===========================================================================
17//===========================================================================
19{
20 //-----------------------------------------------------------
22 //-----------------------------------------------------------
24private:
26 static constexpr GxMemory::ALIGNMENT ALLOCATE_ALIGNMENT = GxMemory::ALIGNMENT::_16;
27
28public:
29 GX_RTTI_CLASS(GxAllocatorFrame, GxAllocator)
30 // ClassBase継承クラス用禁止宣言
32
33
34 enum class ALLOCATE_TYPE
35 {
36 HEAD = 0,
37 TAIL
38 };
39
42 {
43 size_t _head;
44 size_t _tail;
45 };
46
49 {
50 ALL = 0,
51 HEAD,
52 TAIL
53 };
54
56 //-----------------------------------------------------------
58 //-----------------------------------------------------------
60protected:
62 GxAllocatorFrame(void) : _head(0), _tail(0){}
63public:
65 GxAllocatorFrame(GX_CSTR name, GxMemory::TYPE type, u32 size);
68
70 static GxAllocatorFrame* create(void* pAddress, u32 size);
72 static void destroy(GxAllocatorFrame*& pAllocator);
74 // create(),destroy(),, を繰り返すより
75 // create(),reset(),reset(),,, のように使用したほうが効率的
76 void reset(void* pAddress, u32 size);
77
79 //-----------------------------------------------------------
81 //-----------------------------------------------------------
83public:
84#if GX_DEBUG_NEW
86 void* allocateMemory(u32 type, u32 size, GX_CSTR filename, u32 line, GxMemory::ALIGNMENT alignment = ALLOCATE_ALIGNMENT) override;
88 void freeMemory(void* pAddress, GX_CSTR filename, u32 line) override;
89#else // GX_DEBUG_NEW
91 void* allocateMemory(u32 type, u32 size, GxMemory::ALIGNMENT alignment = ALLOCATE_ALIGNMENT) override;
93 void freeMemory(void* pAddress) override;
94#endif // GX_DEBUG_NEW
95
97 void freeMemoryHead(void);
99 void freeMemoryTail(void);
101 void freeMemoryAll(void);
102
104 void recordMemoryState(GxMemoryStateHandle& record);
106 b32 returnMemoryState(const GxMemoryStateHandle& record, MEMORYSTATE_RETURN_TYPE type = MEMORYSTATE_RETURN_TYPE::ALL);
108 size_t getUsedSizeHead(void) const;
109
110#if GX_DEVELOP
112 void printInformation(void) override;
113#endif // GX_DEVELOP
114
116 //-----------------------------------------------------------
118 //-----------------------------------------------------------
120public:
122 u32 getAllocatableMaxSize(GxMemory::ALIGNMENT alignment = ALLOCATE_ALIGNMENT);
123
125 //-----------------------------------------------------------
127 //-----------------------------------------------------------
129private:
130 GxCriticalSection _criticalSection;
131 size_t _head;
132 size_t _tail;
133
135};
136
137GX_CORE_NAMESPACE_END()
#define GX_PROHIBIT_CLASS_BASE(__CLASS__)
GxClassBase継承の禁止宣言
Definition GxBase.h:240
フレームアロケータ
Definition GxAllocatorFrame.h:19
MEMORYSTATE_RETURN_TYPE
メモリ確保状態復帰タイプ
Definition GxAllocatorFrame.h:49
ALLOCATE_TYPE
メモリ確保手法
Definition GxAllocatorFrame.h:35
GxAllocatorFrame(void)
デフォルトコンストラクタ (クラス外での使用禁止)
Definition GxAllocatorFrame.h:62
~GxAllocatorFrame(void)
デストラクタ
Definition GxAllocatorFrame.h:67
メモリアロケータ基底クラス
Definition GxAllocator.h:82
クリティカルセクションクラス
Definition GxThread.h:20
ALIGNMENT
メモリアライメント定義
Definition GxMemory.h:51
@ _16
16byteアライメント
Definition GxMemory.h:54
TYPE
割り当てメモリ種別
Definition GxMemory.h:30
メモリ確保状態保存情報ハンドル
Definition GxAllocatorFrame.h:42
size_t _head
先頭側保存アドレス値
Definition GxAllocatorFrame.h:43
size_t _tail
終端側保存アドレス値
Definition GxAllocatorFrame.h:44
32bitブーリアン
Definition GxDefine.h:173