24 untyped_ref () : world_(
nullptr), ref_{} {}
26 untyped_ref(world_t *world, entity_t
entity, flecs::id_t
id)
32 world_ = world ?
const_cast<flecs::world_t *
>(
ecs_get_world(world))
39 "cannot create ref to empty type");
62 flecs::world world()
const {
63 return flecs::world(world_);
73 if (!world_ || !ref_.entity) {
89struct ref :
public untyped_ref {
90 ref() : untyped_ref() { }
92 ref(world_t *world, entity_t
entity, flecs::id_t
id = 0)
99 T* result =
static_cast<T*
>(get());
101 ecs_assert(result != NULL, ECS_INVALID_PARAMETER,
102 "nullptr dereference by flecs::ref");
108 return static_cast<T*
>(untyped_ref::get());
112 return static_cast<T*
>(untyped_ref::try_get());
#define ecs_assert(condition, error_code,...)
Assert.
const ecs_type_info_t * ecs_get_type_info(const ecs_world_t *world, ecs_id_t component)
Get the type info for an component.
void * ecs_ref_get_id(const ecs_world_t *world, ecs_ref_t *ref, ecs_id_t component)
Get component from ref.
ecs_ref_t ecs_ref_init_id(const ecs_world_t *world, ecs_entity_t entity, ecs_id_t component)
Create a component ref.
ecs_entity_t ecs_get_typeid(const ecs_world_t *world, ecs_id_t component)
Get the type for a component.
const ecs_world_t * ecs_get_world(const ecs_poly_t *poly)
Get world from poly.
ecs_size_t size
Size of type.
Class that wraps around a flecs::id_t.
flecs::id component() const
Return component associated with reference.
flecs::entity entity() const
Return entity associated with reference.