Flecs v4.1
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 a field from a component array.
 
 field (iter &iter, int field)
 Create a field from an iterator.
 
T & operator[] (size_t index) const
 Return an element in the component array.
 
T & operator* () const
 Return the first element of the component array.
 
T * operator-> () const
 Return the first element of the 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 a field from a component array.

Parameters
arrayPointer to the component array.
countNumber of elements in the component array.
is_sharedWhether the component is shared.

Definition at line 71 of file field.hpp.

◆ field() [2/2]

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

Create a field from an iterator.

Parameters
iterIterator object.
fieldIndex of the field in the query being iterated over.

Member Function Documentation

◆ operator*()

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

Return the first element of the component array.

This operator is typically used when the field is shared.

Returns
Reference to the first element.

Definition at line 46 of file field.hpp.

◆ operator->()

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

Return the first element of the component array.

This operator is typically used when the field is shared.

Returns
Pointer to the first element.

Definition at line 59 of file field.hpp.

◆ operator[]()

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

Return an element in the component array.

Access an element at an index in the field.

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

Parameters
indexIndex of element.
Returns
Reference to element.
Parameters
indexThe element index.
Returns
Reference to the element.

Definition at line 27 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: