summaryrefslogtreecommitdiffstatshomepage
path: root/src/lib
diff options
context:
space:
mode:
author Nathan Woods <npwoods@mess.org>2017-04-16 13:08:57 -0400
committer Nathan Woods <npwoods@mess.org>2017-04-16 13:08:57 -0400
commitc108986639334be4f524964a5b5f377b6dab4e17 (patch)
tree46f0f1d801db80b39f106a3090ad0593540420fa /src/lib
parentf451ebd5f71884da575f8c20c29fdf3792e6c89c (diff)
More options refactoring
This should address outstanding concerns with PR#2231. I'm trying to turn emu_options into a self contained structure that encapsulates behaviors related to options, including the gymnastics pertaining to image/slot loading and interactions with get_default_card_software() and "just works". When the MAME 0.186 development cycle starts up, I hope to take this further. I want to make core_options::entry an abstract base class so that the entries associated with image options and slot options can derive from it. This will eliminate the current need for emu_options to directly expose maps for image and slot options. For now, I'm in stabilization mode, and I hope to get things working for a stable 0.185 release.
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/util/options.cpp18
-rw-r--r--src/lib/util/options.h11
2 files changed, 25 insertions, 4 deletions
diff --git a/src/lib/util/options.cpp b/src/lib/util/options.cpp
index 16b62f9c91f..b835d0fa681 100644
--- a/src/lib/util/options.cpp
+++ b/src/lib/util/options.cpp
@@ -565,9 +565,21 @@ std::string core_options::output_ini(const core_options *diff) const
for (entry &curentry : m_entrylist)
{
const char *name = curentry.name();
- const char *value = name && override_get_value(name, overridden_value)
- ? overridden_value.c_str()
- : curentry.value();
+ const char *value;
+ switch (override_get_value(name, overridden_value))
+ {
+ case override_get_value_result::NONE:
+ default:
+ value = curentry.value();
+ break;
+
+ case override_get_value_result::SKIP:
+ continue;
+
+ case override_get_value_result::OVERRIDE:
+ value = overridden_value.c_str();
+ break;
+ }
bool is_unadorned = false;
// check if it's unadorned
diff --git a/src/lib/util/options.h b/src/lib/util/options.h
index b2bc46343ac..637481b12b2 100644
--- a/src/lib/util/options.h
+++ b/src/lib/util/options.h
@@ -181,8 +181,17 @@ public:
int options_count() const { return m_entrylist.count(); }
protected:
+ // This is a hook to allow option value retrieval to be overridden for various reasons; this is a crude
+ // extensibility mechanism that should really be replaced by something better
+ enum class override_get_value_result
+ {
+ NONE,
+ OVERRIDE,
+ SKIP
+ };
+
virtual void value_changed(const std::string &name, const std::string &value) {}
- virtual bool override_get_value(const char *name, std::string &value) const { return false; }
+ virtual override_get_value_result override_get_value(const char *name, std::string &value) const { return override_get_value_result::NONE; }
virtual bool override_set_value(const char *name, const std::string &value) { return false; }
private: