OGLplus  (0.59.0) a C++ wrapper for rendering APIs

storage_caps.hpp
Go to the documentation of this file.
1 #ifndef EAGINE_ECS_STORAGE_CAPS_HPP
9 #define EAGINE_ECS_STORAGE_CAPS_HPP
10 
11 #include "../bitfield.hpp"
12 #include "../reflect/map_enumerators.hpp"
13 
14 namespace eagine::ecs {
15 //------------------------------------------------------------------------------
16 enum class storage_cap_bit : unsigned short {
17  hide = 1U << 0U,
18  copy = 1U << 1U,
19  swap = 1U << 2U,
20  store = 1U << 3U,
21  remove = 1U << 4U,
22  modify = 1U << 5U
23 };
24 //------------------------------------------------------------------------------
25 template <typename Selector>
26 constexpr auto
27 enumerator_mapping(type_identity<storage_cap_bit>, Selector) noexcept {
28  return enumerator_map_type<storage_cap_bit, 6>{
29  {{"hide", storage_cap_bit::hide},
30  {"copy", storage_cap_bit::copy},
31  {"swap", storage_cap_bit::swap},
32  {"store", storage_cap_bit::store},
33  {"remove", storage_cap_bit::remove},
34  {"modify", storage_cap_bit::modify}}};
35 }
36 //------------------------------------------------------------------------------
37 static inline auto operator|(storage_cap_bit a, storage_cap_bit b) noexcept
38  -> bitfield<storage_cap_bit> {
39  return {a, b};
40 }
41 //------------------------------------------------------------------------------
42 class storage_caps : public bitfield<storage_cap_bit> {
43 private:
44  using _base = bitfield<storage_cap_bit>;
45 
46 public:
47  storage_caps() noexcept = default;
48 
49  storage_caps(bitfield<storage_cap_bit> base)
50  : _base(base) {}
51 
52  auto can_hide() const noexcept -> bool {
53  return has(storage_cap_bit::hide);
54  }
55 
56  auto can_copy() const noexcept -> bool {
57  return has(storage_cap_bit::hide);
58  }
59 
60  auto can_swap() const noexcept -> bool {
61  return has(storage_cap_bit::hide);
62  }
63 
64  auto can_remove() const noexcept -> bool {
65  return has(storage_cap_bit::remove);
66  }
67 
68  auto can_store() const noexcept -> bool {
69  return has(storage_cap_bit::store);
70  }
71 
72  auto can_modify() const noexcept -> bool {
73  return has(storage_cap_bit::modify);
74  }
75 };
76 //------------------------------------------------------------------------------
77 } // namespace eagine::ecs
78 
79 #endif // EAGINE_ECS_STORAGE_CAPS_HPP
constexpr auto has(bit_type bit) const noexcept
Tests if the specified bit is set.
Definition: bitfield.hpp:70

Copyright © 2015-2021 Matúš Chochlík.
<chochlik -at -gmail.com>
Documentation generated on Tue Apr 13 2021 by Doxygen (version 1.8.17).