neoGFX
Cross-platform C++ app/game engine
i_component_data.hpp
Go to the documentation of this file.
1 // i_component_data.hpp
2 /*
3  neogfx C++ GUI Library
4  Copyright (c) 2018 Leigh Johnston. All Rights Reserved.
5 
6  This program is free software: you can redistribute it and / or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10 
11  This program is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19 
20 #pragma once
21 
22 #include <neogfx/neogfx.hpp>
24 #include <neogfx/game/ecs_ids.hpp>
25 
26 namespace neogfx::game
27 {
28  template<class _Ty>
29  using ecs_data_type_t = std::remove_cv_t<std::remove_reference_t<_Ty>>;
30 
31  typedef vec3u32 face;
32  typedef std::vector<face> faces;
33 
34  class i_ecs;
35 
36  enum class component_data_field_type : uint32_t
37  {
38  Invalid = 0x00000000,
39  Bool = 0x00000001,
40  Int8 = 0x00000002,
41  Uint8 = 0x00000003,
42  Int16 = 0x00000004,
43  Uint16 = 0x00000005,
44  Int32 = 0x00000006,
45  Uint32 = 0x00000007,
46  Int64 = 0x00000008,
47  Uint64 = 0x00000009,
48  Float32 = 0x0000000A,
49  Float64 = 0x0000000B,
50  Scalar = Float64,
51  BasicVec2 = 0x00000100,
52  BasicVec3 = 0x00000200,
53  BasicVec4 = 0x00000300,
54  Vec2 = BasicVec2 | Float64,
58  Face = Triangle,
59  BasicMat22 = 0x00000400,
60  BasicMat33 = 0x00000500,
61  BasicMat44 = 0x00000600,
62  Mat22 = BasicMat22 | Float64,
65  Aabb = 0x00001000,
66  Aabb2d = 0x00002000,
67  String = 0x00010000,
68  Enum = 0x000B0000,
69  Uuid = 0x000C0000,
70  Id = 0x000D0000,
71  ComponentData = 0x000E0000,
72  Optional = 0x01000000,
73  Array = 0x02000000,
74  Shared = 0x04000000,
75  Internal = 0x80000000,
76  };
77 
79  {
80  return static_cast<component_data_field_type>(static_cast<uint32_t>(aLhs) | static_cast<uint32_t>(aRhs));
81  }
82 
84  {
85  return static_cast<component_data_field_type>(static_cast<uint32_t>(aLhs) & static_cast<uint32_t>(aRhs));
86  }
87 
89  {
90  return aLhs = static_cast<component_data_field_type>(static_cast<uint32_t>(aLhs) | static_cast<uint32_t>(aRhs));
91  }
92 
94  {
95  return aLhs = static_cast<component_data_field_type>(static_cast<uint32_t>(aLhs) & static_cast<uint32_t>(aRhs));
96  }
97 
99  {
100  struct meta
101  {
102  struct invalid_field_index : std::logic_error { invalid_field_index() : std::logic_error("neogfx::game::i_component_data::meta::invalid_field_index") {} };
103 
104  static neolib::uuid field_type_id(uint32_t)
105  {
106  return neolib::uuid{};
107  }
108 
109  static constexpr bool has_handles = false;
110  static constexpr bool has_updater = false;
111  };
112  };
113 }
std::remove_cv_t< std::remove_reference_t< _Ty > > ecs_data_type_t
std::vector< face > faces
constexpr component_data_field_type operator|(component_data_field_type aLhs, component_data_field_type aRhs)
constexpr component_data_field_type operator &(component_data_field_type aLhs, component_data_field_type aRhs)
constexpr component_data_field_type & operator|=(component_data_field_type &aLhs, component_data_field_type aRhs)
static neolib::uuid field_type_id(uint32_t)
constexpr component_data_field_type & operator &=(component_data_field_type &aLhs, component_data_field_type aRhs)