Gaia-ECS v0.9.3
A simple and powerful entity component system
Loading...
Searching...
No Matches
api.h
1#pragma once
2#include "gaia/config/config.h"
3
4#include <cstdarg>
5
6#include "gaia/core/span.h"
7#include "gaia/ecs/command_buffer_fwd.h"
8#include "gaia/ecs/id_fwd.h"
9#include "gaia/ecs/query_fwd.h"
10
11namespace gaia {
12 namespace ecs {
13 class World;
14 class ComponentCache;
15 class Archetype;
16 struct ComponentCacheItem;
17 struct EntityContainer;
18 struct Entity;
19
20 // Component API
21
22 const ComponentCache& comp_cache(const World& world);
23 ComponentCache& comp_cache_mut(World& world);
24 template <typename T>
25 const ComponentCacheItem& comp_cache_add(World& world);
26
27 // Entity API
28
29 const EntityContainer& fetch(const World& world, Entity entity);
30 EntityContainer& fetch_mut(World& world, Entity entity);
31
32 void del(World& world, Entity entity);
33
34 Entity entity_from_id(const World& world, EntityId id);
35 Entity id_entity(const World& world, Entity id);
36 Entity pair_rel(const World& world, Entity pair);
37 Entity pair_tgt(const World& world, Entity pair);
38
40 bool valid(const World& world, Entity entity);
41
42 bool is(const World& world, Entity entity, Entity baseEntity);
43 bool is_base(const World& world, Entity entity);
44
45 Archetype* archetype_from_entity(const World& world, Entity entity);
46
47 util::str_view entity_name(const World& world, Entity entity);
48 util::str_view entity_name(const World& world, EntityId entityId);
49 Entity target(const World& world, Entity entity, Entity relation);
52 void
53 world_for_each_target(const World& world, Entity entity, Entity relation, void* ctx, void (*func)(void*, Entity));
54 Entity world_pair_target_if_alive(const World& world, Entity pair);
55 bool world_entity_enabled(const World& world, Entity entity);
56 bool world_entity_enabled_hierarchy(const World& world, Entity entity, Entity relation);
57 uint32_t world_enabled_hierarchy_version(const World& world);
59 uint32_t world_version(const World& world);
61 uint32_t world_rel_version(const World& world, Entity relation);
63 bool world_is_hierarchy_relation(const World& world, Entity relation);
65 bool world_is_fragmenting_relation(const World& world, Entity relation);
67 bool world_is_fragmenting_hierarchy_relation(const World& world, Entity relation);
69 bool world_supports_depth_order(const World& world, Entity relation);
71 bool world_depth_order_prunes_disabled_subtrees(const World& world, Entity relation);
72 template <typename T>
73 decltype(auto) world_query_entity_arg_by_id(World& world, Entity entity, Entity id);
74
75 // Traversal API
76
77 template <typename Func>
78 void as_relations_trav(const World& world, Entity target, Func func);
79 template <typename Func>
80 bool as_relations_trav_if(const World& world, Entity target, Func func);
81 template <typename Func>
82 void as_targets_trav(const World& world, Entity relation, Func func);
83 template <typename Func>
84 bool as_targets_trav_if(const World& world, Entity relation, Func func);
85 template <typename Func>
86 void targets_trav(const World& world, Entity relation, Entity source, Func func);
87 template <typename Func>
88 bool targets_trav_if(const World& world, Entity relation, Entity source, Func func);
89 const cnt::darray<Entity>& targets_trav_cache(const World& world, Entity relation, Entity source);
90 template <typename Func>
91 void sources(const World& world, Entity relation, Entity target, Func func);
92 template <typename Func>
93 void sources_if(const World& world, Entity relation, Entity target, Func func);
94 const cnt::darray<Entity>& sources_bfs_trav_cache(const World& world, Entity relation, Entity rootTarget);
95 template <typename Func>
96 void sources_bfs(const World& world, Entity relation, Entity rootTarget, Func func);
97 template <typename Func>
98 bool sources_bfs_if(const World& world, Entity relation, Entity rootTarget, Func func);
99 template <typename Func>
100 void children(const World& world, Entity parent, Func func);
101 template <typename Func>
102 void children_if(const World& world, Entity parent, Func func);
103 template <typename Func>
104 void children_bfs(const World& world, Entity root, Func func);
105 template <typename Func>
106 bool children_bfs_if(const World& world, Entity root, Func func);
107
108 // Query API
109
110 QuerySerBuffer& query_buffer(World& world, QueryId& serId);
111 void query_buffer_reset(World& world, QueryId& serId);
112
113 Entity expr_to_entity(const World& world, va_list& args, std::span<const char> exprRaw);
114
115 GroupId group_by_func_default(const World& world, const Archetype& archetype, Entity groupBy);
116
117 // Locking API
118
119 void lock(World& world);
120 void unlock(World& world);
121 bool locked(const World& world);
122
123 // CommandBuffer API
124
125 CommandBufferST& cmd_buffer_st_get(World& world);
126 CommandBufferMT& cmd_buffer_mt_get(World& world);
127 void commit_cmd_buffer_st(World& world);
128 void commit_cmd_buffer_mt(World& world);
129 } // namespace ecs
130} // namespace gaia
Definition span_impl.h:99
Checks if endianess was detected correctly at compile-time.
Definition bitset.h:9