Flecs v3.2
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
8#include "builder.hpp"
9
10namespace flecs {
11
12template <typename ... Components>
13struct pipeline : entity {
14 pipeline(world_t *world, ecs_pipeline_desc_t *desc)
15 : entity(world)
16 {
17 m_id = ecs_pipeline_init(world, desc);
18
19 if (!m_id) {
20 ecs_abort(ECS_INVALID_PARAMETER, NULL);
21 }
22
23 if (desc->query.filter.terms_buffer) {
24 ecs_os_free(desc->query.filter.terms_buffer);
25 }
26 }
27};
28
30 return flecs::pipeline_builder<>(m_world);
31}
32
33template <typename Pipeline, if_not_t< is_enum<Pipeline>::value >>
35 return flecs::pipeline_builder<>(m_world, _::cpp_type<Pipeline>::id(m_world));
36}
37
38inline void world::set_pipeline(const flecs::entity pip) const {
39 return ecs_set_pipeline(m_world, pip);
40}
41
42template <typename Pipeline>
43inline void world::set_pipeline() const {
44 return ecs_set_pipeline(m_world, _::cpp_type<Pipeline>::id(m_world));
45}
46
47inline flecs::entity world::get_pipeline() const {
48 return flecs::entity(m_world, ecs_get_pipeline(m_world));
49}
50
51inline bool world::progress(ecs_ftime_t delta_time) const {
52 return ecs_progress(m_world, delta_time);
53}
54
55inline void world::run_pipeline(const flecs::entity_t pip, ecs_ftime_t delta_time) const {
56 return ecs_run_pipeline(m_world, pip, delta_time);
57}
58
59inline void world::set_time_scale(ecs_ftime_t mul) const {
60 ecs_set_time_scale(m_world, mul);
61}
62
63inline ecs_ftime_t world::get_time_scale() const {
64 const ecs_world_info_t *stats = ecs_get_world_info(m_world);
65 return stats->time_scale;
66}
67
68inline int64_t world::get_tick() const {
69 const ecs_world_info_t *stats = ecs_get_world_info(m_world);
70 return stats->frame_count_total;
71}
72
73inline ecs_ftime_t world::get_target_fps() const {
74 const ecs_world_info_t *stats = ecs_get_world_info(m_world);
75 return stats->target_fps;
76}
77
78inline void world::set_target_fps(ecs_ftime_t target_fps) const {
79 ecs_set_target_fps(m_world, target_fps);
80}
81
82inline void world::reset_clock() const {
83 ecs_reset_clock(m_world);
84}
85
86inline void world::set_threads(int32_t threads) const {
87 ecs_set_threads(m_world, threads);
88}
89
90inline int32_t world::get_threads() const {
91 return ecs_get_stage_count(m_world);
92}
93
94}
#define ecs_abort(error_code,...)
Abort.
Definition log.h:343
FLECS_API void ecs_set_threads(ecs_world_t *world, int32_t threads)
Set number of worker threads.
FLECS_API void ecs_set_time_scale(ecs_world_t *world, ecs_ftime_t scale)
Set time scale.
FLECS_API void ecs_set_pipeline(ecs_world_t *world, ecs_entity_t pipeline)
Set a custom pipeline.
FLECS_API ecs_entity_t ecs_get_pipeline(const ecs_world_t *world)
Get the current pipeline.
FLECS_API bool ecs_progress(ecs_world_t *world, ecs_ftime_t delta_time)
Progress a world.
FLECS_API void ecs_reset_clock(ecs_world_t *world)
Reset world clock.
FLECS_API void ecs_run_pipeline(ecs_world_t *world, ecs_entity_t pipeline, ecs_ftime_t delta_time)
Run pipeline.
FLECS_API ecs_entity_t ecs_pipeline_init(ecs_world_t *world, const ecs_pipeline_desc_t *desc)
Create a custom pipeline.
int32_t ecs_get_stage_count(const ecs_world_t *world)
Get number of configured stages.
flecs::pipeline_builder pipeline() const
Create a new pipeline.
#define ecs_ftime_t
Customizable precision for scalar time values.
Definition flecs.h:42
void ecs_set_target_fps(ecs_world_t *world, float fps)
Set target frames per second (FPS) for application.
const ecs_world_info_t * ecs_get_world_info(const ecs_world_t *world)
Get world info.
ecs_term_t * terms_buffer
For filters with lots of terms an outside array can be provided.
Definition flecs.h:848
ecs_filter_desc_t filter
Filter for the query.
Definition flecs.h:881
Type that contains information about the world.
Definition flecs.h:998
int64_t frame_count_total
Total number of frames.
Definition flecs.h:1015
float time_scale
Time scale applied to delta_time.
Definition flecs.h:1005
float target_fps
Target fps.
Definition flecs.h:1006
Entity.
Definition entity.hpp:30
Pipeline builder.
Definition builder.hpp:24
The world.
Definition world.hpp:113
ecs_ftime_t delta_time() const
Get last delta_time.
Definition world.hpp:187
Builder base class.