openMSX
|
#include <Setting.hh>
Public Types | |
enum class | Save { YES , NO , NO_AND_DONT_TRANSFER } |
Public Member Functions | |
Setting (const Setting &)=delete | |
Setting (Setting &&)=delete | |
Setting & | operator= (const Setting &)=delete |
Setting & | operator= (Setting &&)=delete |
virtual | ~Setting () |
const TclObject & | getValue () const final |
Gets the current value of this setting as a TclObject. | |
std::optional< TclObject > | getOptionalValue () const final |
Like getValue(), but in case of error returns an empty optional instead of throwing an exception. | |
void | setChecker (std::function< void(TclObject &)> checkFunc_) |
Set value-check-callback. | |
void | setValue (const TclObject &newValue) final |
Change the value of this setting to the given value. | |
std::string_view | getDescription () const final |
pure virtual methods /// | |
TclObject | getDefaultValue () const final |
Get the default value of this setting. | |
void | setValueDirect (const TclObject &newValue) final |
Similar to setValue(), but doesn't trigger Tcl traces. | |
void | tabCompletion (std::vector< std::string > &tokens) const override |
Complete a partly typed value. | |
bool | needLoadSave () const final |
Does this setting need to be loaded or saved (settings.xml). | |
void | additionalInfo (TclObject &result) const override |
Helper method for info(). | |
bool | needTransfer () const final |
Does this setting need to be transfered on reverse. | |
CommandController & | getCommandController () const |
Interpreter & | getInterpreter () const |
Public Member Functions inherited from openmsx::BaseSetting | |
const TclObject & | getFullNameObj () const |
Get the name of this setting. | |
const TclObject & | getBaseNameObj () const |
std::string_view | getFullName () const |
std::string_view | getBaseName () const |
void | setPrefix (std::string_view prefix) |
Set a machine specific prefix. | |
void | info (TclObject &result) const |
For SettingInfo. | |
virtual std::string_view | getTypeString () const =0 |
Returns a string describing the setting type (integer, string, ..) Could be used in a GUI to pick an appropriate setting widget. | |
Public Member Functions inherited from openmsx::Subject< Setting > | |
Subject (const Subject &)=delete | |
Subject (Subject &&)=delete | |
Subject & | operator= (const Subject &)=delete |
Subject & | operator= (Subject &&)=delete |
void | attach (Observer< Setting > &observer) |
void | detach (Observer< Setting > &observer) |
bool | anyObservers () const |
Protected Member Functions | |
Setting (CommandController &commandController, std::string_view name, static_string_view description, const TclObject &initialValue, Save save=Save::YES) | |
void | init () |
void | notifyPropertyChange () const |
Protected Member Functions inherited from openmsx::BaseSetting | |
BaseSetting (std::string_view name) | |
BaseSetting (TclObject name) | |
~BaseSetting ()=default | |
Protected Member Functions inherited from openmsx::Subject< Setting > | |
Subject ()=default | |
~Subject () | |
void | notify () const |
Definition at line 117 of file Setting.hh.
|
strong |
Enumerator | |
---|---|
YES | |
NO | |
NO_AND_DONT_TRANSFER |
Definition at line 120 of file Setting.hh.
|
delete |
|
delete |
|
virtual |
Definition at line 70 of file Setting.cc.
References getCommandController(), and openmsx::CommandController::unregisterSetting().
|
protected |
Definition at line 36 of file Setting.cc.
|
overridevirtual |
Helper method for info().
Implements openmsx::BaseSetting.
Reimplemented in openmsx::VideoSourceSetting.
Definition at line 149 of file Setting.cc.
|
inline |
Definition at line 161 of file Setting.hh.
Referenced by init(), setValueDirect(), and ~Setting().
|
inlinefinalvirtual |
Get the default value of this setting.
This is the initial value of the setting. Default values don't get saved in 'settings.xml'. This is also the value used for a Tcl 'unset' command.
Implements openmsx::BaseSetting.
Definition at line 153 of file Setting.hh.
Referenced by openmsx::CommandLineParser::parse().
|
finalvirtual |
pure virtual methods ///
Get a description of this setting that can be presented to the user.
Implements openmsx::BaseSetting.
Definition at line 76 of file Setting.cc.
Interpreter & openmsx::Setting::getInterpreter | ( | ) | const |
Definition at line 139 of file Setting.cc.
References openmsx::CommandController::getInterpreter().
Referenced by openmsx::BooleanSetting::BooleanSetting(), openmsx::FloatSetting::FloatSetting(), openmsx::BooleanSetting::getBoolean(), openmsx::FilePool::getDirectories(), openmsx::FloatSetting::getDouble(), openmsx::FloatSetting::getFloat(), openmsx::IntegerSetting::getInt(), openmsx::IntegerSetting::IntegerSetting(), setValue(), and setValueDirect().
|
inlinefinalvirtual |
Like getValue(), but in case of error returns an empty optional instead of throwing an exception.
Implements openmsx::BaseSetting.
Definition at line 135 of file Setting.hh.
|
inlinefinalvirtual |
Gets the current value of this setting as a TclObject.
Implements openmsx::BaseSetting.
Definition at line 134 of file Setting.hh.
Referenced by openmsx::BooleanSetting::getBoolean(), openmsx::FilePool::getDirectories(), openmsx::FloatSetting::getDouble(), openmsx::EnumSetting< T >::getEnum(), openmsx::FloatSetting::getFloat(), openmsx::IntegerSetting::getInt(), openmsx::KeyCodeSetting::getKey(), openmsx::VideoSourceSetting::getSource(), openmsx::EnumSetting< T >::getString(), openmsx::FilenameSetting::getString(), openmsx::StringSetting::getString(), openmsx::TclCallback::getValue(), openmsx::JoyMega::JoyMega(), openmsx::MSXJoystick::MSXJoystick(), setValueDirect(), and openmsx::Touchpad::Touchpad().
|
protected |
Definition at line 49 of file Setting.cc.
References openmsx::BaseSetting::getBaseName(), getCommandController(), needLoadSave(), openmsx::CommandController::registerSetting(), and setValueDirect().
Referenced by openmsx::BooleanSetting::BooleanSetting(), openmsx::EnumSetting< T >::EnumSetting(), openmsx::FilenameSetting::FilenameSetting(), openmsx::FloatSetting::FloatSetting(), openmsx::IntegerSetting::IntegerSetting(), openmsx::KeyCodeSetting::KeyCodeSetting(), openmsx::ReadOnlySetting::ReadOnlySetting(), openmsx::StringSetting::StringSetting(), and openmsx::VideoSourceSetting::VideoSourceSetting().
|
finalvirtual |
Does this setting need to be loaded or saved (settings.xml).
Implements openmsx::BaseSetting.
Definition at line 119 of file Setting.cc.
References YES.
Referenced by init().
|
finalvirtual |
Does this setting need to be transfered on reverse.
Implements openmsx::BaseSetting.
Definition at line 123 of file Setting.cc.
References NO_AND_DONT_TRANSFER.
|
protected |
Definition at line 111 of file Setting.cc.
References openmsx::BaseSetting::getBaseName(), openmsx::CommandController::getCliComm(), openmsx::TclObject::getString(), openmsx::BaseSetting::info(), openmsx::CliComm::SETTING_INFO, and openmsx::CliComm::updateFiltered().
Referenced by openmsx::VideoSourceSetting::registerVideoSource(), and openmsx::VideoSourceSetting::unregisterVideoSource().
|
inline |
Set value-check-callback.
The callback is called on each change of this settings value. The callback has the possibility to
Definition at line 146 of file Setting.hh.
Referenced by openmsx::BooleanSetting::BooleanSetting(), openmsx::EnumSetting< T >::EnumSetting(), openmsx::FloatSetting::FloatSetting(), openmsx::IntegerSetting::IntegerSetting(), openmsx::JoyMega::JoyMega(), openmsx::KeyCodeSetting::KeyCodeSetting(), openmsx::MSXJoystick::MSXJoystick(), openmsx::ReadOnlySetting::ReadOnlySetting(), openmsx::Touchpad::Touchpad(), and openmsx::VideoSourceSetting::VideoSourceSetting().
|
finalvirtual |
Change the value of this setting to the given value.
This method will trigger Tcl traces. This value still passes via the 'checker-callback' (see below), so the value may be adjusted. Or in case of an invalid value this method may throw.
Implements openmsx::BaseSetting.
Definition at line 81 of file Setting.cc.
References openmsx::BaseSetting::getFullNameObj(), getInterpreter(), and openmsx::Interpreter::setVariable().
Referenced by openmsx::BooleanSetting::setBoolean(), openmsx::FloatSetting::setDouble(), openmsx::EnumSetting< T >::setEnum(), openmsx::IntegerSetting::setInt(), openmsx::ReadOnlySetting::setReadOnlyValue(), openmsx::VideoSourceSetting::setSource(), openmsx::FilenameSetting::setString(), and openmsx::StringSetting::setString().
|
finalvirtual |
Similar to setValue(), but doesn't trigger Tcl traces.
Like setValue(), the given value may be adjusted or rejected. Should only be used by the Interpreter class.
Implements openmsx::BaseSetting.
Definition at line 155 of file Setting.cc.
References openmsx::BaseSetting::getBaseNameObj(), getCommandController(), getInterpreter(), getValue(), and openmsx::Interpreter::setVariable().
Referenced by init().
|
overridevirtual |
Complete a partly typed value.
Default implementation does not complete anything, subclasses can override this to complete according to their specific value type.
Implements openmsx::BaseSetting.
Reimplemented in openmsx::VideoSourceSetting.
Definition at line 144 of file Setting.cc.