DEKI/ENGINE docs
Deki 0.19.0
Modular C++ 2D engine for embedded displays and desktop
Loading...
Searching...
No Matches
Deki::ComponentRegistry Class Reference

#include <deki/reflection/ComponentRegistry.h>

Public Member Functions

void Register (const ComponentMeta *meta)
 Registers a component's static metadata.
const ComponentMeta * GetMeta (uint32_t typeId) const
 Metadata for a type id, or nullptr when unknown.
void RegisterFields (uint32_t typeId, const FieldRef *fields, int count)
 Registers a component's field table.
const FieldRef * FindField (uint32_t typeId, uint32_t nameHash) const
 One field by name hash, or nullptr when absent.
const FieldRef * GetFields (uint32_t typeId, int &outCount) const
 The whole table for a type, or nullptr and outCount 0 when absent.
const ComponentMeta * GetMeta (const std::string &name) const
 Metadata for a serialized name from a scene file, or nullptr when unknown.
const ComponentMeta * GetMetaByClassName (const std::string &className) const
 Metadata for a C++ class name (e.g. "PlatformSetupComponent"), or nullptr.
const ComponentMeta * GetMetaByFormerTypeId (uint32_t formerTypeId) const
 Metadata for a type id that is the hash of a name a component used to have, or nullptr when no component ever had that name.
Component * CreateComponent (uint32_t typeId) const
 Creates a component by type id.
Component * CreateComponent (const std::string &name) const
 Creates a component by serialized name.
const std::vector< const ComponentMeta * > & GetAllComponents () const
std::vector< const ComponentMeta * > GetComponentsByCategory (const std::string &category) const
 Components in a category (e.g. "2D").
std::vector< std::string > GetCategories () const
 Every category name, each once.
void RegisterPluginComponent (const ComponentMeta *meta)
 Registers a plugin component.
void ClearPluginComponents ()
 Removes the components registered with RegisterPluginComponent().
bool IsPluginComponent (uint32_t typeId) const
 True when the component was registered with RegisterPluginComponent().
void Unregister (uint32_t typeId)
 Removes a component.
void FreezeEngineComponents ()
 Marks the current entries as engine-core.
void ClearNonEngineComponents ()
 Removes every package and plugin component in one step, so no stale pointer survives FreeLibrary.

Static Public Member Functions

static ComponentRegistry & Instance ()

Member Function Documentation

◆ Instance()

ComponentRegistry & Deki::ComponentRegistry::Instance ( )
static

◆ Register()

void Deki::ComponentRegistry::Register ( const ComponentMeta * meta)

Registers a component's static metadata.

◆ GetMeta() [1/2]

const ComponentMeta * Deki::ComponentRegistry::GetMeta ( uint32_t typeId) const

Metadata for a type id, or nullptr when unknown.

◆ RegisterFields()

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

Registers a component's field table.

Registering the same typeId again replaces the table, for hot reload.

◆ FindField()

const FieldRef * Deki::ComponentRegistry::FindField ( uint32_t typeId,
uint32_t nameHash ) const

One field by name hash, or nullptr when absent.

◆ GetFields()

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

The whole table for a type, or nullptr and outCount 0 when absent.

◆ GetMeta() [2/2]

const ComponentMeta * Deki::ComponentRegistry::GetMeta ( const std::string & name) const

Metadata for a serialized name from a scene file, or nullptr when unknown.

Falls back to DEKI_FORMER_NAME.

◆ GetMetaByClassName()

const ComponentMeta * Deki::ComponentRegistry::GetMetaByClassName ( const std::string & className) const

Metadata for a C++ class name (e.g. "PlatformSetupComponent"), or nullptr.

◆ GetMetaByFormerTypeId()

const ComponentMeta * Deki::ComponentRegistry::GetMetaByFormerTypeId ( uint32_t formerTypeId) const

Metadata for a type id that is the hash of a name a component used to have, or nullptr when no component ever had that name.

Scenes store some component references as a bare type id with no name (ObjectRef::componentTypeId, PropertyRef::componentTypeId). That id is the hash of the class name at save time, and a hash cannot be turned back into a name, so GetMeta(name) cannot resolve it. This looks up HashString(formerName) instead. Callers rewrite the reference to the current id, so the file is migrated on its next save.

◆ CreateComponent() [1/2]

Component * Deki::ComponentRegistry::CreateComponent ( uint32_t typeId) const

Creates a component by type id.

Returns nullptr when the id is unknown or the class is abstract.

◆ CreateComponent() [2/2]

Component * Deki::ComponentRegistry::CreateComponent ( const std::string & name) const

Creates a component by serialized name.

Returns nullptr when the name is unknown or the class is abstract.

◆ GetAllComponents()

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

◆ GetComponentsByCategory()

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

Components in a category (e.g. "2D").

◆ GetCategories()

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

Every category name, each once.

◆ RegisterPluginComponent()

void Deki::ComponentRegistry::RegisterPluginComponent ( const ComponentMeta * meta)

Registers a plugin component.

Use it instead of Register() for plugins, so hot-reload can clear them and keep the engine components.

◆ ClearPluginComponents()

void Deki::ComponentRegistry::ClearPluginComponents ( )

Removes the components registered with RegisterPluginComponent().

Called before plugins hot-reload.

◆ IsPluginComponent()

bool Deki::ComponentRegistry::IsPluginComponent ( uint32_t typeId) const

True when the component was registered with RegisterPluginComponent().

◆ Unregister()

void Deki::ComponentRegistry::Unregister ( uint32_t typeId)

Removes a component.

Package hot-reload calls it before FreeLibrary, so the registry holds no pointers into the unloaded DLL.

◆ FreezeEngineComponents()

void Deki::ComponentRegistry::FreezeEngineComponents ( )

Marks the current entries as engine-core.

Call once after engine init, before loading any packages. ClearNonEngineComponents() keeps them.

◆ ClearNonEngineComponents()

void Deki::ComponentRegistry::ClearNonEngineComponents ( )

Removes every package and plugin component in one step, so no stale pointer survives FreeLibrary.


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