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

Registry for package-extensible project-settings types. More...

#include <SettingsRegistry.h>

Public Member Functions

void Register (const char *sectionName, const DekiComponentMeta *meta)
 Register a settings type owned by deki-engine-core.
void RegisterPlugin (const char *sectionName, const DekiComponentMeta *meta)
 Register a settings type owned by a plugin/package DLL.
DekiComponentGetByName (const char *sectionName)
 Look up a settings instance by section name.
DekiComponentGetByTypeId (uint32_t typeId)
 Look up a settings instance by component type id (uint32_t hash of GUID).
template<typename T>
T * Get ()
 Type-safe lookup: T must be a registered settings type.
const std::vector< DekiSettingsTypeInfo > & GetAll () const
 All registered settings types (for the editor panel walk).
void ClearPluginSettings ()
 Clear all plugin-loaded settings instances.
void Unregister (uint32_t typeId)
 Remove a settings type by component type id.
bool IsPluginSetting (uint32_t typeId) const
 True if the type was registered via RegisterPlugin (vs Register).
void FreezeEngineSettings ()
 Snapshot current state as engine-core baseline.
std::string SnapshotPluginSettingsAsJson () const
 Snapshot every plugin-owned settings instance to a JSON string.
void RestoreFromJson (const std::string &snapshotJson)
 Restore plugin settings from a snapshot produced by SnapshotPluginSettingsAsJson().

Static Public Member Functions

static DekiSettingsRegistryInstance ()

Detailed Description

Registry for package-extensible project-settings types.

Packages declare settings types as ordinary DekiComponents tagged with DEKI_PROJECT_SETTINGS_SECTION("..."), then call DEKI_REGISTER_PROJECT_SETTINGS (engine-core) or DEKI_REGISTER_PROJECT_SETTINGS_PLUGIN (package DLL) at static init. The editor's Project Settings panel iterates the registry and renders each type's properties via the existing PropertyEditorFactory machinery — tooltips, ranges, visibility conditions all work out of the box.

The registry owns the live instance (one per registered type), unlike ComponentRegistry which only owns metadata. Plugin instances are deleted before FreeLibrary via ClearPluginSettings to avoid dangling vtables.

Member Function Documentation

◆ Instance()

DekiSettingsRegistry & DekiSettingsRegistry::Instance ( )
static

◆ Register()

void DekiSettingsRegistry::Register ( const char * sectionName,
const DekiComponentMeta * meta )

Register a settings type owned by deki-engine-core.

Parameters
sectionNameUI section header & lookup key (e.g. "Rendering")
metaComponent metadata; must contain a working createFunc.

◆ RegisterPlugin()

void DekiSettingsRegistry::RegisterPlugin ( const char * sectionName,
const DekiComponentMeta * meta )

Register a settings type owned by a plugin/package DLL.

Live instance is deleted by ClearPluginSettings() / Unregister() before the owning DLL is unloaded, preventing dangling-vtable crashes.

◆ GetByName()

DekiComponent * DekiSettingsRegistry::GetByName ( const char * sectionName)

Look up a settings instance by section name.

◆ GetByTypeId()

DekiComponent * DekiSettingsRegistry::GetByTypeId ( uint32_t typeId)

Look up a settings instance by component type id (uint32_t hash of GUID).

◆ Get()

template<typename T>
T * DekiSettingsRegistry::Get ( )
inline

Type-safe lookup: T must be a registered settings type.

◆ GetAll()

const std::vector< DekiSettingsTypeInfo > & DekiSettingsRegistry::GetAll ( ) const
inline

All registered settings types (for the editor panel walk).

◆ ClearPluginSettings()

void DekiSettingsRegistry::ClearPluginSettings ( )

Clear all plugin-loaded settings instances.

Called by PackageLoader before FreeLibrary on plugin DLLs. Engine-core registrations are preserved.

◆ Unregister()

void DekiSettingsRegistry::Unregister ( uint32_t typeId)

Remove a settings type by component type id.

Used during per-package unload to clear entries before FreeLibrary, preventing dangling pointers from one package taking down the editor when another is reloaded.

◆ IsPluginSetting()

bool DekiSettingsRegistry::IsPluginSetting ( uint32_t typeId) const

True if the type was registered via RegisterPlugin (vs Register).

◆ FreezeEngineSettings()

void DekiSettingsRegistry::FreezeEngineSettings ( )

Snapshot current state as engine-core baseline.

Call once after engine init, before any package loads. ClearPluginSettings uses the snapshot to restore instead of dereferencing potentially-stale meta pointers.

◆ SnapshotPluginSettingsAsJson()

std::string DekiSettingsRegistry::SnapshotPluginSettingsAsJson ( ) const

Snapshot every plugin-owned settings instance to a JSON string.

Used by hot reload: capture the user's edits before unloading plugin DLLs, then restore them via RestoreFromJson() after the DLLs reload and re-register their (default-valued) instances.

Engine-core settings are NOT included — those instances survive the reload because they live in deki-engine-core.dll.

The format mirrors deki.json's "packageSettings" block, so a snapshot can also be persisted to disk and restored later if needed.

◆ RestoreFromJson()

void DekiSettingsRegistry::RestoreFromJson ( const std::string & snapshotJson)

Restore plugin settings from a snapshot produced by SnapshotPluginSettingsAsJson().

Sections whose owning package didn't reload are silently skipped (the user can still recover them on the next reload). Properties that no longer exist on the new metadata are silently skipped — graceful for field renames or removals.


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