openMSX
ReadOnlySetting.cc
Go to the documentation of this file.
1 #include "ReadOnlySetting.hh"
2 #include "MSXException.hh"
3 
4 namespace openmsx {
5 
7  CommandController& commandController_,
8  string_view name_, string_view description_,
9  const TclObject& initialValue)
10  : Setting(commandController_, name_, description_, initialValue,
11  Setting::DONT_TRANSFER)
12  , roValue(initialValue)
13 {
14  setChecker([this](TclObject& newValue) {
15  if (newValue != roValue) {
16  throw MSXException("Read-only setting");
17  }
18  });
19  init();
20 }
21 
23 {
24  roValue = newValue;
25  setValue(newValue);
26 }
27 
29 {
30  return "read-only";
31 }
32 
33 } // namespace openmsx
void setChecker(std::function< void(TclObject &)> checkFunc_)
Set value-check-callback.
Definition: Setting.hh:151
ReadOnlySetting(CommandController &commandController, string_view name, string_view description, const TclObject &initialValue)
Thanks to enen for testing this on a real cartridge:
Definition: Autofire.cc:5
void setValue(const TclObject &newValue) final override
Change the value of this setting to the given value.
Definition: Setting.cc:88
This class implements a (close approximation) of the std::string_view class.
Definition: string_view.hh:16
string_view getTypeString() const override
Returns a string describing the setting type (integer, string, ..) Could be used in a GUI to pick an ...
void setReadOnlyValue(const TclObject &value)