summaryrefslogtreecommitdiffstatshomepage
path: root/src/emu/emuopts.h
diff options
context:
space:
mode:
author Nathan Woods <npwoods@mess.org>2017-04-02 18:57:02 -0400
committer Vas Crabb <cuavas@users.noreply.github.com>2017-04-06 11:20:45 +1000
commitfbb7d927d3a58de18850ad3079621e0a78e5e6bd (patch)
tree81616193556f6466a00d2c05142d1ba89b9cc693 /src/emu/emuopts.h
parent694a7812155927f89df046b585836ce872929e72 (diff)
Refactoring in response to MT#6531
Prior to this change, options for images and slots were stored in the emu_options collection. Anything that might restart the emulation (such as slot changes and images that reset on load) had to manipulate the emu_options structure directly. The dynamic nature of images and slots meant that some elaborate conventions for setting up this collection had to be understood by clients. After this change, emu_options has two new members (image_options and slot_options) that expose image and slot selections via an std::map. Anything that changes images or slots in a fashion that needs to persist across sessions needs to modify these data structures. Additionally, some of the hairly logic (e.g. - get_default_card_software) now records its data here rather than trying to subvert the core_options system. This is how MT#6531 was fixed; now when diimage.cpp sees an image that resets on load, it just modifies the image_options structure and forces a reset. This allowed some further cleanups to happen within diimage. This should be considered a very risky change, and scrutiny/feedback is welcome. In particular, there seems to be functionality surrounding device bioses that I'm not 100% sure how it works; the syntax seems to imply that it only works on slot devices.
Diffstat (limited to 'src/emu/emuopts.h')
-rw-r--r--src/emu/emuopts.h60
1 files changed, 52 insertions, 8 deletions
diff --git a/src/emu/emuopts.h b/src/emu/emuopts.h
index 9f1b4b644ec..31c49210e50 100644
--- a/src/emu/emuopts.h
+++ b/src/emu/emuopts.h
@@ -195,6 +195,42 @@
// TYPE DEFINITIONS
//**************************************************************************
+class slot_option
+{
+public:
+ slot_option(std::string &&value = "", std::string &&bios = "")
+ : m_value(std::move(value)), m_bios(std::move(bios))
+ {
+ }
+ slot_option(const slot_option &that) = default;
+ slot_option(slot_option &&that) = default;
+
+ const slot_option &operator=(const slot_option &that)
+ {
+ // I thought you got this implicitly by declaring a default copy constructor?
+ m_value = that.m_value;
+ m_default_card_software = that.m_default_card_software;
+ m_bios = that.m_bios;
+ return that;
+ }
+
+ // accessors
+ const std::string &value() const { return m_value.empty() ? m_default_card_software : m_value; }
+ const std::string &bios() const { return m_bios; }
+ const std::string &default_card_software() const { return m_default_card_software; }
+ bool is_default() const { return m_value.empty(); }
+
+ // seters
+ void set_bios(std::string &&s) { m_bios = std::move(s); }
+ void set_default_card_software(std::string &&s) { m_default_card_software = std::move(s); }
+
+private:
+ std::string m_value;
+ std::string m_bios;
+ std::string m_default_card_software;
+};
+
+
class emu_options : public core_options
{
public:
@@ -384,8 +420,12 @@ public:
short http_port() const { return int_value(OPTION_HTTP_PORT); }
const char *http_root() const { return value(OPTION_HTTP_ROOT); }
- std::string main_value(const char *option) const;
- std::string sub_value(const char *name, const char *subname) const;
+ // slots and devices - the values for these are stored outside of the core_options
+ // structure
+ std::map<std::string, slot_option> &slot_options() { return m_slot_options; }
+ const std::map<std::string, slot_option> &slot_options() const { return m_slot_options; }
+ std::map<std::string, std::string> &image_options() { return m_image_options; }
+ const std::map<std::string, std::string> &image_options() const { return m_image_options; }
protected:
virtual void value_changed(const std::string &name, const std::string &value) override;
@@ -393,12 +433,16 @@ protected:
private:
static const options_entry s_option_entries[];
- // cached options
- int m_coin_impulse;
- bool m_joystick_contradictory;
- bool m_sleep;
- bool m_refresh_speed;
- ui_option m_ui;
+ // slots and devices
+ std::map<std::string, slot_option> m_slot_options;
+ std::map<std::string, std::string> m_image_options;
+
+ // cached options, for scenarios where parsing core_options is too slow
+ int m_coin_impulse;
+ bool m_joystick_contradictory;
+ bool m_sleep;
+ bool m_refresh_speed;
+ ui_option m_ui;
};
#endif // MAME_EMU_EMUOPTS_H