Flecs: include/flecs/addons/cpp/mixins/enum/impl.hpp Source File
Description: A fast entity component system (ECS) for C & C++

| Flecs v4.0 A fast entity component system (ECS) for C & C++

Loading...
Searching...
No Matches
impl.hpp
Go to the documentation of this file.
1
6#pragma once
7
8namespace flecs {
9
10template <typename E>
11 inline E entity_view::to_constant() const {
12 const E* ptr = this->get<E>();
13 ecs_assert(ptr != NULL, ECS_INVALID_PARAMETER, "entity is not a constant");
14 return ptr[0];
15}
16
17template <typename E, if_t< is_enum<E>::value >>
18 inline flecs::entity world::to_entity(E constant) const {
19 const auto& et = enum_type<E>(world_);
20 return flecs::entity(world_, et.entity(constant));
21}
22
23}
ecs_assert
#define ecs_assert(condition, error_code,...)
Assert.
Definition log.h:352
flecs::component::constant
untyped_component & constant(const char *name, int32_t value)
Add constant.
Definition untyped_component.inl:191
flecs::entity_view::to_constant
E to_constant() const
Convert entity to enum constant.
Definition impl.hpp:11
flecs::world::to_entity
flecs::entity to_entity(E constant) const
Convert enum constant to entity.
Definition impl.hpp:18
flecs::entity_view::get
const T * get() const
Get component value.
Definition entity_view.hpp:259
flecs::entity
Entity.
Definition entity.hpp:30