Flecs v3.2
A fast entity component system (ECS) for C & C++
Loading...
Searching...
No Matches
flecs::_::enum_reflection< E, Handler > Struct Template Reference

Provides utilities for enum reflection. More...

#include <enum.hpp>

Static Public Member Functions

template<E Value>
static constexpr underlying_type_t< E > to_int ()
 
template<underlying_type_t< E > Value>
static constexpr E from_int ()
 
template<E Value>
static constexpr underlying_type_t< E > is_not_0 ()
 
template<E Low, E High, typename... Args>
static constexpr underlying_type_t< E > each_enum_range (underlying_type_t< E > last_value, Args... args)
 Iterates over the range [Low, High] of enum values between Low and High.
 
template<E Low, E High, typename... Args>
static constexpr underlying_type_t< E > each_mask_range (underlying_type_t< E > last_value, Args... args)
 Iterates over the mask range (Low, High] of enum values between Low and High.
 
template<E Value = _::to_constant< E , 128>::value, typename... Args>
static constexpr underlying_type_t< E > each_enum (Args... args)
 Handles enum iteration for gathering reflection data.
 

Static Public Attributes

static const underlying_type_t< E > high_bit = static_cast<underlying_type_t<E>>(1) << (sizeof(underlying_type_t<E>) * 8 - 1)
 

Detailed Description

template<typename E, template< typename > class Handler>
struct flecs::_::enum_reflection< E, Handler >

Provides utilities for enum reflection.

This struct provides static functions for enum reflection, including conversion between enum values and their underlying integral types, and iteration over enum values.

Template Parameters
EThe enum type.
HandlerThe handler for enum reflection operations.

Definition at line 181 of file enum.hpp.

Member Function Documentation

◆ each_enum()

template<typename E , template< typename > class Handler>
template<E Value = _::to_constant< E , 128>::value, typename... Args>
static constexpr underlying_type_t< E > flecs::_::enum_reflection< E, Handler >::each_enum ( Args... args)
inlinestaticconstexpr

Handles enum iteration for gathering reflection data.

Iterates over all enum values up to a specified maximum value (each_enum_range<0, Value>), then iterates the rest of the possible bitmasks (each_mask_range<Value, high_bit>).

Template Parameters
ValueThe maximum enum value to iterate up to.
ArgsAdditional arguments to be passed through to Handler<E>::handle_constant
Parameters
argsAdditional arguments to be passed through to Handler<E>::handle_constant
Returns
constexpr underlying_type_t<E> The result of the iteration.

Definition at line 261 of file enum.hpp.

◆ each_enum_range()

template<typename E , template< typename > class Handler>
template<E Low, E High, typename... Args>
static constexpr underlying_type_t< E > flecs::_::enum_reflection< E, Handler >::each_enum_range ( underlying_type_t< E > last_value,
Args... args )
inlinestaticconstexpr

Iterates over the range [Low, High] of enum values between Low and High.

Recursively divide and conquers the search space to reduce the template-depth. Once recursive division is complete, calls Handle<E>::handle_constant in ascending order, passing the values computed up the chain.

Template Parameters
LowThe lower bound of the search range, inclusive.
HighThe upper bound of the search range, inclusive.
ArgsAdditional arguments to be passed through to Handler<E>::handle_constant
Parameters
last_valueThe last value processed in the iteration.
argsAdditional arguments to be passed through to Handler<E>::handle_constant
Returns
constexpr underlying_type_t<E> The result of the iteration.

Definition at line 212 of file enum.hpp.

◆ each_mask_range()

template<typename E , template< typename > class Handler>
template<E Low, E High, typename... Args>
static constexpr underlying_type_t< E > flecs::_::enum_reflection< E, Handler >::each_mask_range ( underlying_type_t< E > last_value,
Args... args )
inlinestaticconstexpr

Iterates over the mask range (Low, High] of enum values between Low and High.

Recursively iterates the search space, looking for enums defined as multiple-of-2 bitmasks. Each iteration, shifts bit to the right until it hits Low, then calls Handler<E>::handle_constant for each bitmask in ascending order.

Template Parameters
LowThe lower bound of the search range, not inclusive
HighThe upper bound of the search range, inclusive.
ArgsAdditional arguments to be passed through to Handler<E>::handle_constant
Parameters
last_valueThe last value processed in the iteration.
argsAdditional arguments to be passed through to Handler<E>::handle_constant
Returns
constexpr underlying_type_t<E> The result of the iteration.

Definition at line 238 of file enum.hpp.

◆ from_int()

template<typename E , template< typename > class Handler>
template<underlying_type_t< E > Value>
static constexpr E flecs::_::enum_reflection< E, Handler >::from_int ( )
inlinestaticconstexpr

Definition at line 188 of file enum.hpp.

◆ is_not_0()

template<typename E , template< typename > class Handler>
template<E Value>
static constexpr underlying_type_t< E > flecs::_::enum_reflection< E, Handler >::is_not_0 ( )
inlinestaticconstexpr

Definition at line 193 of file enum.hpp.

◆ to_int()

template<typename E , template< typename > class Handler>
template<E Value>
static constexpr underlying_type_t< E > flecs::_::enum_reflection< E, Handler >::to_int ( )
inlinestaticconstexpr

Definition at line 183 of file enum.hpp.

Member Data Documentation

◆ high_bit

template<typename E , template< typename > class Handler>
const underlying_type_t<E> flecs::_::enum_reflection< E, Handler >::high_bit = static_cast<underlying_type_t<E>>(1) << (sizeof(underlying_type_t<E>) * 8 - 1)
static

Definition at line 265 of file enum.hpp.


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