Deki 1.3.0
Modular C++ 2D engine for embedded displays and desktop
Loading...
Searching...
No Matches

Registry for component metadata. More...

#include <ComponentRegistry.h>

Public Member Functions

void Register (const DekiComponentMeta *meta)
 Register a component's metadata.
const DekiComponentMetaGetMeta (uint32_t typeId) const
 Get metadata by component type ID.
void RegisterFields (uint32_t typeId, const DekiFieldRef *fields, int count)
 Register a component's flattened field table (idempotent per typeId).
const DekiFieldRefFindField (uint32_t typeId, uint32_t nameHash) const
 Look up one field by name hash.
const DekiFieldRefGetFields (uint32_t typeId, int &outCount) const
 The whole table for a type (nullptr and outCount 0 when absent).
const DekiComponentMetaGetMeta (const std::string &name) const
 Get metadata by component serialized name (GUID).
const DekiComponentMetaGetMetaByClassName (const std::string &className) const
 Get metadata by class name (e.g., "PlatformSetupComponent").
DekiComponentCreateComponent (uint32_t typeId) const
 Create a new component instance by type ID.
DekiComponentCreateComponent (const std::string &name) const
 Create a new component instance by serialized name (GUID).
const std::vector< const DekiComponentMeta * > & GetAllComponents () const
 Get all registered components.
std::vector< const DekiComponentMeta * > GetComponentsByCategory (const std::string &category) const
 Get components by category.
std::vector< std::string > GetCategories () const
 Get all unique category names.
void RegisterPluginComponent (const DekiComponentMeta *meta)
 Register a plugin component's metadata.
void ClearPluginComponents ()
 Clear all plugin-loaded components from the registry.
bool IsPluginComponent (uint32_t typeId) const
 Check if a component type is from a plugin.
void Unregister (uint32_t typeId)
 Unregister a component by type ID.
void FreezeEngineComponents ()
 Snapshot current entries as engine-core components.
void ClearNonEngineComponents ()
 Remove ALL entries not frozen as engine-core.

Static Public Member Functions

static ComponentRegistryInstance ()

Detailed Description

Registry for component metadata.

On ESP32-S3: Minimal implementation - just provides metadata lookup by type. In Editor: Full implementation with name-based lookup and enumeration.

Member Function Documentation

◆ Instance()

ComponentRegistry & ComponentRegistry::Instance ( )
static

◆ Register()

void ComponentRegistry::Register ( const DekiComponentMeta * meta)

Register a component's metadata.

Parameters
metaPointer to static component metadata

◆ GetMeta() [1/2]

const DekiComponentMeta * ComponentRegistry::GetMeta ( uint32_t typeId) const

Get metadata by component type ID.

Parameters
typeIdThe ComponentType value
Returns
Pointer to metadata, or nullptr if not found

◆ RegisterFields()

void ComponentRegistry::RegisterFields ( uint32_t typeId,
const DekiFieldRef * fields,
int count )

Register a component's flattened field table (idempotent per typeId).

◆ FindField()

const DekiFieldRef * ComponentRegistry::FindField ( uint32_t typeId,
uint32_t nameHash ) const

Look up one field by name hash.

nullptr when absent.

◆ GetFields()

const DekiFieldRef * ComponentRegistry::GetFields ( uint32_t typeId,
int & outCount ) const

The whole table for a type (nullptr and outCount 0 when absent).

◆ GetMeta() [2/2]

const DekiComponentMeta * ComponentRegistry::GetMeta ( const std::string & name) const

Get metadata by component serialized name (GUID).

Parameters
nameThe serialized name / GUID from scene files
Returns
Pointer to metadata, or nullptr if not found

◆ GetMetaByClassName()

const DekiComponentMeta * ComponentRegistry::GetMetaByClassName ( const std::string & className) const

Get metadata by class name (e.g., "PlatformSetupComponent").

Parameters
classNameThe C++ class name
Returns
Pointer to metadata, or nullptr if not found

◆ CreateComponent() [1/2]

DekiComponent * ComponentRegistry::CreateComponent ( uint32_t typeId) const

Create a new component instance by type ID.

Parameters
typeIdThe ComponentType value
Returns
New component instance, or nullptr if not found/abstract

◆ CreateComponent() [2/2]

DekiComponent * ComponentRegistry::CreateComponent ( const std::string & name) const

Create a new component instance by serialized name (GUID).

Parameters
nameThe serialized name / GUID
Returns
New component instance, or nullptr if not found/abstract

◆ GetAllComponents()

const std::vector< const DekiComponentMeta * > & ComponentRegistry::GetAllComponents ( ) const

Get all registered components.

Returns
Vector of all registered component metadata

◆ GetComponentsByCategory()

std::vector< const DekiComponentMeta * > ComponentRegistry::GetComponentsByCategory ( const std::string & category) const

Get components by category.

Parameters
categoryThe category name (e.g., "2D")
Returns
Vector of matching component metadata

◆ GetCategories()

std::vector< std::string > ComponentRegistry::GetCategories ( ) const

Get all unique category names.

Returns
Vector of category names

◆ RegisterPluginComponent()

void ComponentRegistry::RegisterPluginComponent ( const DekiComponentMeta * meta)

Register a plugin component's metadata.

Parameters
metaPointer to static component metadata

Use this instead of Register() for plugin components so they can be properly cleared during hot-reload while preserving engine components.

◆ ClearPluginComponents()

void ComponentRegistry::ClearPluginComponents ( )

Clear all plugin-loaded components from the registry.

This is called before hot-reloading plugins. Only components registered via RegisterPluginComponent() are removed; engine components are preserved.

◆ IsPluginComponent()

bool ComponentRegistry::IsPluginComponent ( uint32_t typeId) const

Check if a component type is from a plugin.

Parameters
typeIdThe ComponentType value
Returns
true if the component was registered via RegisterPluginComponent()

◆ Unregister()

void ComponentRegistry::Unregister ( uint32_t typeId)

Unregister a component by type ID.

Parameters
typeIdThe ComponentType value

Used during package hot-reload to clear entries BEFORE FreeLibrary, preventing dangling pointers in the registry.

◆ FreezeEngineComponents()

void ComponentRegistry::FreezeEngineComponents ( )

Snapshot current entries as engine-core components.

Call once after engine initialization, before loading any packages. Frozen entries are preserved by ClearNonEngineComponents().

◆ ClearNonEngineComponents()

void ComponentRegistry::ClearNonEngineComponents ( )

Remove ALL entries not frozen as engine-core.

Atomically clears every package and plugin component from the registry, ensuring no stale pointers survive after FreeLibrary.


The documentation for this class was generated from the following file: