75 desc_.entity = result;
82template <
typename... Args>
88template <
typename Kind>
92 const char *metric_name)
105 const char *component_name = e.
name();
107 if (ecs_os_strcmp(m->
name,
"value") || !component_name) {
111 char *snake_name = flecs_to_snake_case(component_name);
112 metric_entity = w.
scope(
parent).entity(snake_name);
113 ecs_os_free(snake_name);
116 metric_entity = w.
scope(
parent).entity(metric_name);
FLECS_API ecs_entity_t ecs_metric_init(ecs_world_t *world, const ecs_metric_desc_t *desc)
Create a new metric.
FLECS_API void FlecsMetricsImport(ecs_world_t *world)
Metrics module import function.
flecs::metric_builder metric(Args &&... args) const
Create a metric.
untyped_component & metric(flecs::entity_t parent=0, const char *brief=nullptr, const char *name=nullptr)
Register a member as a metric.
flecs::entity import()
Import a module.
flecs::component< T > component(Args &&... args) const
Find or register a component.
flecs::entity entity(Args &&... args) const
Create an entity.
ecs_entity_t entity_t
Entity type.
void err(const char *fmt,...)
Error (level -3).
ecs_entity_t ecs_get_typeid(const ecs_world_t *world, ecs_id_t component)
Get the type for a component.
const char * name
Must be set when used with ecs_struct_desc_t.
ecs_entity_t member
Should not be set by ecs_struct_desc_t.
flecs::string_view name() const
Return the entity name.
flecs::string path(const char *sep="::", const char *init_sep="::") const
Return the entity path.
flecs::entity lookup(const char *path, bool search_path=false) const
Lookup an entity by name.
flecs::entity parent() const
Get parent of entity.
flecs::id_t id_
The raw ID value.
flecs::world_t * world_
World is optional, but guarantees that entity identifiers extracted from the ID are valid.
Metric builder interface.
~metric_builder()
Destructor.
metric_builder & id(flecs::id_t the_id)
Set the ID for the metric.
metric_builder(flecs::world_t *world, flecs::entity_t entity)
Construct a metric builder.
metric_builder & dotmember(const char *name)
Set the member to use for the metric using dot notation.
metric_builder & member(flecs::entity_t e)
Set the member to use for the metric by entity ID.
metric_builder & kind(flecs::entity_t the_kind)
Set the metric kind (e.g., Counter, Gauge).
Counter increment metric kind.
metrics(flecs::world &world)
Construct the metrics module.
EcsMetricValue Value
Metric value component.
EcsMetricSource Source
Metric source component.
const char * c_str() const
Return the C string.
untyped_component()
Default constructor.
world_t * world_
Pointer to the underlying C world.
flecs::entity lookup(const char *name, const char *sep="::", const char *root_sep="::", bool recursive=true) const
Lookup entity by name.
void scope(id_t parent, const Func &func) const
All entities created in the function are created in the scope.