Flecs v4.0
A fast entity component system (ECS) for C & C++
Loading...
Searching...
No Matches
flecs::field< T > Struct Template Reference

Wrapper class around a field. More...

#include <field.hpp>

Public Member Functions

 field (T *array, size_t count, bool is_shared=false)
 Create field from component array.
 
 field (iter &iter, int field)
 Create field from iterator.
 
T & operator[] (size_t index) const
 Return element in component array.
 
T & operator* () const
 Return first element of component array.
 
T * operator-> () const
 Return first element of component array.
 

Protected Attributes

T * data_
 
size_t count_
 
bool is_shared_
 

Detailed Description

template<typename T>
struct flecs::field< T >

Wrapper class around a field.

Template Parameters
Tcomponent type of the field.

Definition at line 61 of file field.hpp.

Constructor & Destructor Documentation

◆ field() [1/2]

template<typename T >
flecs::field< T >::field ( T * array,
size_t count,
bool is_shared = false )
inline

Create field from component array.

Parameters
arrayPointer to the component array.
countNumber of elements in component array.
is_sharedIs the component shared or not.

Definition at line 71 of file field.hpp.

◆ field() [2/2]

template<typename T >
flecs::field< T >::field ( iter & iter,
int field )

Create field from iterator.

Parameters
iterIterator object.
fieldIndex of the signature of the query being iterated over.

Member Function Documentation

◆ operator*()

template<typename T >
T & flecs::field< T >::operator* ( ) const

Return first element of component array.

This operator is typically used when the field is shared.

Returns
Reference to the first element.

Definition at line 36 of file field.hpp.

◆ operator->()

template<typename T >
T * flecs::field< T >::operator-> ( ) const

Return first element of component array.

This operator is typically used when the field is shared.

Returns
Pointer to the first element.

Definition at line 49 of file field.hpp.

◆ operator[]()

template<typename T >
T & flecs::field< T >::operator[] ( size_t index) const

Return element in component array.

This operator may only be used if the field is not shared.

Parameters
indexIndex of element.
Returns
Reference to element.

Definition at line 17 of file field.hpp.

Member Data Documentation

◆ count_

template<typename T >
size_t flecs::field< T >::count_
protected

Definition at line 107 of file field.hpp.

◆ data_

template<typename T >
T* flecs::field< T >::data_
protected

Definition at line 106 of file field.hpp.

◆ is_shared_

template<typename T >
bool flecs::field< T >::is_shared_
protected

Definition at line 108 of file field.hpp.


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