Deki 1.3.0
Modular C++ 2D engine for embedded displays and desktop
Loading...
Searching...
No Matches
SceneFormat::ComponentFactory Class Reference

Creates components by type id (see the file comment above). More...

#include <ComponentFactory.h>

Public Member Functions

void Register (uint32_t typeId, ComponentCreator creator)
 Register a component type for creation.
void Unregister (uint32_t typeId)
 Unregister a component type.
DekiComponentCreate (uint32_t typeId)
 Create a component by type ID.
bool IsRegistered (uint32_t typeId) const
 Check if a component type is registered.
size_t GetRegisteredCount () const
 Get number of registered components.
void Clear ()
 Clear all registered components.

Static Public Member Functions

static ComponentFactory & Instance ()
 Get singleton instance.

Detailed Description

Creates components by type id (see the file comment above).

O(1) lookup for all components regardless of count. ~48 bytes memory per registered component.

Member Function Documentation

◆ Instance()

ComponentFactory & SceneFormat::ComponentFactory::Instance ( )
static

Get singleton instance.

◆ Register()

void SceneFormat::ComponentFactory::Register ( uint32_t typeId,
ComponentCreator creator )
inline

Register a component type for creation.

Parameters
typeIdHash of component class name (use ClassName::StaticType)
creatorFunction that creates a new instance

◆ Unregister()

void SceneFormat::ComponentFactory::Unregister ( uint32_t typeId)
inline

Unregister a component type.

Parameters
typeIdHash of component class name

◆ Create()

DekiComponent * SceneFormat::ComponentFactory::Create ( uint32_t typeId)
inline

Create a component by type ID.

Parameters
typeIdHash of component class name
Returns
New component instance, or nullptr if type not found

◆ IsRegistered()

bool SceneFormat::ComponentFactory::IsRegistered ( uint32_t typeId) const
inline

Check if a component type is registered.

Parameters
typeIdHash of component class name
Returns
true if type can be created

◆ GetRegisteredCount()

size_t SceneFormat::ComponentFactory::GetRegisteredCount ( ) const
inline

Get number of registered components.

◆ Clear()

void SceneFormat::ComponentFactory::Clear ( )
inline

Clear all registered components.

Useful for plugin hot-reload scenarios.


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