neoGFX
Cross-platform C++ app/game engine
Loading...
Searching...
No Matches
i_component_data.hpp
Go to the documentation of this file.
1// i_component_data.hpp
2/*
3 * Copyright (c) 2018, 2020 Leigh Johnston.
4 *
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions are
9 * met:
10 *
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 *
14 * * Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 *
18 * * Neither the name of Leigh Johnston nor the names of any
19 * other contributors to this software may be used to endorse or
20 * promote products derived from this software without specific prior
21 * written permission.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
24 * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
25 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
26 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
27 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
28 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
29 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
30 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
31 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
32 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 */
35
36#pragma once
37
38#include <neolib/neolib.hpp>
41
42namespace neolib::ecs
43{
44 using namespace neolib::math;
45
46 template<class _Ty>
47 using ecs_data_type_t = std::remove_cv_t<std::remove_reference_t<_Ty>>;
48
49 class i_ecs;
50
51 enum class component_data_field_type : uint32_t
52 {
53 Invalid = 0x00000000,
54 Bool = 0x00000001,
55 Int8 = 0x00000002,
56 Uint8 = 0x00000003,
57 Int16 = 0x00000004,
58 Uint16 = 0x00000005,
59 Int32 = 0x00000006,
60 Uint32 = 0x00000007,
61 Int64 = 0x00000008,
62 Uint64 = 0x00000009,
63 Float32 = 0x0000000A,
64 Float64 = 0x0000000B,
66 BasicVec2 = 0x00000100,
67 BasicVec3 = 0x00000200,
68 BasicVec4 = 0x00000300,
88 Face = Triangle,
89 BasicMat22 = 0x00000400,
90 BasicMat33 = 0x00000500,
91 BasicMat44 = 0x00000600,
95 Aabb = 0x00001000,
96 Aabb2d = 0x00002000,
97 String = 0x00010000,
98 Enum = 0x000B0000,
99 Uuid = 0x000C0000,
100 Id = 0x000D0000,
101 SmallId = 0x000E0000,
102 ComponentData = 0x000F0000,
103 Optional = 0x01000000,
104 Array = 0x02000000,
105 Shared = 0x04000000,
106 Cache = 0x40000000,
107 Internal = 0x80000000,
108 };
109
111 {
112 return static_cast<component_data_field_type>(static_cast<uint32_t>(aLhs) | static_cast<uint32_t>(aRhs));
113 }
114
116 {
117 return static_cast<component_data_field_type>(static_cast<uint32_t>(aLhs) & static_cast<uint32_t>(aRhs));
118 }
119
121 {
122 return aLhs = static_cast<component_data_field_type>(static_cast<uint32_t>(aLhs) | static_cast<uint32_t>(aRhs));
123 }
124
126 {
127 return aLhs = static_cast<component_data_field_type>(static_cast<uint32_t>(aLhs) & static_cast<uint32_t>(aRhs));
128 }
129
131 {
132 struct meta
133 {
134 struct invalid_field_index : std::logic_error { invalid_field_index() : std::logic_error("ecs::i_component_data::meta::invalid_field_index") {} };
135
137 {
138 return neolib::uuid{};
139 }
140
141 static constexpr bool has_handles = false;
142 static constexpr bool has_updater = false;
143 };
144 };
145}
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)
constexpr component_data_field_type operator|(component_data_field_type aLhs, component_data_field_type aRhs)
std::remove_cv_t< std::remove_reference_t< _Ty > > ecs_data_type_t
static neolib::uuid field_type_id(uint32_t)