MGL(Win32)
読み取り中…
検索中…
一致する文字列を見つけられません
mgl_memory_allocator.h
[詳解]
1// SPDX-License-Identifier: Zlib
2/* ------------------------------------------------------------------------- */
9/* ------------------------------------------------------------------------- */
10
11#ifndef INCGUARD_MGL_MEMORY_ALLOCATOR_H_1651231310
12#define INCGUARD_MGL_MEMORY_ALLOCATOR_H_1651231310
13
14#include <cstddef>
15#include <cstdint>
16
18
19namespace MGL::Memory
20{
21
23enum class AllocatorType : uint32_t;
24
25/* ------------------------------------------------------------------------- */
31/* ------------------------------------------------------------------------- */
32constexpr AllocatorType MakeAllocatorType(const char *key) noexcept
33{
34 return static_cast<AllocatorType>(Hash::FNV1a(key));
35}
36
38constexpr AllocatorType kInvalidAllocatorType = MakeAllocatorType("MGL-InvalidAllocator");
39
42{
43public:
44 virtual ~Allocator() = default;
45
46 /* ------------------------------------------------------------------------- */
52 /* ------------------------------------------------------------------------- */
53 [[nodiscard]] virtual AllocatorType GetType() const noexcept = 0;
54
55 /* ------------------------------------------------------------------------- */
61 /* ------------------------------------------------------------------------- */
62 virtual bool Initialize() noexcept = 0;
63
64 /* ------------------------------------------------------------------------- */
70 /* ------------------------------------------------------------------------- */
71 [[nodiscard]] virtual bool IsInitialized() const noexcept = 0;
72
73 /* ------------------------------------------------------------------------- */
79 /* ------------------------------------------------------------------------- */
80 [[nodiscard]] virtual void *Allocate(size_t size) noexcept = 0;
81
82 /* ------------------------------------------------------------------------- */
87 /* ------------------------------------------------------------------------- */
88 virtual void Deallocate(void *buffer) noexcept = 0;
89
90 /* ------------------------------------------------------------------------- */
99 /* ------------------------------------------------------------------------- */
100 virtual bool GetSizeInfo(size_t &dest, uint32_t key, uint32_t arg) noexcept = 0;
101};
102} // namespace MGL::Memory
103
104#endif // INCGUARD_MGL_MEMORY_ALLOCATOR_H_1651231310
105
106// vim: et ts=4 sw=4 sts=4
メモリアロケータインターフェース
Definition mgl_memory_allocator.h:42
virtual void * Allocate(size_t size) noexcept=0
アロケート
virtual void Deallocate(void *buffer) noexcept=0
デアロケート
virtual bool GetSizeInfo(size_t &dest, uint32_t key, uint32_t arg) noexcept=0
サイズ情報を取得
virtual bool Initialize() noexcept=0
初期化処理
virtual bool IsInitialized() const noexcept=0
初期化状態を取得
virtual AllocatorType GetType() const noexcept=0
このアロケータを表す値を取得
MGL FNV-1aハッシュ計算関数
constexpr AllocatorType kInvalidAllocatorType
無効なアロケータを表す値
Definition mgl_memory_allocator.h:38
constexpr AllocatorType MakeAllocatorType(const char *key) noexcept
AllocatorTypeを生成するための定数式
Definition mgl_memory_allocator.h:32