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  std::string_view name_, static_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 
28 std::string_view ReadOnlySetting::getTypeString() const
29 {
30  return "read-only";
31 }
32 
33 } // namespace openmsx
ReadOnlySetting(CommandController &commandController, std::string_view name, static_string_view description, const TclObject &initialValue)
std::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)
void setChecker(std::function< void(TclObject &)> checkFunc_)
Set value-check-callback.
Definition: Setting.hh:160
void setValue(const TclObject &newValue) final
Change the value of this setting to the given value.
Definition: Setting.cc:89
static_string_view
This file implemented 3 utility functions:
Definition: Autofire.cc:5