DEKI/ENGINE docs
manual api reference
Deki 0.40.1
Modular C++ engine with a visual editor, for 2D and 3D
Loading...
Searching...
No Matches
Deki::ComponentRegistry Class Reference

Component metadata and field tables, by type id and, in the editor, by name. More...

#include <deki/reflection/ComponentRegistry.h>

Public Member Functions

void ClearNonEngineComponents ()
 Removes every package and plugin component in one step, so no stale pointer survives FreeLibrary.
void ClearPluginComponents ()
 Removes the components registered with RegisterPluginComponent().
Component * CreateComponent (const std::string &name) const
 Creates a component by serialized name.
Component * CreateComponent (uint32_t typeId) const
 Creates a component by type id.
const FieldRef * FindField (uint32_t typeId, uint32_t nameHash) const
 One field by name hash, or nullptr when absent.
void FreezeEngineComponents ()
 Marks the current entries as engine-core.
const std::vector< const ComponentMeta * > & GetAllComponents () const
std::vector< std::string > GetCategories () const
 Every category name, each once.
std::vector< const ComponentMeta * > GetComponentsByCategory (const std::string &category) const
 Components in a category (e.g. "2D").
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 * GetMeta (uint32_t typeId) const
 Metadata for a type id, 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.
bool IsPluginComponent (uint32_t typeId) const
 True when the component was registered with RegisterPluginComponent().
void Register (const ComponentMeta *meta)
 Registers a component's static metadata.
void RegisterFields (uint32_t typeId, const FieldRef *fields, int count)
 Registers a component's field table.
void RegisterPluginComponent (const ComponentMeta *meta)
 Registers a plugin component.
void Unregister (uint32_t typeId)
 Removes a component.

Static Public Member Functions

static ComponentRegistry & Instance ()

Detailed Description

Component metadata and field tables, by type id and, in the editor, by name.

Member Function Documentation

◆ ClearNonEngineComponents()

void Deki::ComponentRegistry::ClearNonEngineComponents ( )

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

◆ ClearPluginComponents()

void Deki::ComponentRegistry::ClearPluginComponents ( )

Removes the components registered with RegisterPluginComponent().

Called before plugins hot-reload.

◆ CreateComponent() [1/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.

◆ CreateComponent() [2/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.

◆ FindField()

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

One field by name hash, or nullptr when absent.

◆ FreezeEngineComponents()

void Deki::ComponentRegistry::FreezeEngineComponents ( )

Marks the current entries as engine-core.

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

◆ GetAllComponents()

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

◆ GetCategories()

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

Every category name, each once.

◆ GetComponentsByCategory()

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

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

◆ 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() [1/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.

◆ GetMeta() [2/2]

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

Metadata for a type id, or nullptr when unknown.

◆ 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.

◆ Instance()

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

◆ IsPluginComponent()

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

True when the component was registered with RegisterPluginComponent().

◆ Register()

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

Registers a component's static metadata.

◆ 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.

◆ 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.

◆ 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.


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