Flecs
v4.1
A fast entity component system (ECS) for C & C++
Toggle main menu visibility
Loading...
Searching...
No Matches
builder.hpp
Go to the documentation of this file.
1
7
8
#pragma once
9
10
namespace
flecs {
11
namespace
_
{
12
13
// Macros for template types so we don't go cross-eyed.
14
#define FLECS_TBUILDER template<typename ... Components> class
15
#define FLECS_IBUILDER template<typename IBase, typename ... Components> class
16
17
template
<FLECS_TBUILDER T,
typename
TDesc,
typename
Base, FLECS_IBUILDER IBuilder,
typename
... Components>
18
struct
builder : IBuilder<Base, Components ...>
19
{
20
using
IBase = IBuilder<Base, Components ...>;
21
22
public
:
23
builder(
flecs::world_t
*
world
)
24
: IBase(&desc_)
25
, desc_{}
26
, world_(
world
) { }
27
28
builder(
const
builder& f)
29
: IBase(&desc_, f.term_index_)
30
{
31
world_ = f.world_;
32
desc_ = f.desc_;
33
}
34
35
builder(builder&& f) noexcept
36
: builder<T, TDesc, Base, IBuilder, Components...>(f) { }
37
38
operator
TDesc*() {
39
return
&desc_;
40
}
41
42
operator
const
TDesc*()
const
{
43
return
&desc_;
44
}
45
46
T<Components ...> build()
const
{
47
return
T<Components...>(world_, *
static_cast<
const
Base*
>
(
this
));
48
}
49
50
protected
:
51
flecs::world_t
* world_v()
override
{
return
world_; }
52
TDesc desc_;
53
flecs::world_t
*world_;
54
};
55
56
#undef FLECS_TBUILDER
57
#undef FLECS_IBUILDER
58
59
}
// namespace _
60
}
// namespace flecs
flecs::world_t
ecs_world_t world_t
World type.
Definition
c_types.hpp:18
flecs::_
Int to enum.
Definition
component.hpp:18
flecs::world
The world.
Definition
world.hpp:246