Flecs v4.1
A fast entity component system (ECS) for C & C++
Loading...
Searching...
No Matches
flecs::table Struct Reference

Table. More...

#include <table.hpp>

Inheritance diagram for flecs::table:
[legend]

Public Member Functions

 table ()
 Default constructor.
 
 table (world_t *world, table_t *t)
 Construct a table from a world and C table pointer.
 
virtual ~table ()
 Destructor.
 
flecs::string str () const
 Convert the table type to a string.
 
flecs::type type () const
 Get the table type.
 
int32_t count () const
 Get the table count.
 
int32_t size () const
 Get the number of allocated elements in the table.
 
const flecs::entity_tentities () const
 Get the array of entity IDs.
 
void clear_entities () const
 Delete entities in the table.
 
int32_t type_index (flecs::id_t id) const
 Find the type index for a (component) ID.
 
template<typename T >
int32_t type_index () const
 Find the type index for a type.
 
int32_t type_index (flecs::entity_t first, flecs::entity_t second) const
 Find the type index for a pair.
 
template<typename First >
int32_t type_index (flecs::entity_t second) const
 Find the type index for a pair.
 
template<typename First , typename Second >
int32_t type_index () const
 Find the type index for a pair.
 
int32_t column_index (flecs::id_t id) const
 Find the column index for a (component) ID.
 
template<typename T >
int32_t column_index () const
 Find the column index for a type.
 
int32_t column_index (flecs::entity_t first, flecs::entity_t second) const
 Find the column index for a pair.
 
template<typename First >
int32_t column_index (flecs::entity_t second) const
 Find the column index for a pair.
 
template<typename First , typename Second >
int32_t column_index () const
 Find the column index for a pair.
 
bool has (flecs::id_t id) const
 Test if the table has a (component) ID.
 
template<typename T >
bool has () const
 Test if the table has the type.
 
bool has (flecs::entity_t first, flecs::entity_t second) const
 Test if the table has the pair.
 
template<typename First >
bool has (flecs::entity_t second) const
 Test if the table has the pair.
 
template<typename First , typename Second >
bool has () const
 Test if the table has the pair.
 
virtual void * get_column (int32_t index) const
 Get a pointer to the component array by column index.
 
void * try_get (flecs::id_t id) const
 Get a pointer to the component array by component.
 
void * try_get (flecs::entity_t first, flecs::entity_t second) const
 Get a pointer to the component array by pair.
 
template<typename T , if_t< is_actual< T >::value > = 0>
T * try_get () const
 Get a pointer to the component array by component.
 
template<typename T , typename A = actual_type_t<T>, if_t< flecs::is_pair< T >::value > = 0>
A * try_get () const
 Get a pointer to the component array by component.
 
template<typename First >
First * try_get (flecs::entity_t second) const
 Get a pointer to the component array by pair.
 
void * get (flecs::id_t id) const
 Get a pointer to the component array by component.
 
void * get (flecs::entity_t first, flecs::entity_t second) const
 Get a pointer to the component array by pair.
 
template<typename T , if_t< is_actual< T >::value > = 0>
T * get () const
 Get a pointer to the component array by component.
 
template<typename T , typename A = actual_type_t<T>, if_t< flecs::is_pair< T >::value > = 0>
A * get () const
 Get a pointer to the component array by component.
 
template<typename First >
First * get (flecs::entity_t second) const
 Get a pointer to the component array by pair.
 
template<typename First , typename Second , typename P = flecs::pair<First, Second>, typename A = actual_type_t<P>, if_not_t< flecs::is_pair< First >::value > = 0>
A * get () const
 Get a pointer to the component array by pair.
 
size_t column_size (int32_t index) const
 Get the column size.
 
int32_t depth (flecs::entity_t rel) const
 Get the depth for a given relationship.
 
template<typename Rel >
int32_t depth () const
 Get the depth for a given relationship.
 
ecs_table_records_t records () const
 Get the table records array.
 
uint64_t id () const
 Get the table ID.
 
void lock () const
 Lock the table.
 
void unlock () const
 Unlock the table.
 
bool has_flags (ecs_flags32_t flags) const
 Check if the table has flags.
 
table_tget_table () const
 Get the table.
 
 operator table_t * () const
 Implicit conversion to table_t*.
 

Protected Attributes

world_tworld_
 
table_ttable_
 

Detailed Description

Table.

A table stores entities with the same set of components.

Definition at line 23 of file table.hpp.

Constructor & Destructor Documentation

◆ table() [1/2]

flecs::table::table ( )
inline

Default constructor.

Definition at line 25 of file table.hpp.

◆ table() [2/2]

flecs::table::table ( world_t * world,
table_t * t )
inline

Construct a table from a world and C table pointer.

Parameters
worldThe world.
tPointer to the C table.

Definition at line 32 of file table.hpp.

◆ ~table()

virtual flecs::table::~table ( )
inlinevirtual

Destructor.

Definition at line 37 of file table.hpp.

Member Function Documentation

◆ clear_entities()

void flecs::table::clear_entities ( ) const
inline

Delete entities in the table.

Definition at line 65 of file table.hpp.

◆ column_index() [1/5]

template<typename T >
int32_t flecs::table::column_index ( ) const
inline

Find the column index for a type.

Template Parameters
TThe type.
Returns
The column index of the ID in the table type, -1 if not found.

Definition at line 135 of file table.hpp.

◆ column_index() [2/5]

template<typename First , typename Second >
int32_t flecs::table::column_index ( ) const
inline

Find the column index for a pair.

Template Parameters
FirstFirst element of the pair.
SecondSecond element of the pair.
Returns
The column index of the ID in the table type, -1 if not found.

Definition at line 167 of file table.hpp.

◆ column_index() [3/5]

int32_t flecs::table::column_index ( flecs::entity_t first,
flecs::entity_t second ) const
inline

Find the column index for a pair.

Parameters
firstFirst element of the pair.
secondSecond element of the pair.
Returns
The column index of the ID in the table type, -1 if not found.

Definition at line 145 of file table.hpp.

◆ column_index() [4/5]

template<typename First >
int32_t flecs::table::column_index ( flecs::entity_t second) const
inline

Find the column index for a pair.

Template Parameters
FirstFirst element of the pair.
Parameters
secondSecond element of the pair.
Returns
The column index of the ID in the table type, -1 if not found.

Definition at line 156 of file table.hpp.

◆ column_index() [5/5]

int32_t flecs::table::column_index ( flecs::id_t id) const
inline

Find the column index for a (component) ID.

Parameters
idThe (component) ID.
Returns
The column index of the ID in the table, -1 if not found.

Definition at line 125 of file table.hpp.

◆ column_size()

size_t flecs::table::column_size ( int32_t index) const
inline

Get the column size.

Parameters
indexThe column index.
Returns
The size of the column's component type.

Definition at line 368 of file table.hpp.

◆ count()

int32_t flecs::table::count ( ) const
inline

Get the table count.

Definition at line 50 of file table.hpp.

◆ depth() [1/2]

template<typename Rel >
int32_t flecs::table::depth ( ) const
inline

Get the depth for a given relationship.

Template Parameters
RelThe relationship.
Returns
The depth.

Definition at line 387 of file table.hpp.

◆ depth() [2/2]

int32_t flecs::table::depth ( flecs::entity_t rel) const
inline

Get the depth for a given relationship.

Parameters
relThe relationship.
Returns
The depth.

Definition at line 377 of file table.hpp.

◆ entities()

const flecs::entity_t * flecs::table::entities ( ) const
inline

Get the array of entity IDs.

Definition at line 60 of file table.hpp.

◆ get() [1/6]

template<typename T , if_t< is_actual< T >::value > = 0>
T * flecs::table::get ( ) const
inline

Get a pointer to the component array by component.

Template Parameters
TThe component.
Returns
Pointer to the column, NULL if not found.

Definition at line 324 of file table.hpp.

◆ get() [2/6]

template<typename T , typename A = actual_type_t<T>, if_t< flecs::is_pair< T >::value > = 0>
A * flecs::table::get ( ) const
inline

Get a pointer to the component array by component.

Template Parameters
TThe component.
Returns
Pointer to the column, NULL if not found.

Definition at line 335 of file table.hpp.

◆ get() [3/6]

template<typename First , typename Second , typename P = flecs::pair<First, Second>, typename A = actual_type_t<P>, if_not_t< flecs::is_pair< First >::value > = 0>
A * flecs::table::get ( ) const
inline

Get a pointer to the component array by pair.

Template Parameters
FirstThe first element of the pair.
SecondThe second element of the pair.
Returns
Pointer to the column, NULL if not found.

Definition at line 359 of file table.hpp.

◆ get() [4/6]

void * flecs::table::get ( flecs::entity_t first,
flecs::entity_t second ) const
inline

Get a pointer to the component array by pair.

Parameters
firstThe first element of the pair.
secondThe second element of the pair.
Returns
Pointer to the column, NULL if not found.

Definition at line 314 of file table.hpp.

◆ get() [5/6]

template<typename First >
First * flecs::table::get ( flecs::entity_t second) const
inline

Get a pointer to the component array by pair.

Template Parameters
FirstThe first element of the pair.
Parameters
secondThe second element of the pair.
Returns
Pointer to the column, NULL if not found.

Definition at line 346 of file table.hpp.

◆ get() [6/6]

void * flecs::table::get ( flecs::id_t id) const
inline

Get a pointer to the component array by component.

Parameters
idThe component ID.
Returns
Pointer to the column, NULL if not found.

Definition at line 297 of file table.hpp.

◆ get_column()

virtual void * flecs::table::get_column ( int32_t index) const
inlinevirtual

Get a pointer to the component array by column index.

Parameters
indexThe column index.
Returns
Pointer to the column, NULL if not a component.

Reimplemented in flecs::table_range.

Definition at line 227 of file table.hpp.

◆ get_table()

table_t * flecs::table::get_table ( ) const
inline

Get the table.

Returns
The table.

Definition at line 430 of file table.hpp.

◆ has() [1/5]

template<typename T >
bool flecs::table::has ( ) const
inline

Test if the table has the type.

Template Parameters
TThe type.
Returns
True if the table has the type, false if not.

Definition at line 186 of file table.hpp.

◆ has() [2/5]

template<typename First , typename Second >
bool flecs::table::has ( ) const
inline

Test if the table has the pair.

Template Parameters
FirstFirst element of the pair.
SecondSecond element of the pair.
Returns
True if the table has the pair, false if not.

Definition at line 218 of file table.hpp.

◆ has() [3/5]

bool flecs::table::has ( flecs::entity_t first,
flecs::entity_t second ) const
inline

Test if the table has the pair.

Parameters
firstFirst element of the pair.
secondSecond element of the pair.
Returns
True if the table has the pair, false if not.

Definition at line 196 of file table.hpp.

◆ has() [4/5]

template<typename First >
bool flecs::table::has ( flecs::entity_t second) const
inline

Test if the table has the pair.

Template Parameters
FirstFirst element of the pair.
Parameters
secondSecond element of the pair.
Returns
True if the table has the pair, false if not.

Definition at line 207 of file table.hpp.

◆ has() [5/5]

bool flecs::table::has ( flecs::id_t id) const
inline

Test if the table has a (component) ID.

Parameters
idThe (component) ID.
Returns
True if the table has the ID, false if not.

Definition at line 176 of file table.hpp.

◆ has_flags()

bool flecs::table::has_flags ( ecs_flags32_t flags) const
inline

Check if the table has flags.

Parameters
flagsThe flags to check for.
Returns
True if the table has the specified flags.

Definition at line 422 of file table.hpp.

◆ id()

uint64_t flecs::table::id ( ) const
inline

Get the table ID.

Returns
The table ID.

Definition at line 403 of file table.hpp.

◆ lock()

void flecs::table::lock ( ) const
inline

Lock the table.

Definition at line 408 of file table.hpp.

◆ operator table_t *()

flecs::table::operator table_t * ( ) const
inline

Implicit conversion to table_t*.

Definition at line 435 of file table.hpp.

◆ records()

ecs_table_records_t flecs::table::records ( ) const
inline

Get the table records array.

Returns
The table records.

Definition at line 395 of file table.hpp.

◆ size()

int32_t flecs::table::size ( ) const
inline

Get the number of allocated elements in the table.

Definition at line 55 of file table.hpp.

◆ str()

flecs::string flecs::table::str ( ) const
inline

Convert the table type to a string.

Definition at line 40 of file table.hpp.

◆ try_get() [1/5]

template<typename T , if_t< is_actual< T >::value > = 0>
T * flecs::table::try_get ( ) const
inline

Get a pointer to the component array by component.

Template Parameters
TThe component.
Returns
Pointer to the column, NULL if not found.

Definition at line 263 of file table.hpp.

◆ try_get() [2/5]

template<typename T , typename A = actual_type_t<T>, if_t< flecs::is_pair< T >::value > = 0>
A * flecs::table::try_get ( ) const
inline

Get a pointer to the component array by component.

Template Parameters
TThe component.
Returns
Pointer to the column, NULL if not found.

Definition at line 274 of file table.hpp.

◆ try_get() [3/5]

void * flecs::table::try_get ( flecs::entity_t first,
flecs::entity_t second ) const
inline

Get a pointer to the component array by pair.

Parameters
firstThe first element of the pair.
secondThe second element of the pair.
Returns
Pointer to the column, NULL if not found.

Definition at line 253 of file table.hpp.

◆ try_get() [4/5]

template<typename First >
First * flecs::table::try_get ( flecs::entity_t second) const
inline

Get a pointer to the component array by pair.

Template Parameters
FirstThe first element of the pair.
Parameters
secondThe second element of the pair.
Returns
Pointer to the column, NULL if not found.

Definition at line 285 of file table.hpp.

◆ try_get() [5/5]

void * flecs::table::try_get ( flecs::id_t id) const
inline

Get a pointer to the component array by component.

Parameters
idThe component ID.
Returns
Pointer to the column, NULL if not found.

Definition at line 239 of file table.hpp.

◆ type()

flecs::type flecs::table::type ( ) const
inline

Get the table type.

Definition at line 45 of file table.hpp.

◆ type_index() [1/5]

template<typename T >
int32_t flecs::table::type_index ( ) const
inline

Find the type index for a type.

Template Parameters
TThe type.
Returns
The index of the ID in the table type, -1 if not found.

Definition at line 84 of file table.hpp.

◆ type_index() [2/5]

template<typename First , typename Second >
int32_t flecs::table::type_index ( ) const
inline

Find the type index for a pair.

Template Parameters
FirstFirst element of the pair.
SecondSecond element of the pair.
Returns
The index of the ID in the table type, -1 if not found.

Definition at line 116 of file table.hpp.

◆ type_index() [3/5]

int32_t flecs::table::type_index ( flecs::entity_t first,
flecs::entity_t second ) const
inline

Find the type index for a pair.

Parameters
firstFirst element of the pair.
secondSecond element of the pair.
Returns
The index of the ID in the table type, -1 if not found.

Definition at line 94 of file table.hpp.

◆ type_index() [4/5]

template<typename First >
int32_t flecs::table::type_index ( flecs::entity_t second) const
inline

Find the type index for a pair.

Template Parameters
FirstFirst element of the pair.
Parameters
secondSecond element of the pair.
Returns
The index of the ID in the table type, -1 if not found.

Definition at line 105 of file table.hpp.

◆ type_index() [5/5]

int32_t flecs::table::type_index ( flecs::id_t id) const
inline

Find the type index for a (component) ID.

Parameters
idThe (component) ID.
Returns
The index of the ID in the table type, -1 if not found.

Definition at line 74 of file table.hpp.

◆ unlock()

void flecs::table::unlock ( ) const
inline

Unlock the table.

Definition at line 413 of file table.hpp.

Member Data Documentation

◆ table_

table_t* flecs::table::table_
protected

Definition at line 441 of file table.hpp.

◆ world_

world_t* flecs::table::world_
protected

Definition at line 440 of file table.hpp.


The documentation for this struct was generated from the following file: