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
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 id_ = ecs_pipeline_init(world, desc);
18
19 if (!id_) {
20 ecs_abort(ECS_INVALID_PARAMETER, NULL);
21 }
22 }
23};
24
26 return flecs::pipeline_builder<>(world_);
27}
28
29template <typename Pipeline, if_not_t< is_enum<Pipeline>::value >>
31 return flecs::pipeline_builder<>(world_, _::type<Pipeline>::id(world_));
32}
33
34inline void world::set_pipeline(const flecs::entity pip) const {
35 return ecs_set_pipeline(world_, pip);
36}
37
38template <typename Pipeline>
39inline void world::set_pipeline() const {
40 return ecs_set_pipeline(world_, _::type<Pipeline>::id(world_));
41}
42
44 return flecs::entity(world_, ecs_get_pipeline(world_));
45}
46
47inline bool world::progress(ecs_ftime_t delta_time) const {
48 return ecs_progress(world_, delta_time);
49}
50
51inline void world::run_pipeline(const flecs::entity_t pip, ecs_ftime_t delta_time) const {
52 return ecs_run_pipeline(world_, pip, delta_time);
53}
54
55template <typename Pipeline, if_not_t< is_enum<Pipeline>::value >>
56inline void world::run_pipeline(ecs_ftime_t delta_time) const {
57 return ecs_run_pipeline(world_, _::type<Pipeline>::id(world_), delta_time);
58}
59
60inline void world::set_time_scale(ecs_ftime_t mul) const {
61 ecs_set_time_scale(world_, mul);
62}
63
64inline void world::set_target_fps(ecs_ftime_t target_fps) const {
65 ecs_set_target_fps(world_, target_fps);
66}
67
68inline void world::reset_clock() const {
69 ecs_reset_clock(world_);
70}
71
72inline void world::set_threads(int32_t threads) const {
73 ecs_set_threads(world_, threads);
74}
75
76inline int32_t world::get_threads() const {
77 return ecs_get_stage_count(world_);
78}
79
80inline void world::set_task_threads(int32_t task_threads) const {
81 ecs_set_task_threads(world_, task_threads);
82}
83
84inline bool world::using_task_threads() const {
85 return ecs_using_task_threads(world_);
86}
87
88}
#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 bool ecs_using_task_threads(ecs_world_t *world)
Returns true if task thread use have been requested.
FLECS_API void ecs_set_task_threads(ecs_world_t *world, int32_t task_threads)
Set number of worker task threads.
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.
void set_target_fps(ecs_ftime_t target_fps) const
Set target FPS.
flecs::pipeline_builder pipeline() const
Create a new pipeline.
flecs::entity get_pipeline() const
Get pipeline.
void run_pipeline(const flecs::entity_t pip, ecs_ftime_t delta_time=0.0) const
Run pipeline.
void reset_clock() const
Reset simulation clock.
void set_threads(int32_t threads) const
Set number of threads.
void set_pipeline() const
Set pipeline.
int32_t get_threads() const
Set number of threads.
void set_time_scale(ecs_ftime_t mul) const
Set timescale.
void set_task_threads(int32_t task_threads) const
Set number of task threads.
bool progress(ecs_ftime_t delta_time=0.0) const
Progress world one tick.
bool using_task_threads() const
Returns true if task thread use has been requested.
#define ecs_ftime_t
Customizable precision for scalar time values.
Definition flecs.h:59
void ecs_set_target_fps(ecs_world_t *world, float fps)
Set target frames per second (FPS) for application.
Pipeline builder.
Pipeline descriptor, used with ecs_pipeline_init().
Definition pipeline.h:88
Entity.
Definition entity.hpp:30
Pipeline builder.
Definition builder.hpp:24
The world.
Definition world.hpp:137
ecs_ftime_t delta_time() const
Get delta_time.
Definition world.hpp:1173