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

Registry of project-settings types, which packages can add to. More...

#include <deki/reflection/SettingsRegistry.h>

Public Member Functions

void Register (const char *sectionName, const ComponentMeta *meta)
 Registers a settings type owned by deki-engine-core.
void RegisterPlugin (const char *sectionName, const ComponentMeta *meta)
 Registers a settings type owned by a plugin or package DLL.
Component * GetByName (const char *sectionName)
 The settings instance for a section name.
Component * GetByTypeId (uint32_t typeId)
 The settings instance for a component type id.
template<typename T>
T * Get ()
 The instance of settings type T, which must be registered.
const std::vector< SettingsTypeInfo > & GetAll () const
 All registered settings types, for the Project Settings panel.
void ClearPluginSettings ()
 Deletes every plugin settings instance and keeps the engine-core ones.
void Unregister (uint32_t typeId)
 Removes a settings type.
bool IsPluginSetting (uint32_t typeId) const
 True if the type was registered with RegisterPlugin, not Register.
void FreezeEngineSettings ()
 Saves the current state as the engine-core baseline.
std::string SnapshotPluginSettingsAsJson () const
 Writes every plugin-owned settings instance to a JSON string.
void RestoreFromJson (const std::string &snapshotJson)
 Restores plugin settings from a SnapshotPluginSettingsAsJson() snapshot.

Static Public Member Functions

static SettingsRegistry & Instance ()

Detailed Description

Registry of project-settings types, which packages can add to.

Packages declare settings types as ordinary components with a DEKI_SETTINGS_SECTION("...") marker above the class, and the codegen registers them here from the package's registration function. The Project Settings panel walks the registry and draws each type's properties with PropertyEditorFactory, so tooltips, ranges and visibility conditions all work.

Unlike ComponentRegistry, which holds only metadata, this registry owns one live instance per type. Plugin instances are deleted by ClearPluginSettings before FreeLibrary, so no vtable is left dangling.

Member Function Documentation

◆ Instance()

SettingsRegistry & Deki::SettingsRegistry::Instance ( )
static

◆ Register()

void Deki::SettingsRegistry::Register ( const char * sectionName,
const ComponentMeta * meta )

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

sectionName is the panel's section header and lookup key (e.g. "Rendering"). meta must have a working createFunc.

◆ RegisterPlugin()

void Deki::SettingsRegistry::RegisterPlugin ( const char * sectionName,
const ComponentMeta * meta )

Registers a settings type owned by a plugin or package DLL.

Its instance is deleted by ClearPluginSettings() or Unregister() before the DLL unloads, so no vtable is left dangling.

◆ GetByName()

Component * Deki::SettingsRegistry::GetByName ( const char * sectionName)

The settings instance for a section name.

◆ GetByTypeId()

Component * Deki::SettingsRegistry::GetByTypeId ( uint32_t typeId)

The settings instance for a component type id.

◆ Get()

template<typename T>
T * Deki::SettingsRegistry::Get ( )
inline

The instance of settings type T, which must be registered.

◆ GetAll()

const std::vector< SettingsTypeInfo > & Deki::SettingsRegistry::GetAll ( ) const
inline

All registered settings types, for the Project Settings panel.

◆ ClearPluginSettings()

void Deki::SettingsRegistry::ClearPluginSettings ( )

Deletes every plugin settings instance and keeps the engine-core ones.

PackageLoader calls it before FreeLibrary on plugin DLLs.

◆ Unregister()

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

Removes a settings type.

Called when a single package unloads, before FreeLibrary, so its stale pointers cannot crash the editor when another package reloads.

◆ IsPluginSetting()

bool Deki::SettingsRegistry::IsPluginSetting ( uint32_t typeId) const

True if the type was registered with RegisterPlugin, not Register.

◆ FreezeEngineSettings()

void Deki::SettingsRegistry::FreezeEngineSettings ( )

Saves the current state as the engine-core baseline.

Call once after engine init, before any package loads. ClearPluginSettings restores from it instead of dereferencing possibly stale meta pointers.

◆ SnapshotPluginSettingsAsJson()

std::string Deki::SettingsRegistry::SnapshotPluginSettingsAsJson ( ) const

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

Hot reload uses it to keep the user's edits: snapshot before unloading plugin DLLs, then RestoreFromJson() once the DLLs have reloaded and registered fresh default instances. Engine-core settings are left out; they live in deki-engine-core.dll and survive the reload.

The format matches deki.json's "packageSettings" block, so a snapshot can also be saved to disk.

◆ RestoreFromJson()

void Deki::SettingsRegistry::RestoreFromJson ( const std::string & snapshotJson)

Restores plugin settings from a SnapshotPluginSettingsAsJson() snapshot.

Sections whose package did not reload are skipped and can be restored on the next reload. Properties the new metadata no longer has are skipped, so renamed or removed fields do no harm.


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