openMSX
Public Types | Public Member Functions | Protected Member Functions | List of all members
openmsx::Setting Class Reference

#include <Setting.hh>

Inheritance diagram for openmsx::Setting:
Inheritance graph
[legend]
Collaboration diagram for openmsx::Setting:
Collaboration graph
[legend]

Public Types

enum  SaveSetting { SAVE, DONT_SAVE, DONT_TRANSFER }
 

Public Member Functions

 Setting (const Setting &)=delete
 
Settingoperator= (const Setting &)=delete
 
virtual ~Setting ()
 
const TclObjectgetValue () const final override
 Gets the current value of this setting as a TclObject. More...
 
void setRestoreValue (const TclObject &newRestoreValue)
 Set restore value. More...
 
void setChecker (std::function< void(TclObject &)> checkFunc_)
 Set value-check-callback. More...
 
void setValue (const TclObject &newValue) final override
 Change the value of this setting to the given value. More...
 
std::string_view getDescription () const final override
 pure virtual methods /// More...
 
TclObject getDefaultValue () const final override
 Get the default value of this setting. More...
 
TclObject getRestoreValue () const final override
 Get the value that will be set after a Tcl 'unset' command. More...
 
void setValueDirect (const TclObject &newValue) final override
 Similar to setValue(), but doesn't trigger Tcl traces. More...
 
void tabCompletion (std::vector< std::string > &tokens) const override
 Complete a partly typed value. More...
 
bool needLoadSave () const final override
 Does this setting need to be loaded or saved (settings.xml). More...
 
void additionalInfo (TclObject &result) const override
 Helper method for info(). More...
 
bool needTransfer () const final override
 Does this setting need to be transfered on reverse. More...
 
void setDontSaveValue (const TclObject &dontSaveValue) final override
 This value will never end up in the settings.xml file. More...
 
CommandControllergetCommandController () const
 
InterpretergetInterpreter () const
 
- Public Member Functions inherited from openmsx::BaseSetting
const TclObjectgetFullNameObj () const
 Get the name of this setting. More...
 
const TclObjectgetBaseNameObj () const
 
std::string_view getFullName () const
 
std::string_view getBaseName () const
 
void setPrefix (std::string_view prefix)
 Set a machine specific prefix. More...
 
void info (TclObject &result) const
 For SettingInfo. More...
 
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. More...
 
- Public Member Functions inherited from openmsx::Subject< Setting >
void attach (Observer< Setting > &observer)
 
void detach (Observer< Setting > &observer)
 
bool anyObservers () const
 

Protected Member Functions

 Setting (CommandController &commandController, std::string_view name, std::string_view description, const TclObject &initialValue, SaveSetting save=SAVE)
 
void init ()
 
void notifyPropertyChange () const
 
- Protected Member Functions inherited from openmsx::BaseSetting
 BaseSetting (std::string_view name)
 
 BaseSetting (const TclObject &name)
 
 ~BaseSetting ()=default
 
- Protected Member Functions inherited from openmsx::Subject< Setting >
 Subject ()=default
 
 ~Subject ()
 
void notify () const
 

Detailed Description

Definition at line 119 of file Setting.hh.

Member Enumeration Documentation

◆ SaveSetting

Enumerator
SAVE 
DONT_SAVE 
DONT_TRANSFER 

Definition at line 125 of file Setting.hh.

Constructor & Destructor Documentation

◆ Setting() [1/2]

openmsx::Setting::Setting ( const Setting )
delete

◆ ~Setting()

openmsx::Setting::~Setting ( )
virtual

Definition at line 78 of file Setting.cc.

◆ Setting() [2/2]

openmsx::Setting::Setting ( CommandController commandController,
std::string_view  name,
std::string_view  description,
const TclObject initialValue,
SaveSetting  save = SAVE 
)
protected

Member Function Documentation

◆ additionalInfo()

void openmsx::Setting::additionalInfo ( TclObject result) const
overridevirtual

◆ getCommandController()

CommandController& openmsx::Setting::getCommandController ( ) const
inline

◆ getDefaultValue()

TclObject openmsx::Setting::getDefaultValue ( ) const
inlinefinaloverridevirtual

Get the default value of this setting.

This is the initial value of the setting. Default values don't get saved in 'settings.xml'.

Implements openmsx::BaseSetting.

Definition at line 159 of file Setting.hh.

Referenced by openmsx::RenderSettings::RenderSettings().

◆ getDescription()

string_view openmsx::Setting::getDescription ( ) const
finaloverridevirtual

pure virtual methods ///

Get a description of this setting that can be presented to the user.

Implements openmsx::BaseSetting.

Definition at line 84 of file Setting.cc.

◆ getInterpreter()

Interpreter & openmsx::Setting::getInterpreter ( ) const

◆ getRestoreValue()

TclObject openmsx::Setting::getRestoreValue ( ) const
inlinefinaloverridevirtual

Get the value that will be set after a Tcl 'unset' command.

Usually this is the same as the default value. Though one exception is 'renderer', see comments in RendererFactory.cc.

Implements openmsx::BaseSetting.

Definition at line 160 of file Setting.hh.

References openmsx::BaseSetting::additionalInfo(), openmsx::BaseSetting::needLoadSave(), openmsx::BaseSetting::needTransfer(), openmsx::BaseSetting::setDontSaveValue(), openmsx::BaseSetting::setValueDirect(), and openmsx::BaseSetting::tabCompletion().

Referenced by openmsx::CommandLineParser::parse().

◆ getValue()

const TclObject& openmsx::Setting::getValue ( ) const
inlinefinaloverridevirtual

◆ init()

void openmsx::Setting::init ( )
protected

◆ needLoadSave()

bool openmsx::Setting::needLoadSave ( ) const
finaloverridevirtual

Does this setting need to be loaded or saved (settings.xml).

Implements openmsx::BaseSetting.

Definition at line 137 of file Setting.cc.

◆ needTransfer()

bool openmsx::Setting::needTransfer ( ) const
finaloverridevirtual

Does this setting need to be transfered on reverse.

Implements openmsx::BaseSetting.

Definition at line 141 of file Setting.cc.

◆ notifyPropertyChange()

void openmsx::Setting::notifyPropertyChange ( ) const
protected

◆ operator=()

Setting& openmsx::Setting::operator= ( const Setting )
delete

◆ setChecker()

void openmsx::Setting::setChecker ( std::function< void(TclObject &)>  checkFunc_)
inline

Set value-check-callback.

The callback is called on each change of this settings value. The callback has to posibility to

  • change the value (modify the parameter)
  • disallow the change (throw an exception) The callback is only executed on each value change, even if the new value is the same as the current value. However the callback is not immediately executed once it's set (via this method).

Definition at line 152 of file Setting.hh.

References openmsx::BaseSetting::getDescription(), and openmsx::BaseSetting::setValue().

Referenced by openmsx::BooleanSetting::BooleanSetting(), openmsx::FloatSetting::FloatSetting(), openmsx::IntegerSetting::IntegerSetting(), openmsx::Joystick::Joystick(), openmsx::KeyCodeSetting::KeyCodeSetting(), openmsx::OSDConsoleRenderer::OSDConsoleRenderer(), openmsx::ReadOnlySetting::ReadOnlySetting(), openmsx::RenderSettings::RenderSettings(), openmsx::Touchpad::Touchpad(), and openmsx::VideoSourceSetting::VideoSourceSetting().

◆ setDontSaveValue()

void openmsx::Setting::setDontSaveValue ( const TclObject dontSaveValue)
finaloverridevirtual

This value will never end up in the settings.xml file.

Implements openmsx::BaseSetting.

Definition at line 146 of file Setting.cc.

Referenced by openmsx::RenderSettings::RenderSettings().

◆ setRestoreValue()

void openmsx::Setting::setRestoreValue ( const TclObject newRestoreValue)
inline

Set restore value.

See getDefaultValue() and getRestoreValue().

Definition at line 139 of file Setting.hh.

Referenced by openmsx::RenderSettings::RenderSettings().

◆ setValue()

void openmsx::Setting::setValue ( const TclObject value)
finaloverridevirtual

◆ setValueDirect()

void openmsx::Setting::setValueDirect ( const TclObject value)
finaloverridevirtual

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 178 of file Setting.cc.

References openmsx::BaseSetting::getBaseNameObj(), and openmsx::BaseSetting::getValue().

◆ tabCompletion()

void openmsx::Setting::tabCompletion ( std::vector< std::string > &  tokens) const
overridevirtual

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