25 table() : world_(nullptr), table_(nullptr) { }
69 template <
typename... T,
typename... Args>
70 int32_t type_index(Args... args)
const {
74 template <
typename... T,
typename... Args>
75 int32_t column_index(Args... args)
const {
79 template <
typename... T,
typename... Args>
80 bool has(Args... args)
const {
81 return type_index<T...>(args...) != -1;
94 template <
typename... T,
typename... Args>
95 auto try_get(Args... args)
const {
96 return get_ptr<false>(_::make_id<T...>(world_, args...));
99 template <
typename... T,
typename... Args>
100 auto get(Args... args)
const {
101 return get_ptr<true>(_::make_id<T...>(world_, args...));
127 template <
typename Rel>
137 return flecs_table_records(table_);
144 uint64_t
id()
const {
145 return flecs_table_id(table_);
181 template <
bool Required,
typename Id>
182 typename Id::type* get_ptr(Id
id)
const {
183 int32_t index = column_index(
id.
id);
187 auto ptr =
static_cast<typename Id::type*
>(
get_column(index));
188 if constexpr (Required) {
190 "invalid get: table does not have component (use try_get())");
#define ecs_assert(condition, error_code,...)
Assert.
#define ECS_INVALID_OPERATION
Invalid operation error code.
ecs_table_t table_t
Table type.
ecs_entity_t entity_t
Entity type.
ecs_world_t world_t
World type.
char * ecs_table_str(const ecs_world_t *world, const ecs_table_t *table)
Convert a table to a string.
const ecs_type_t * ecs_table_get_type(const ecs_table_t *table)
Get the type for a table.
int32_t ecs_table_get_column_index(const ecs_world_t *world, const ecs_table_t *table, ecs_id_t component)
Get the column index for a component.
int32_t ecs_table_size(const ecs_table_t *table)
Return the allocated size of the table.
bool ecs_table_has_flags(ecs_table_t *table, ecs_flags32_t flags)
Test a table for flags.
void * ecs_table_get_column(const ecs_table_t *table, int32_t index, int32_t offset)
Get a column from a table by column index.
int32_t ecs_table_count(const ecs_table_t *table)
Return the number of entities in the table.
const ecs_entity_t * ecs_table_entities(const ecs_table_t *table)
Return the array with entity IDs for the table.
void ecs_table_unlock(ecs_world_t *world, ecs_table_t *table)
Unlock a table.
int32_t ecs_table_get_depth(const ecs_world_t *world, const ecs_table_t *table, ecs_entity_t rel)
Return the depth for a table in the tree for the specified relationship.
void ecs_table_lock(ecs_world_t *world, ecs_table_t *table)
Lock a table.
size_t ecs_table_get_column_size(const ecs_table_t *table, int32_t index)
Get the column size from a table.
int32_t ecs_table_get_type_index(const ecs_world_t *world, const ecs_table_t *table, ecs_id_t component)
Get the type index for a component.
void ecs_table_clear_entities(ecs_world_t *world, ecs_table_t *table)
Remove all entities in a table.
table_range(world_t *world, table_t *t, int32_t offset, int32_t count)
Construct a table range from a world, table, offset, and count.
void * get_column(int32_t index) const override
Get a pointer to the component array by column index.
int32_t count() const
Get the number of entities in the range.
int32_t offset() const
Get the offset of the range.
table_range()
Default constructor.
int32_t depth() const
Get the depth for a given relationship.
uint64_t id() const
Get the table ID.
flecs::string str() const
Convert the table type to a string.
table(world_t *world, table_t *t)
Construct a table from a world and C table pointer.
int32_t depth(flecs::entity_t rel) const
Get the depth for a given relationship.
int32_t count() const
Get the table count.
virtual ~table()
Destructor.
table()
Default constructor.
bool has_flags(ecs_flags32_t flags) const
Check if the table has flags.
const flecs::entity_t * entities() const
Get the array of entity IDs.
void lock() const
Lock the table.
table_t * get_table() const
Get the table.
size_t column_size(int32_t index) const
Get the column size.
void clear_entities() const
Delete entities in the table.
flecs::type type() const
Get the table type.
int32_t size() const
Get the number of allocated elements in the table.
ecs_table_records_t records() const
Get the table records array.
void unlock() const
Unlock the table.
virtual void * get_column(int32_t index) const
Get a pointer to the component array by column index.