ReXGlue SDK
Loading...
Searching...
No Matches
rex::Setting< T > Class Template Referencefinal

#include <rex/setting.h>

Inheritance diagram for rex::Setting< T >:
[legend]

Public Member Functions

template<typename... Traits>
 Setting (SettingOwner *owner, std::string_view name, const T &default_value, std::string_view help, Traits... traits)
T Get () const
Result< void > Set (const T &value)
Result< void > Lock (const T &value)
ScopeGuard OnChange (MoveOnlyFunction< void(const T &)> fn)
Public Member Functions inherited from rex::SettingBase
const std::string & GetName () const
const std::string & GetHelp () const
SettingType GetType () const
const SettingConstraints & GetConstraints () const
SettingOwner & GetOwner () const
SettingLayer GetLayer () const
bool IsFrozen () const
bool IsRestartPending () const
std::string GetText () const
std::string GetDefaultText () const
Result< void > Check (std::string_view text) const
Result< void > SetText (SettingLayer layer, std::string_view text)
Result< void > Reset ()

Additional Inherited Members

Protected Member Functions inherited from rex::SettingBase
 SettingBase (SettingOwner &owner, std::string_view name, SettingType type, std::string_view help)
SettingConstraints & EditConstraints ()
Result< void > SetFromCode (std::string_view text)
Protected Member Functions inherited from rex::NonCopyable
 NonCopyable (const NonCopyable &)=delete
NonCopyable & operator= (const NonCopyable &)=delete

Detailed Description

template<typename T>
class rex::Setting< T >

A typed setting, declared with REX_SETTING inside its owner. Scalars read lock free.

Template Parameters
Tbool, i32, i64, u32, u64, f64, std::string or std::filesystem::path.

Constructor & Destructor Documentation

◆ Setting()

template<typename T>
template<typename... Traits>
rex::Setting< T >::Setting ( SettingOwner * owner,
std::string_view name,
const T & default_value,
std::string_view help,
Traits... traits )

Declares the setting. REX_SETTING is the usual way to write it.

Template Parameters
TraitsThe traits, such as Range, Allowed, kRestart or kNoSave.

Member Function Documentation

◆ Get()

template<typename T>
T rex::Setting< T >::Get ( ) const

Returns the value. A path comes back with its {scope.name} references resolved.

◆ Lock()

template<typename T>
Result< void > rex::Setting< T >::Lock ( const T & value)
nodiscard

Stores a value at the lock layer, so no later layer changes it.

Returns
Ok, or an error when the setting is frozen.

◆ OnChange()

template<typename T>
ScopeGuard rex::Setting< T >::OnChange ( MoveOnlyFunction< void(const T &)> fn)
nodiscard

Calls a function after every change, on the thread that made it.

Parameters
fnCalled with the new value.
Returns
The guard. The calls stop when it is destroyed.

◆ Set()

template<typename T>
Result< void > rex::Setting< T >::Set ( const T & value)
nodiscard

Stores a value at the title layer before launch, the runtime layer after.

Returns
Ok, or the same errors as SetText.

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