Skip to content
Flecs v4.1
c_types.hpp
Go to the documentation of this file.
1/**
2 * @file addons/cpp/c_types.hpp
3 * @brief Aliases for types/constants from C API.
4 */
5
6#pragma once
7
8namespace flecs {
9
10/**
11 * @defgroup cpp_globals API Types and Globals
12 * @ingroup cpp_core
13 * Types and constants bridged from C API.
14 *
15 * @{
16 */
17
18using world_t = ecs_world_t; /**< World type. */
19using world_info_t = ecs_world_info_t; /**< World info type. */
20using id_t = ecs_id_t; /**< ID type. */
21using entity_t = ecs_entity_t; /**< Entity type. */
22using type_t = ecs_type_t; /**< Type type. */
23using table_t = ecs_table_t; /**< Table type. */
24using term_t = ecs_term_t; /**< Term type. */
25using query_t = ecs_query_t; /**< Query type. */
26using query_group_info_t = ecs_query_group_info_t; /**< Query group info type. */
27using observer_t = ecs_observer_t; /**< Observer type. */
28using iter_t = ecs_iter_t; /**< Iterator type. */
29using ref_t = ecs_ref_t; /**< Ref type. */
30using table_record_t = ecs_table_record_t; /**< Table record type. */
31using table_records_t = ecs_table_records_t; /**< Table records type. */
32using component_record_t = ecs_component_record_t; /**< Component record type. */
33using type_info_t = ecs_type_info_t; /**< Type info type. */
34using type_hooks_t = ecs_type_hooks_t; /**< Type hooks type. */
35using flags32_t = ecs_flags32_t; /**< 32-bit flags type. */
36using flags64_t = ecs_flags64_t; /**< 64-bit flags type. */
37
38/** Inout kind. */
40 InOutDefault = EcsInOutDefault, /**< InOutDefault. */
41 InOutNone = EcsInOutNone, /**< InOutNone. */
42 InOutFilter = EcsInOutFilter, /**< InOutFilter. */
43 InOut = EcsInOut, /**< InOut. */
44 In = EcsIn, /**< In. */
45 Out = EcsOut /**< Out. */
46};
47
48/** Operator kind. */
50 And = EcsAnd, /**< And operator. */
51 Or = EcsOr, /**< Or operator. */
52 Not = EcsNot, /**< Not operator. */
53 Optional = EcsOptional, /**< Optional operator. */
54 AndFrom = EcsAndFrom, /**< AndFrom operator. */
55 OrFrom = EcsOrFrom, /**< OrFrom operator. */
56 NotFrom = EcsNotFrom /**< NotFrom operator. */
57};
58
59/** Query cache kind. */
61 QueryCacheDefault = EcsQueryCacheDefault, /**< Default query cache. */
62 QueryCacheAuto = EcsQueryCacheAuto, /**< Auto query cache. */
63#ifdef FLECS_CACHED_QUERIES
64 QueryCacheAll = EcsQueryCacheAll, /**< Cache all. */
65#endif
66 QueryCacheNone = EcsQueryCacheNone /**< No caching. */
67};
68
69/** ID bit flags. */
70static const flecs::entity_t PAIR = ECS_PAIR; /**< Pair flag. */
71static const flecs::entity_t AUTO_OVERRIDE = ECS_AUTO_OVERRIDE; /**< Auto override flag. */
72static const flecs::entity_t TOGGLE = ECS_TOGGLE; /**< Toggle flag. */
73static const flecs::entity_t VALUE_PAIR = ECS_VALUE_PAIR; /**< Value pair flag. */
74
75////////////////////////////////////////////////////////////////////////////////
76//// Built-in components and tags
77////////////////////////////////////////////////////////////////////////////////
78
79/** Built-in EcsComponent type. */
81/** Built-in EcsIdentifier type. */
83/** Built-in EcsPoly type. */
84using Poly = EcsPoly;
85/** Built-in EcsParent type. */
87
88/** Built-in Query tag. */
89static const flecs::entity_t Query = EcsQuery;
90/** Built-in Observer tag. */
91static const flecs::entity_t Observer = EcsObserver;
92/** Built-in Module tag. */
93static const flecs::entity_t Module = EcsModule;
94
95#ifdef FLECS_PREFAB
96/** Built-in Prefab tag. */
97static const flecs::entity_t Prefab = EcsPrefab;
98#endif
99
100/** Built-in Disabled tag. */
101static const flecs::entity_t Disabled = EcsDisabled;
102/** Built-in Empty tag. */
103static const flecs::entity_t Empty = EcsEmpty;
104/** Built-in Monitor tag. */
105static const flecs::entity_t Monitor = EcsMonitor;
106/** Built-in System tag. */
107static const flecs::entity_t System = EcsSystem;
108#ifdef FLECS_PIPELINE
109/** Built-in Pipeline tag. */
110static const flecs::entity_t Pipeline = ecs_id(EcsPipeline);
111/** Built-in Phase tag. */
112static const flecs::entity_t Phase = EcsPhase;
113#endif
114/** Built-in Constant tag. */
115static const flecs::entity_t Constant = EcsConstant;
116/** Built-in ParentDepth tag. */
117static const flecs::entity_t ParentDepth = EcsParentDepth;
118
119/** Built-in OnAdd event. */
120static const flecs::entity_t OnAdd = EcsOnAdd;
121/** Built-in OnRemove event. */
122static const flecs::entity_t OnRemove = EcsOnRemove;
123/** Built-in OnSet event. */
124static const flecs::entity_t OnSet = EcsOnSet;
125/** Built-in OnTableCreate event. */
126static const flecs::entity_t OnTableCreate = EcsOnTableCreate;
127/** Built-in OnTableDelete event. */
128static const flecs::entity_t OnTableDelete = EcsOnTableDelete;
129
130#ifdef FLECS_CONSTRAINT_TRAITS
131/** Acyclic trait. */
132static const flecs::entity_t Acyclic = EcsAcyclic;
133/** Final trait. */
134static const flecs::entity_t Final = EcsFinal;
135/** OneOf trait. */
136static const flecs::entity_t OneOf = EcsOneOf;
137/** Relationship tag. */
138static const flecs::entity_t Relationship = EcsRelationship;
139/** Target tag. */
140static const flecs::entity_t Target = EcsTarget;
141/** Trait tag. */
142static const flecs::entity_t Trait = EcsTrait;
143/** Singleton tag. */
144static const flecs::entity_t Singleton = EcsSingleton;
145/** Symmetric trait. */
146static const flecs::entity_t Symmetric = EcsSymmetric;
147#endif
148
149/** Self term flag. */
150static const uint64_t Self = EcsSelf;
151/** Up term flag. */
152static const uint64_t Up = EcsUp;
153/** Trav term flag. */
154static const uint64_t Trav = EcsTrav;
155/** Cascade term flag. */
156static const uint64_t Cascade = EcsCascade;
157/** Desc term flag. */
158static const uint64_t Desc = EcsDesc;
159/** IsVariable term flag. */
160static const uint64_t IsVariable = EcsIsVariable;
161/** IsEntity term flag. */
162static const uint64_t IsEntity = EcsIsEntity;
163/** IsName term flag. */
164static const uint64_t IsName = EcsIsName;
165/** TraverseFlags term flag mask. */
166static const uint64_t TraverseFlags = EcsTraverseFlags;
167/** TermRefFlags term flag mask. */
168static const uint64_t TermRefFlags = EcsTermRefFlags;
169
170/** Built-in Flecs entity. */
171static const flecs::entity_t Flecs = EcsFlecs;
172/** Built-in FlecsCore entity. */
173static const flecs::entity_t FlecsCore = EcsFlecsCore;
174/** Built-in World entity. */
175static const flecs::entity_t World = EcsWorld;
176
177/** Wildcard entity. */
178static const flecs::entity_t Wildcard = EcsWildcard;
179/** Any entity. */
180static const flecs::entity_t Any = EcsAny;
181/** This variable entity. */
182static const flecs::entity_t This = EcsThis;
183/** Transitive trait. */
184static const flecs::entity_t Transitive = EcsTransitive;
185/** Reflexive trait. */
186static const flecs::entity_t Reflexive = EcsReflexive;
187/** Inheritable trait. */
188static const flecs::entity_t Inheritable = EcsInheritable;
189/** PairIsTag trait. */
190static const flecs::entity_t PairIsTag = EcsPairIsTag;
191/** Exclusive trait. */
192static const flecs::entity_t Exclusive = EcsExclusive;
193/** Traversable trait. */
194static const flecs::entity_t Traversable = EcsTraversable;
195/** With trait. */
196static const flecs::entity_t With = EcsWith;
197/** CanToggle trait. */
198static const flecs::entity_t CanToggle = EcsCanToggle;
199
200/** OnInstantiate trait. */
201static const flecs::entity_t OnInstantiate = EcsOnInstantiate;
202#ifdef FLECS_PREFAB
203/** Override trait. */
204static const flecs::entity_t Override = EcsOverride;
205/** Inherit trait. */
206static const flecs::entity_t Inherit = EcsInherit;
207#endif
208/** DontInherit trait. */
209static const flecs::entity_t DontInherit = EcsDontInherit;
210
211/** OnDelete cleanup trait. */
212static const flecs::entity_t OnDelete = EcsOnDelete;
213/** OnDeleteTarget cleanup trait. */
214static const flecs::entity_t OnDeleteTarget = EcsOnDeleteTarget;
215/** Remove cleanup action. */
216static const flecs::entity_t Remove = EcsRemove;
217/** Delete cleanup action. */
218static const flecs::entity_t Delete = EcsDelete;
219/** Panic cleanup action. */
220static const flecs::entity_t Panic = EcsPanic;
221
222/** IsA relationship. */
223static const flecs::entity_t IsA = EcsIsA;
224/** ChildOf relationship. */
225static const flecs::entity_t ChildOf = EcsChildOf;
226/** DependsOn relationship. */
227static const flecs::entity_t DependsOn = EcsDependsOn;
228/** OrderedChildren tag. */
229static const flecs::entity_t OrderedChildren = EcsOrderedChildren;
230
231/** Name identifier. */
232static const flecs::entity_t Name = EcsName;
233/** Symbol identifier. */
234static const flecs::entity_t Symbol = EcsSymbol;
235
236/** Sparse storage tag. */
237static const flecs::entity_t Sparse = EcsSparse;
238/** DontFragment storage tag. */
239static const flecs::entity_t DontFragment = EcsDontFragment;
240
241/** PredEq query predicate. */
242static const flecs::entity_t PredEq = EcsPredEq;
243/** PredMatch query predicate. */
244static const flecs::entity_t PredMatch = EcsPredMatch;
245/** PredLookup query predicate. */
246static const flecs::entity_t PredLookup = EcsPredLookup;
247
248/** ScopeOpen query scope marker. */
249static const flecs::entity_t ScopeOpen = EcsScopeOpen;
250/** ScopeClose query scope marker. */
251static const flecs::entity_t ScopeClose = EcsScopeClose;
252
253/** @} */
254
255}
const ecs_entity_t EcsScopeClose
Marker used to indicate the end of a scope (}) in queries.
const ecs_entity_t EcsOnRemove
Event that triggers when an ID is removed from an entity.
const ecs_entity_t EcsThis
This entity.
const ecs_entity_t EcsWildcard
Wildcard entity ("*").
const ecs_entity_t EcsName
Tag to indicate name identifier.
const ecs_entity_t EcsOnSet
Event that triggers when a component is set for an entity.
const ecs_entity_t EcsReflexive
Mark a relationship as reflexive.
const ecs_entity_t EcsEmpty
Tag used to indicate a query is empty.
const ecs_entity_t EcsOnTableDelete
Event that triggers when a table is deleted.
const ecs_entity_t EcsOnTableCreate
Event that triggers when a table is created.
const ecs_entity_t EcsObserver
Tag added to observers.
const ecs_entity_t EcsQuery
Tag added to queries.
const ecs_entity_t EcsOrderedChildren
Tag that, when added to a parent, ensures stable order of ecs_children() results.
const ecs_entity_t EcsDontFragment
Mark component as non-fragmenting.
const ecs_entity_t EcsTraversable
Mark a relationship as traversable.
const ecs_entity_t EcsPredLookup
Marker used to indicate $var ~= "pattern" matching in queries.
const ecs_entity_t EcsIsA
Used to express inheritance relationships.
const ecs_entity_t EcsExclusive
Can be added to a relationship to indicate that the relationship can only occur once on an entity.
const ecs_entity_t EcsSymbol
Tag to indicate symbol identifier.
const ecs_entity_t EcsDependsOn
Used to express dependency relationships.
const ecs_entity_t EcsTransitive
Mark a relationship as transitive.
const ecs_entity_t EcsDelete
Delete cleanup policy.
const ecs_entity_t EcsChildOf
Used to express parent-child relationships.
const ecs_entity_t EcsFlecsCore
Core module scope.
const ecs_entity_t EcsMonitor
Event that triggers an observer when an entity starts or stops matching a query.
const ecs_entity_t EcsCanToggle
Mark a component as toggleable with ecs_enable_id().
const ecs_entity_t EcsPredEq
Marker used to indicate $var == ... matching in queries.
const ecs_entity_t EcsPhase
Phase pipeline phase.
const ecs_entity_t EcsWorld
Entity associated with world (used for "attaching" components to world).
const ecs_entity_t EcsScopeOpen
Marker used to indicate the start of a scope ({) in queries.
const ecs_entity_t EcsRemove
Remove cleanup policy.
const ecs_entity_t EcsOverride
Override component on instantiate.
const ecs_entity_t EcsPredMatch
Marker used to indicate $var == "name" matching in queries.
const ecs_entity_t EcsInherit
Inherit component on instantiate.
const ecs_entity_t EcsModule
Tag added to module entities.
const ecs_entity_t EcsSparse
Mark component as sparse.
const ecs_entity_t EcsOnAdd
Event that triggers when an ID is added to an entity.
const ecs_entity_t EcsPrefab
Tag added to prefab entities.
const ecs_entity_t EcsOnInstantiate
Relationship that specifies component inheritance behavior.
const ecs_entity_t EcsInheritable
Mark component as inheritable.
const ecs_entity_t EcsAny
Any entity ("_").
const ecs_entity_t EcsParentDepth
Relationship storing the entity's depth in a non-fragmenting hierarchy.
const ecs_entity_t EcsWith
Ensure that a component is always added together with another component.
const ecs_entity_t EcsOnDelete
Relationship used for specifying cleanup behavior.
const ecs_entity_t EcsOnDeleteTarget
Relationship used to define what should happen when a target entity (second element of a pair) is del...
const ecs_entity_t EcsFlecs
Root scope for built-in Flecs entities.
const ecs_entity_t EcsSystem
Tag added to systems.
const ecs_entity_t EcsDisabled
When this tag is added to an entity, it is skipped by queries, unless EcsDisabled is explicitly queri...
const ecs_entity_t EcsDontInherit
Never inherit component on instantiate.
const ecs_entity_t EcsPairIsTag
Can be added to a relationship to indicate that it should never hold data, even when it or the relati...
const ecs_entity_t EcsPanic
Panic cleanup policy.
const ecs_entity_t EcsConstant
Tag added to enum or bitmask constants.
FLECS_API const ecs_entity_t EcsTrait
Can be added to components to indicate it is a trait.
FLECS_API const ecs_entity_t EcsOneOf
Ensure that a relationship target is a child of the specified entity.
FLECS_API const ecs_entity_t EcsSingleton
Mark component as singleton.
FLECS_API const ecs_entity_t EcsSymmetric
Mark relationship as commutative.
FLECS_API const ecs_entity_t EcsFinal
Ensure that an entity or component cannot be used as a target in an IsA relationship.
FLECS_API const ecs_entity_t EcsTarget
Ensure that an entity is always used in a pair as a target.
FLECS_API const ecs_entity_t EcsRelationship
Ensure that an entity is always used in a pair as a relationship.
FLECS_API const ecs_entity_t EcsAcyclic
Mark a relationship as acyclic.
FLECS_API const ecs_entity_t ecs_id(EcsDocDescription)
Component ID for EcsDocDescription.
struct ecs_component_record_t ecs_component_record_t
Information about a (component) ID, such as type info and tables with the ID.
Definition flecs.h:507
struct ecs_ref_t ecs_ref_t
A ref is a fast way to fetch a component for a specific entity.
Definition flecs.h:491
ecs_id_t ecs_entity_t
An entity identifier.
Definition flecs.h:395
struct ecs_table_record_t ecs_table_record_t
Opaque type for table record.
Definition flecs.h:541
struct ecs_world_t ecs_world_t
A world is the container for all ECS data and supporting features.
Definition flecs.h:439
uint64_t ecs_id_t
IDs are the things that can be added to an entity.
Definition flecs.h:388
struct ecs_table_t ecs_table_t
A table stores entities and components for a specific type.
Definition flecs.h:445
ecs_iter_t iter_t
Iterator type.
Definition c_types.hpp:28
ecs_query_t query_t
Query type.
Definition c_types.hpp:25
ecs_component_record_t component_record_t
Component record type.
Definition c_types.hpp:32
ecs_world_info_t world_info_t
World info type.
Definition c_types.hpp:19
ecs_term_t term_t
Term type.
Definition c_types.hpp:24
ecs_table_t table_t
Table type.
Definition c_types.hpp:23
EcsComponent Component
Built-in EcsComponent type.
Definition c_types.hpp:80
ecs_type_hooks_t type_hooks_t
Type hooks type.
Definition c_types.hpp:34
ecs_id_t id_t
ID type.
Definition c_types.hpp:20
EcsIdentifier Identifier
Built-in EcsIdentifier type.
Definition c_types.hpp:82
ecs_ref_t ref_t
Ref type.
Definition c_types.hpp:29
ecs_table_records_t table_records_t
Table records type.
Definition c_types.hpp:31
ecs_flags64_t flags64_t
64-bit flags type.
Definition c_types.hpp:36
ecs_table_record_t table_record_t
Table record type.
Definition c_types.hpp:30
oper_kind_t
Operator kind.
Definition c_types.hpp:49
ecs_entity_t entity_t
Entity type.
Definition c_types.hpp:21
EcsParent Parent
Built-in EcsParent type.
Definition c_types.hpp:86
ecs_type_t type_t
Type type.
Definition c_types.hpp:22
ecs_query_group_info_t query_group_info_t
Query group info type.
Definition c_types.hpp:26
ecs_observer_t observer_t
Observer type.
Definition c_types.hpp:27
ecs_flags32_t flags32_t
32-bit flags type.
Definition c_types.hpp:35
query_cache_kind_t
Query cache kind.
Definition c_types.hpp:60
EcsPoly Poly
Built-in EcsPoly type.
Definition c_types.hpp:84
ecs_world_t world_t
World type.
Definition c_types.hpp:18
ecs_type_info_t type_info_t
Type info type.
Definition c_types.hpp:33
inout_kind_t
Inout kind.
Definition c_types.hpp:39
@ NotFrom
NotFrom operator.
Definition c_types.hpp:56
@ OrFrom
OrFrom operator.
Definition c_types.hpp:55
@ AndFrom
AndFrom operator.
Definition c_types.hpp:54
@ And
And operator.
Definition c_types.hpp:50
@ Optional
Optional operator.
Definition c_types.hpp:53
@ Or
Or operator.
Definition c_types.hpp:51
@ Not
Not operator.
Definition c_types.hpp:52
@ QueryCacheNone
No caching.
Definition c_types.hpp:66
@ QueryCacheAll
Cache all.
Definition c_types.hpp:64
@ QueryCacheAuto
Auto query cache.
Definition c_types.hpp:62
@ QueryCacheDefault
Default query cache.
Definition c_types.hpp:61
@ In
In.
Definition c_types.hpp:44
@ Out
Out.
Definition c_types.hpp:45
@ InOutFilter
InOutFilter.
Definition c_types.hpp:42
@ InOutDefault
InOutDefault.
Definition c_types.hpp:40
@ InOut
InOut.
Definition c_types.hpp:43
@ InOutNone
InOutNone.
Definition c_types.hpp:41
const ecs_id_t ECS_PAIR
Indicate that the ID is a pair.
const ecs_id_t ECS_AUTO_OVERRIDE
Automatically override component when it is inherited.
const ecs_id_t ECS_TOGGLE
Add a bitset to storage, which allows a component to be enabled or disabled.
const ecs_id_t ECS_VALUE_PAIR
Indicate that the target of a pair is an integer value.
#define EcsIsEntity
Term ID is an entity.
Definition flecs.h:798
#define EcsIsVariable
Term ID is a variable.
Definition flecs.h:792
#define EcsIsName
Term ID is a name (don't attempt to look up as an entity).
Definition flecs.h:804
#define EcsDesc
Iterate groups in descending order.
Definition flecs.h:786
#define EcsCascade
Sort results breadth-first.
Definition flecs.h:780
#define EcsTrav
Traverse relationship transitively.
Definition flecs.h:774
#define EcsTraverseFlags
All term traversal flags.
Definition flecs.h:810
#define EcsTermRefFlags
All term reference kind flags.
Definition flecs.h:816
#define EcsUp
Match by traversing upwards.
Definition flecs.h:768
#define EcsSelf
Term ID flags.
Definition flecs.h:762
@ EcsQueryCacheAll
Require that all query terms can be cached.
Definition flecs.h:751
@ EcsQueryCacheDefault
Behavior determined by query creation context.
Definition flecs.h:748
@ EcsQueryCacheNone
No caching.
Definition flecs.h:753
@ EcsQueryCacheAuto
Cache query terms that are cacheable.
Definition flecs.h:749
@ EcsOut
Term is only written.
Definition flecs.h:732
@ EcsInOut
Term is both read and written.
Definition flecs.h:730
@ EcsInOutFilter
Same as InOutNone + prevents term from triggering observers.
Definition flecs.h:729
@ EcsInOutDefault
InOut for regular terms, In for shared terms.
Definition flecs.h:727
@ EcsInOutNone
Term is neither read nor written.
Definition flecs.h:728
@ EcsIn
Term is only read.
Definition flecs.h:731
@ EcsNot
The term must not match.
Definition flecs.h:739
@ EcsOptional
The term may match.
Definition flecs.h:740
@ EcsOr
One of the terms in an or chain must match.
Definition flecs.h:738
@ EcsOrFrom
Term must match at least one component from term ID.
Definition flecs.h:742
@ EcsAnd
The term must match.
Definition flecs.h:737
@ EcsNotFrom
Term must match none of the components from term ID.
Definition flecs.h:743
@ EcsAndFrom
Term must match all components from term ID.
Definition flecs.h:741
Component information.
Definition flecs.h:1620
A (string) identifier.
Definition flecs.h:1611
Non-fragmenting ChildOf relationship.
Definition flecs.h:1631
Component for storing a poly object.
Definition flecs.h:1626
Iterator.
Definition flecs.h:1192
An observer reacts to events matching a query.
Definition flecs.h:903
Type that contains information about a query group.
Definition flecs.h:1594
Queries are lists of constraints (terms) that match entities.
Definition flecs.h:858
Type that describes a term (single element in a query).
Definition flecs.h:834
Type that contains component information (passed to ctors/dtors/...).
Definition flecs.h:1052
A type is a list of (component) IDs.
Definition flecs.h:412
Type that contains information about the world.
Definition flecs.h:1534