Flecs v3.2
A fast entity component system (ECS) for C & C++
Loading...
Searching...
No Matches
type.hpp
Go to the documentation of this file.
1
6#pragma once
7
8namespace flecs {
9
21struct type {
22 type() : m_world(nullptr), m_type(nullptr) { }
23
24 type(world_t *world, const type_t *t)
25 : m_world(world)
26 , m_type(t) { }
27
30 return flecs::string(ecs_type_str(m_world, m_type));
31 }
32
34 int32_t count() const {
35 if (!m_type) {
36 return 0;
37 }
38 return m_type->count;
39 }
40
42 flecs::id_t* array() const {
43 if (!m_type) {
44 return nullptr;
45 }
46 return m_type->array;
47 }
48
50 flecs::id get(int32_t index) const {
51 ecs_assert(m_type != NULL, ECS_INVALID_PARAMETER, NULL);
52 ecs_assert(m_type->count > index, ECS_OUT_OF_RANGE, NULL);
53 if (!m_type) {
54 return flecs::id();
55 }
56 return flecs::id(m_world, m_type->array[index]);
57 }
58
59 flecs::id_t* begin() const {
60 return m_type->array;
61 }
62
63 flecs::id_t* end() const {
64 return &m_type->array[m_type->count];
65 }
66
68 operator const type_t*() const {
69 return m_type;
70 }
71private:
72 world_t *m_world;
73 const type_t *m_type;
74};
75
78}
#define ecs_assert(condition, error_code,...)
Assert.
Definition log.h:351
flecs::id_t * array() const
Return pointer to array.
Definition type.hpp:42
int32_t count() const
Return number of ids in type.
Definition type.hpp:34
flecs::string str() const
Convert type to comma-separated string.
Definition type.hpp:29
flecs::id get(int32_t index) const
Get id at specified index in type.
Definition type.hpp:50
char * ecs_type_str(const ecs_world_t *world, const ecs_type_t *type)
Convert type to string.
A type is a list of (component) ids.
Definition flecs.h:335
Class that wraps around a flecs::id_t.
Definition decl.hpp:27
Type class.
Definition type.hpp:21
The world.
Definition world.hpp:132