ReXGlue SDK
Loading...
Searching...
No Matches
rex::SettingsRegistry Class Referencefinal

#include <rex/settings_registry.h>

Inheritance diagram for rex::SettingsRegistry:
[legend]

Public Member Functions

Result< void > Register (SettingOwner &owner) override
void Unregister (SettingOwner &owner) override
Result< SettingBase * > Find (std::string_view name) const override
std::vector< SettingBase * > Enumerate (std::string_view scope={}) const override
std::vector< ConsoleCommand * > EnumerateCommands (std::string_view scope={}) const override
Result< void > SetText (std::string_view name, std::string_view text) override
Result< void > SetText (SettingLayer layer, std::string_view name, std::string_view text) override
void AddAlias (std::string_view old_name, std::string_view new_name) override
bool IsAlias (std::string_view name) const override
Result< void > Reset (std::string_view name) override
Result< void > Run (std::string_view name, std::string_view args) override
std::vector< std::string > GetRestartPending () const override
Result< void > Save (const std::filesystem::path &file) const override
Result< void > Load (const std::filesystem::path &file, SettingLayer layer=SettingLayer::kRuntime) override

Friends

class ProcessSettingsControl
class SettingBase
class ConsoleCommand
SettingsRegistry & GetSettingsRegistry ()

Detailed Description

The process settings registry, reached through GetSettingsRegistry() and, for modules, ISettingsRegistry.

Member Function Documentation

◆ AddAlias()

void rex::SettingsRegistry::AddAlias ( std::string_view old_name,
std::string_view new_name )
overridevirtual

Maps an old name to the setting that replaced it. Each use of an old name adds one notice.

Parameters
new_nameThe new full name, empty when the old name was removed and its values are ignored.

Implements rex::ISettingsRegistry.

◆ Enumerate()

std::vector< SettingBase * > rex::SettingsRegistry::Enumerate ( std::string_view scope = {}) const
overridevirtual

Lists registered settings, sorted by name.

Parameters
scopeOnly settings under this scope, every setting when empty.

Implements rex::ISettingsRegistry.

◆ EnumerateCommands()

std::vector< ConsoleCommand * > rex::SettingsRegistry::EnumerateCommands ( std::string_view scope = {}) const
overridevirtual

Lists registered commands, sorted by name.

Parameters
scopeOnly commands under this scope, every command when empty.

Implements rex::ISettingsRegistry.

◆ Find()

Result< SettingBase * > rex::SettingsRegistry::Find ( std::string_view name) const
nodiscardoverridevirtual

Finds a setting by full name.

Returns
The setting, or kNotFound.

Implements rex::ISettingsRegistry.

◆ GetRestartPending()

std::vector< std::string > rex::SettingsRegistry::GetRestartPending ( ) const
overridevirtual

Lists the kRestart settings whose change waits for the next start.

Implements rex::ISettingsRegistry.

◆ IsAlias()

bool rex::SettingsRegistry::IsAlias ( std::string_view name) const
nodiscardoverridevirtual

Reports whether a name is an old name in the alias table, removed names included.

Parameters
nameThe name to look up.
Returns
True when SetText resolves the name through an alias.

Implements rex::ISettingsRegistry.

◆ Load()

Result< void > rex::SettingsRegistry::Load ( const std::filesystem::path & file,
SettingLayer layer = SettingLayer::kRuntime )
nodiscardoverridevirtual

Reads a TOML file into the runtime layer. Old names apply through the alias table.

Parameters
layerThe layer the values apply at.
Returns
Ok, or an error naming the file and the first refused value.

Implements rex::ISettingsRegistry.

◆ Register()

Result< void > rex::SettingsRegistry::Register ( SettingOwner & owner)
nodiscardoverridevirtual

Registers an owner and applies values waiting for its settings.

Returns
Ok, or an error naming both owners when a full name is already registered.

Implements rex::ISettingsRegistry.

◆ Reset()

Result< void > rex::SettingsRegistry::Reset ( std::string_view name)
nodiscardoverridevirtual

Returns a setting to its default. The result is Ok, kNotFound, or an error when it is frozen.

Implements rex::ISettingsRegistry.

◆ Run()

Result< void > rex::SettingsRegistry::Run ( std::string_view name,
std::string_view args )
nodiscardoverridevirtual

Runs a command.

Returns
What the command returned, or kNotFound.

Implements rex::ISettingsRegistry.

◆ Save()

Result< void > rex::SettingsRegistry::Save ( const std::filesystem::path & file) const
nodiscardoverridevirtual

Writes every saved setting that differs from its default to a TOML file.

Returns
Ok, or an error when the file cannot be written.

Implements rex::ISettingsRegistry.

◆ SetText() [1/2]

Result< void > rex::SettingsRegistry::SetText ( SettingLayer layer,
std::string_view name,
std::string_view text )
nodiscardoverridevirtual

Sets a setting from text at a layer. A name nothing registered yet waits and applies when its owner registers. A value a higher layer holds is kept, not an error.

Parameters
nameThe full name, or an old name from the alias table.
Returns
Ok, or the setting's refusal.

Implements rex::ISettingsRegistry.

◆ SetText() [2/2]

Result< void > rex::SettingsRegistry::SetText ( std::string_view name,
std::string_view text )
nodiscardoverridevirtual

Sets a setting from text at the runtime layer. An old name applies to its new setting.

Returns
Ok, kNotFound, or the setting's refusal.

Implements rex::ISettingsRegistry.

◆ Unregister()

void rex::SettingsRegistry::Unregister ( SettingOwner & owner)
overridevirtual

Removes an owner. Its current values wait here for the next owner of the same names.

Implements rex::ISettingsRegistry.


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