OXYGENHUB
◆ main openmsx / src / settings / ReadOnlySetting.cc
748 B · C++ · last changed chore(): initial commit 1 month ago source blame history raw
e8555c89 Andy McCall 1
#include "ReadOnlySetting.hh"
2
3
#include "MSXException.hh"
4
5
namespace openmsx {
6
7
ReadOnlySetting::ReadOnlySetting(
8
		CommandController& commandController_,
9
		std::string_view name_, static_string_view description_,
10
		const TclObject& initialValue)
11
	: Setting(commandController_, name_, description_, initialValue,
12
	          Setting::Save::NO_AND_DONT_TRANSFER)
13
	, roValue(initialValue)
14
{
15
	setChecker([this](const TclObject& newValue) {
16
		if (newValue != roValue) {
17
			throw MSXException("Read-only setting");
18
		}
19
	});
20
	init();
21
}
22
23
void ReadOnlySetting::setReadOnlyValue(const TclObject& newValue)
24
{
25
	roValue = newValue;
26
	setValue(newValue);
27
}
28
29
std::string_view ReadOnlySetting::getTypeString() const
30
{
31
	return "read-only";
32
}
33
34
} // namespace openmsx