diff options
Diffstat (limited to 'src/handle-fwd.hpp')
-rw-r--r-- | src/handle-fwd.hpp | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/handle-fwd.hpp b/src/handle-fwd.hpp new file mode 100644 index 00000000..919461f5 --- /dev/null +++ b/src/handle-fwd.hpp @@ -0,0 +1,36 @@ +#pragma once + +namespace floormat::Handle { + +template<typename Obj, uint32_t PageSize> struct Item; + +template<typename OBJ, uint32_t PAGE_SIZE> +struct Handle +{ + uint32_t index = (uint32_t)-1; + uint32_t counter = 0; + +#if 0 + using Obj = OBJ; + static constexpr auto PageSize = PAGE_SIZE; +#endif + + const OBJ& get() const; + OBJ& get(); + + bool operator==(const Handle& other) const noexcept; + + explicit operator bool() const noexcept; + +private: + static Item<OBJ, PAGE_SIZE>& get_from_pool(uint32_t index, uint32_t counter); +}; + +} // namespace floormat::Handle + +namespace floormat { + +template<typename Obj, uint32_t PageSize> +using handle = struct Handle::Handle<Obj, PageSize>; + +} // namespace floormat |