Flecs v4.0
A fast entity component system (ECS) for C & C++
Loading...
Searching...
No Matches
c_types.hpp
Go to the documentation of this file.
1
6#pragma once
7
8namespace flecs {
9
18using world_t = ecs_world_t;
19using world_info_t = ecs_world_info_t;
20using id_t = ecs_id_t;
21using entity_t = ecs_entity_t;
22using type_t = ecs_type_t;
23using table_t = ecs_table_t;
24using term_t = ecs_term_t;
25using query_t = ecs_query_t;
26using query_group_info_t = ecs_query_group_info_t;
27using observer_t = ecs_observer_t;
28using iter_t = ecs_iter_t;
29using ref_t = ecs_ref_t;
30using type_info_t = ecs_type_info_t;
31using type_hooks_t = ecs_type_hooks_t;
32using flags32_t = ecs_flags32_t;
33
34enum inout_kind_t {
35 InOutDefault = EcsInOutDefault,
36 InOutNone = EcsInOutNone,
37 InOutFilter = EcsInOutFilter,
38 InOut = EcsInOut,
39 In = EcsIn,
40 Out = EcsOut
41};
42
43enum oper_kind_t {
44 And = EcsAnd,
45 Or = EcsOr,
46 Not = EcsNot,
47 Optional = EcsOptional,
48 AndFrom = EcsAndFrom,
49 OrFrom = EcsOrFrom,
50 NotFrom = EcsNotFrom
51};
52
53enum query_cache_kind_t {
54 QueryCacheDefault = EcsQueryCacheDefault,
55 QueryCacheAuto = EcsQueryCacheAuto,
56 QueryCacheAll = EcsQueryCacheAll,
57 QueryCacheNone = EcsQueryCacheNone
58};
59
61static const flecs::entity_t PAIR = ECS_PAIR;
62static const flecs::entity_t AUTO_OVERRIDE = ECS_AUTO_OVERRIDE;
63static const flecs::entity_t TOGGLE = ECS_TOGGLE;
64
68
69/* Builtin components */
70using Component = EcsComponent;
71using Identifier = EcsIdentifier;
72using Poly = EcsPoly;
73using DefaultChildComponent = EcsDefaultChildComponent;
74
75/* Builtin tags */
76static const flecs::entity_t Query = EcsQuery;
77static const flecs::entity_t Observer = EcsObserver;
78static const flecs::entity_t Private = EcsPrivate;
79static const flecs::entity_t Module = EcsModule;
80static const flecs::entity_t Prefab = EcsPrefab;
81static const flecs::entity_t Disabled = EcsDisabled;
82static const flecs::entity_t Empty = EcsEmpty;
83static const flecs::entity_t Monitor = EcsMonitor;
84static const flecs::entity_t System = EcsSystem;
85static const flecs::entity_t Pipeline = ecs_id(EcsPipeline);
86static const flecs::entity_t Phase = EcsPhase;
87
88/* Builtin event tags */
89static const flecs::entity_t OnAdd = EcsOnAdd;
90static const flecs::entity_t OnRemove = EcsOnRemove;
91static const flecs::entity_t OnSet = EcsOnSet;
92static const flecs::entity_t OnTableCreate = EcsOnTableCreate;
93static const flecs::entity_t OnTableDelete = EcsOnTableDelete;
94
95/* Builtin term flags */
96static const uint64_t Self = EcsSelf;
97static const uint64_t Up = EcsUp;
98static const uint64_t Trav = EcsTrav;
99static const uint64_t Cascade = EcsCascade;
100static const uint64_t Desc = EcsDesc;
101static const uint64_t IsVariable = EcsIsVariable;
102static const uint64_t IsEntity = EcsIsEntity;
103static const uint64_t IsName = EcsIsName;
104static const uint64_t TraverseFlags = EcsTraverseFlags;
105static const uint64_t TermRefFlags = EcsTermRefFlags;
106
107/* Builtin entity ids */
108static const flecs::entity_t Flecs = EcsFlecs;
109static const flecs::entity_t FlecsCore = EcsFlecsCore;
110static const flecs::entity_t World = EcsWorld;
111
112/* Component traits */
113static const flecs::entity_t Wildcard = EcsWildcard;
114static const flecs::entity_t Any = EcsAny;
115static const flecs::entity_t This = EcsThis;
116static const flecs::entity_t Transitive = EcsTransitive;
117static const flecs::entity_t Reflexive = EcsReflexive;
118static const flecs::entity_t Final = EcsFinal;
119static const flecs::entity_t PairIsTag = EcsPairIsTag;
120static const flecs::entity_t Exclusive = EcsExclusive;
121static const flecs::entity_t Acyclic = EcsAcyclic;
122static const flecs::entity_t Traversable = EcsTraversable;
123static const flecs::entity_t Symmetric = EcsSymmetric;
124static const flecs::entity_t With = EcsWith;
125static const flecs::entity_t OneOf = EcsOneOf;
126static const flecs::entity_t Trait = EcsTrait;
127static const flecs::entity_t Relationship = EcsRelationship;
128static const flecs::entity_t Target = EcsTarget;
129static const flecs::entity_t CanToggle = EcsCanToggle;
130
131/* OnInstantiate trait */
132static const flecs::entity_t OnInstantiate = EcsOnInstantiate;
133static const flecs::entity_t Override = EcsOverride;
134static const flecs::entity_t Inherit = EcsInherit;
135static const flecs::entity_t DontInherit = EcsDontInherit;
136
137/* OnDelete/OnDeleteTarget traits */
138static const flecs::entity_t OnDelete = EcsOnDelete;
139static const flecs::entity_t OnDeleteTarget = EcsOnDeleteTarget;
140static const flecs::entity_t Remove = EcsRemove;
141static const flecs::entity_t Delete = EcsDelete;
142static const flecs::entity_t Panic = EcsPanic;
143
144/* Builtin relationships */
145static const flecs::entity_t IsA = EcsIsA;
146static const flecs::entity_t ChildOf = EcsChildOf;
147static const flecs::entity_t DependsOn = EcsDependsOn;
148static const flecs::entity_t SlotOf = EcsSlotOf;
149
150/* Builtin identifiers */
151static const flecs::entity_t Name = EcsName;
152static const flecs::entity_t Symbol = EcsSymbol;
153
154/* Storage */
155static const flecs::entity_t Sparse = EcsSparse;
156static const flecs::entity_t Union = EcsUnion;
157
158/* Builtin predicates for comparing entity ids in queries. */
159static const flecs::entity_t PredEq = EcsPredEq;
160static const flecs::entity_t PredMatch = EcsPredMatch;
161static const flecs::entity_t PredLookup = EcsPredLookup;
162
163/* Builtin marker entities for query scopes */
164static const flecs::entity_t ScopeOpen = EcsScopeOpen;
165static const flecs::entity_t ScopeClose = EcsScopeClose;
166
169}
struct EcsIdentifier EcsIdentifier
A (string) identifier.
struct EcsPoly EcsPoly
Component for storing a poly object.
struct EcsDefaultChildComponent EcsDefaultChildComponent
When added to an entity this informs serialization formats which component to use when a value is ass...
struct EcsComponent EcsComponent
Component information.
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 EcsAcyclic
Marks a relationship as acyclic.
const ecs_entity_t EcsSymmetric
Marks relationship as commutative.
const ecs_entity_t EcsOnSet
Event that triggers when a component is set for an entity.
const ecs_entity_t EcsReflexive
Marks a relationship as reflexive.
const ecs_entity_t EcsTrait
Can be added to components to indicate it is a trait.
const ecs_entity_t EcsEmpty
Tag used to indicate query is empty.
const ecs_entity_t EcsOneOf
Ensure that relationship target is child of specified entity.
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 EcsRelationship
Ensure that an entity is always used in pair as relationship.
const ecs_entity_t EcsTraversable
Marks 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 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
Marks 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 observer when an entity starts/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 EcsPrivate
Tag to indicate an entity/component/system is private to a module.
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 EcsSlotOf
Used to express a slot (used with prefab inheritance)
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 EcsUnion
Mark relationship as union.
const ecs_entity_t EcsAny
Any entity ("_").
const ecs_entity_t EcsTarget
Ensure that an entity is always used in pair as target.
const ecs_entity_t EcsWith
Ensure that a component always is 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 builtin 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 querie...
const ecs_entity_t EcsDontInherit
Never inherit component on instantiate.
const ecs_entity_t EcsPairIsTag
Can be added to relationship to indicate that it should never hold data, even when it or the relation...
const ecs_entity_t EcsPanic
Panic cleanup policy.
const ecs_entity_t EcsFinal
Ensures that entity/component cannot be used as target in IsA relationship.
FLECS_API const ecs_entity_t ecs_id(EcsDocDescription)
Component id for EcsDocDescription.
struct ecs_term_t ecs_term_t
A term is a single element in a query.
Definition flecs.h:400
struct ecs_type_info_t ecs_type_info_t
Type information.
Definition flecs.h:453
struct ecs_observer_t ecs_observer_t
An observer is a system that is invoked when an event matches its query.
Definition flecs.h:422
struct ecs_ref_t ecs_ref_t
A ref is a fast way to fetch a component for a specific entity.
Definition flecs.h:443
ecs_id_t ecs_entity_t
An entity identifier.
Definition flecs.h:347
struct ecs_world_t ecs_world_t
A world is the container for all ECS data and supporting features.
Definition flecs.h:391
struct ecs_type_hooks_t ecs_type_hooks_t
Type hooks are callbacks associated with component lifecycle events.
Definition flecs.h:448
uint64_t ecs_id_t
Ids are the things that can be added to an entity.
Definition flecs.h:340
struct ecs_query_t ecs_query_t
A query returns entities matching a list of constraints.
Definition flecs.h:403
struct ecs_table_t ecs_table_t
A table stores entities and components for a specific type.
Definition flecs.h:397
struct ecs_iter_t ecs_iter_t
Type used for iterating iterable objects.
Definition flecs.h:433
const ecs_id_t ECS_PAIR
Indicates 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
Adds bitset to storage which allows component to be enabled/disabled.
struct ecs_world_info_t ecs_world_info_t
Type that contains information about the world.
struct ecs_query_group_info_t ecs_query_group_info_t
Type that contains information about a query group.
#define EcsIsEntity
Term id is an entity.
Definition flecs.h:732
#define EcsIsVariable
Term id is a variable.
Definition flecs.h:726
#define EcsIsName
Term id is a name (don't attempt to lookup as entity).
Definition flecs.h:738
#define EcsDesc
Iterate groups in descending order.
Definition flecs.h:720
#define EcsCascade
Sort results breadth first.
Definition flecs.h:714
#define EcsTrav
Traverse relationship transitively.
Definition flecs.h:708
#define EcsTraverseFlags
All term traversal flags.
Definition flecs.h:744
#define EcsTermRefFlags
All term reference kind flags.
Definition flecs.h:750
#define EcsUp
Match by traversing upwards.
Definition flecs.h:702
#define EcsSelf
Match on self.
Definition flecs.h:696
@ EcsQueryCacheAll
Require that all query terms can be cached.
Definition flecs.h:686
@ EcsQueryCacheDefault
Behavior determined by query creation context.
Definition flecs.h:684
@ EcsQueryCacheNone
No caching.
Definition flecs.h:687
@ EcsQueryCacheAuto
Cache query terms that are cacheable.
Definition flecs.h:685
@ EcsOut
Term is only written.
Definition flecs.h:668
@ EcsInOut
Term is both read and written.
Definition flecs.h:666
@ EcsInOutFilter
Same as InOutNone + prevents term from triggering observers.
Definition flecs.h:665
@ EcsInOutDefault
InOut for regular terms, In for shared terms.
Definition flecs.h:663
@ EcsInOutNone
Term is neither read nor written.
Definition flecs.h:664
@ EcsIn
Term is only read.
Definition flecs.h:667
@ EcsNot
The term must not match.
Definition flecs.h:675
@ EcsOptional
The term may match.
Definition flecs.h:676
@ EcsOr
One of the terms in an or chain must match.
Definition flecs.h:674
@ EcsOrFrom
Term must match at least one component from term id.
Definition flecs.h:678
@ EcsAnd
The term must match.
Definition flecs.h:673
@ EcsNotFrom
Term must match none of the components from term id.
Definition flecs.h:679
@ EcsAndFrom
Term must match all components from term id.
Definition flecs.h:677
A type is a list of (component) ids.
Definition flecs.h:364