Flecs
v4.1
A fast entity component system (ECS) for C & C++
Toggle main menu visibility
Loading...
Searching...
No Matches
type.hpp
Go to the documentation of this file.
1
5
6
#pragma once
7
8
namespace
flecs {
9
17
21
struct
type
{
23
type
() : world_(nullptr), type_(nullptr) { }
24
30
type
(
world_t
*
world
,
const
type_t
*t)
31
: world_(
world
)
32
, type_(t) { }
33
38
flecs::string
str
()
const
{
39
return
flecs::string
(
ecs_type_str
(world_, type_));
40
}
41
46
int32_t
count
()
const
{
47
if
(!type_) {
48
return
0;
49
}
50
return
type_->count;
51
}
52
57
flecs::id_t
*
array
()
const
{
58
if
(!type_) {
59
return
nullptr
;
60
}
61
return
type_->array;
62
}
63
69
flecs::id
get
(int32_t index)
const
{
70
ecs_assert
(type_ !=
nullptr
,
ECS_INVALID_PARAMETER
,
nullptr
);
71
ecs_assert
(type_->count > index,
ECS_OUT_OF_RANGE
,
nullptr
);
72
if
(!type_) {
73
return
flecs::id
();
74
}
75
return
flecs::id
(world_, type_->array[index]);
76
}
77
79
const
flecs::id_t
*
begin
()
const
{
80
if
(type_ && type_->count) {
81
return
type_->array;
82
}
else
{
83
return
&empty_;
84
}
85
}
86
88
const
flecs::id_t
*
end
()
const
{
89
if
(type_ && type_->count) {
90
return
&type_->array[type_->count];
91
}
else
{
92
return
&empty_;
93
}
94
}
95
97
operator
const
type_t
*()
const
{
98
return
type_;
99
}
100
private
:
101
world_t
*world_;
102
const
type_t
*type_;
103
flecs::id_t
empty_;
104
};
105
107
108
}
ecs_assert
#define ecs_assert(condition, error_code,...)
Assert.
Definition
log.h:473
ECS_OUT_OF_RANGE
#define ECS_OUT_OF_RANGE
Out of range error code.
Definition
log.h:677
ECS_INVALID_PARAMETER
#define ECS_INVALID_PARAMETER
Invalid parameter error code.
Definition
log.h:671
flecs::id_t
ecs_id_t id_t
ID type.
Definition
c_types.hpp:20
flecs::type_t
ecs_type_t type_t
Type type.
Definition
c_types.hpp:22
flecs::world_t
ecs_world_t world_t
World type.
Definition
c_types.hpp:18
ecs_type_str
char * ecs_type_str(const ecs_world_t *world, const ecs_type_t *type)
Convert a type to a string.
flecs::id
Class that wraps around a flecs::id_t.
Definition
decl.hpp:27
flecs::string
Owned string wrapper.
Definition
string.hpp:15
flecs::type::end
const flecs::id_t * end() const
Get an iterator to the end of the type's ID array.
Definition
type.hpp:88
flecs::type::array
flecs::id_t * array() const
Return a pointer to the ID array.
Definition
type.hpp:57
flecs::type::count
int32_t count() const
Return the number of IDs in the type.
Definition
type.hpp:46
flecs::type::str
flecs::string str() const
Convert the type to a comma-separated string.
Definition
type.hpp:38
flecs::type::type
type()
Default constructor.
Definition
type.hpp:23
flecs::type::get
flecs::id get(int32_t index) const
Get the ID at a specified index in the type.
Definition
type.hpp:69
flecs::type::type
type(world_t *world, const type_t *t)
Construct a type from a world and C type pointer.
Definition
type.hpp:30
flecs::type::begin
const flecs::id_t * begin() const
Get an iterator to the beginning of the type's ID array.
Definition
type.hpp:79
flecs::world
The world.
Definition
world.hpp:246