component.h¶
| File Path | engine/include/conjure/ecs/component.h |
| API ↗ | Entities and components |
Components.
Structs¶
| File | Description |
|---|---|
component_id |
Dense index of a component type within one registry. INVALID means "no component". |
component_info |
Everything the registry knows about one component type. A registered component_info stays at a stable address for the registry's lifetime. |
component_mask::hasher |
Hasher for std::unordered_map keys. |
component_ops |
Lifecycle hooks of a non-trivial component. A null pointer selects the trivial path: zero-fill or the registered default bytes for construction, no-op destruction, memcpy for relocation and copy. |
component_serializer |
Serialisation hooks of a component type. Null hooks select the reflection-driven default, which walks component_info::reflection (serialization.h). remapEntities is consulted only when a type stores entity references that reflection cannot see: entity_archive::capture calls it with a table whose targets are the captured entities (real -> archive-local) and world::instantiate with the table of the created copy (archive-local -> real). A hook rewrites each reference through entity_remap::remap, which serves both directions; references to entities outside the archive are left as they are (archive_options::keepExternalReferences only governs reflected fields). |
component_type_cache |
The per-type lookup cache behind component_registry::id_of: one atomic word packing (registrySerial << 16) | id. A serial mismatch means "look the name up again". The static lives per shared library but only caches a lookup result, so every library agrees. |
Classes¶
| File | Description |
|---|---|
component_mask |
A set of component ids: one bit per id. Archetype matching is a handful of 64-bit operations. |
Enumerations¶
component_flags¶
enum class component_flags : u32 {
NONE = 0,
TAG = 1 << 0, // size 0, lives only in the mask
TRIVIAL = 1 << 1, // memcpy relocate/copy, no destructor
DYNAMIC = 1 << 2, // registered at runtime (C#), fields described by data
TRANSIENT = 1 << 3, // never serialised, no reflection required
EDITOR_HIDDEN = 1 << 4 // internal types (unresolved_components); area H calls this INTERNAL
};
Properties of a component type.
Concepts¶
named_component¶
template <typename ComponentType> concept named_component = requires { { component_name<std::remove_cvref_t<ComponentType>>::VALUE } -> std::convertible_to<std::string_view>; };
True when CONJURE_COMPONENT named the type.
Forward Declarations¶
component_name¶
The registered name of a C++ component type. Specialised by CONJURE_COMPONENT; the name's string_id is the registry key, so the same name yields the same id in every registry.
json::value¶
json::writer¶
reflect::type_info¶
Constants¶
| Name | Type | Value | Description |
|---|---|---|---|
MAX_COMPONENT_ALIGNMENT |
inline constexpr u32 |
64 |
Strictest component alignment accepted. |
MAX_COMPONENT_SIZE |
inline constexpr u32 |
4096 |
Largest component in bytes; larger data belongs behind an asset handle. |
MAX_COMPONENTS |
inline constexpr u32 |
1024 |
Most component types one registry can hold. |
Macros¶
CONJURE_ENUM_FLAGS¶
Functions¶
Public¶
default_component_bytes¶
default_component_bytes¶template <typename ComponentType> [[nodiscard]] std::vector<std::byte> default_component_bytes();The default bytes of a trivially copyable type with a non-trivial default constructor (member initialisers), constructed into zeroed storage so padding stays zero. Empty when zero-fill is already the default or the type is not trivially copyable.
derive_component_flags¶
derive_component_flags¶template <typename ComponentType> [[nodiscard]] constexpr component_flags derive_component_flags(
component_flags extra) noexcept;The flags a C++ type implies: TAG for empty types, TRIVIAL for trivially copyable ones, combined with the caller's extra flags.
detail::construct_default_components¶
detail::construct_default_components¶template <typename ComponentType> void construct_default_components(void *destination, u32 count);detail::copy_components¶
detail::copy_components¶template <typename ComponentType> void copy_components(void *destination, const void *source, u32 count);detail::destruct_components¶
detail::destruct_components¶template <typename ComponentType> void destruct_components(void *object, u32 count);detail::relocate_components¶
detail::relocate_components¶template <typename ComponentType> void relocate_components(void *destination, void *source, u32 count);make_component_ops¶
make_component_ops¶template <typename ComponentType> [[nodiscard]] component_ops make_component_ops() noexcept;The lifecycle hooks of a C++ type: all null for trivially copyable types (the memcpy path), otherwise the type's special members.