summaryrefslogtreecommitdiffstatshomepage
path: root/src/emu/emuopts.h
diff options
context:
space:
mode:
author npwoods <npwoods@alumni.cmu.edu>2017-06-24 22:48:56 -0400
committer Vas Crabb <cuavas@users.noreply.github.com>2017-06-25 12:48:56 +1000
commitb193e05cd7c8456a2648d43854645da84f56ddbd (patch)
tree406d4dca91e403acdcea26379bcf65e567ca4834 /src/emu/emuopts.h
parent1b28df0b39225c3017e7bc843c14b58f548162ac (diff)
Overhaul to how MAME handles options, take two (#2341)
Diffstat (limited to 'src/emu/emuopts.h')
-rw-r--r--src/emu/emuopts.h160
1 files changed, 112 insertions, 48 deletions
diff --git a/src/emu/emuopts.h b/src/emu/emuopts.h
index e592d04d6e3..21fa27fb22f 100644
--- a/src/emu/emuopts.h
+++ b/src/emu/emuopts.h
@@ -195,56 +195,78 @@
// TYPE DEFINITIONS
//**************************************************************************
+class game_driver;
+class device_slot_interface;
+class emu_options;
+
class slot_option
{
public:
- slot_option(const char *default_value = nullptr);
- slot_option(const slot_option &that) = default;
+ slot_option(emu_options &host, const char *default_value);
+ slot_option(const slot_option &that) = delete;
slot_option(slot_option &&that) = default;
- const slot_option &operator=(const slot_option &that)
- {
- m_specified = that.m_specified;
- m_specified_value = that.m_specified_value;
- m_specified_bios = that.m_specified_bios;
- m_default_card_software = that.m_default_card_software;
- m_default_value = that.m_default_value;
- return *this;
- }
-
- const slot_option &operator=(slot_option &&that)
- {
- m_specified = that.m_specified;
- m_specified_value = std::move(that.m_specified_value);
- m_specified_bios = std::move(that.m_specified_bios);
- m_default_card_software = std::move(that.m_default_card_software);
- m_default_value = std::move(that.m_default_value);
- return *this;
- }
-
// accessors
const std::string &value() const;
std::string specified_value() const;
const std::string &bios() const { return m_specified_bios; }
const std::string &default_card_software() const { return m_default_card_software; }
bool specified() const { return m_specified; }
+ core_options::entry::shared_ptr option_entry() const { return m_entry.lock(); }
// seters
- void specify(std::string &&text);
+ void specify(const std::string &text, bool peg_priority = true);
+ void specify(std::string &&text, bool peg_priority = true);
void set_bios(std::string &&text);
- void set_default_card_software(std::string &&s) { m_default_card_software = std::move(s); }
+ void set_default_card_software(std::string &&s);
+
+ // instantiates an option entry (don't call outside of emuopts.cpp)
+ core_options::entry::shared_ptr setup_option_entry(const char *name);
private:
- bool m_specified;
- std::string m_specified_value;
- std::string m_specified_bios;
- std::string m_default_card_software;
- std::string m_default_value;
+ void possibly_changed(const std::string &old_value);
+
+ emu_options & m_host;
+ bool m_specified;
+ std::string m_specified_value;
+ std::string m_specified_bios;
+ std::string m_default_card_software;
+ std::string m_default_value;
+ core_options::entry::weak_ptr m_entry;
+};
+
+
+class image_option
+{
+public:
+ image_option(emu_options &host, const std::string &canonical_instance_name);
+ image_option(const image_option &that) = delete;
+ image_option(image_option &&that) = default;
+
+ // accessors
+ const std::string &canonical_instance_name() const { return m_canonical_instance_name; }
+ const std::string &value() const { return m_value; }
+ core_options::entry::shared_ptr option_entry() const { return m_entry.lock(); }
+
+ // mutators
+ void specify(const std::string &value, bool peg_priority = true);
+ void specify(std::string &&value, bool peg_priority = true);
+
+ // instantiates an option entry (don't call outside of emuopts.cpp)
+ core_options::entry::shared_ptr setup_option_entry(std::vector<std::string> &&names);
+
+private:
+ emu_options & m_host;
+ std::string m_canonical_instance_name;
+ std::string m_value;
+ core_options::entry::weak_ptr m_entry;
};
class emu_options : public core_options
{
+ friend class slot_option;
+ friend class image_option;
public:
enum ui_option
{
@@ -252,12 +274,27 @@ public:
UI_SIMPLE
};
+ enum class option_support
+ {
+ FULL, // full option support
+ GENERAL_AND_SYSTEM, // support for general options and system (no softlist)
+ GENERAL_ONLY // only support for general options
+ };
+
// construction/destruction
- emu_options();
+ emu_options(option_support support = option_support::FULL);
+ ~emu_options();
+
+ // mutation
+ void set_system_name(const std::string &new_system_name);
+ void set_system_name(std::string &&new_system_name);
+ void set_software(std::string &&new_software);
// core options
- const char *system_name() const { return value(OPTION_SYSTEMNAME); }
- const char *software_name() const { return value(OPTION_SOFTWARENAME); }
+ const game_driver *system() const { return m_system; }
+ const char *system_name() const;
+ const std::string &attempted_system_name() const { return m_attempted_system_name; }
+ const std::string &software_name() const { return m_software_name; }
// core configuration options
bool read_config() const { return bool_value(OPTION_READCONFIG); }
@@ -427,36 +464,63 @@ public:
const char *language() const { return value(OPTION_LANGUAGE); }
- // Web server specific optopns
+ // Web server specific options
bool http() const { return bool_value(OPTION_HTTP); }
short http_port() const { return int_value(OPTION_HTTP_PORT); }
const char *http_root() const { return value(OPTION_HTTP_ROOT); }
// 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; }
+ const ::slot_option &slot_option(const std::string &device_name) const;
+ ::slot_option &slot_option(const std::string &device_name);
+ const ::slot_option *find_slot_option(const std::string &device_name) const;
+ ::slot_option *find_slot_option(const std::string &device_name);
+ bool has_slot_option(const std::string &device_name) const { return find_slot_option(device_name) ? true : false; }
+ const ::image_option &image_option(const std::string &device_name) const;
+ ::image_option &image_option(const std::string &device_name);
protected:
- virtual void value_changed(const std::string &name, const std::string &value) override;
- virtual override_get_value_result override_get_value(const char *name, std::string &value) const override;
- virtual bool override_set_value(const char *name, const std::string &value) override;
+ virtual void command_argument_processed() override;
private:
- static const options_entry s_option_entries[];
+ struct software_options
+ {
+ std::unordered_map<std::string, std::string> slot;
+ std::unordered_map<std::string, std::string> image;
+ };
+
+ // slot/image/softlist calculus
+ software_options evaluate_initial_softlist_options(const std::string &software_identifier);
+ void update_slot_and_image_options();
+ bool add_and_remove_slot_options();
+ bool add_and_remove_image_options();
+ void reevaluate_default_card_software();
+ std::string get_default_card_software(device_slot_interface &slot);
+
+ // static list of options entries
+ static const options_entry s_option_entries[];
+
+ // the basics
+ option_support m_support;
+ const game_driver * m_system;
// slots and devices
- std::map<std::string, slot_option> m_slot_options;
- std::map<std::string, std::string> m_image_options;
+ std::unordered_map<std::string, ::slot_option> m_slot_options;
+ std::unordered_map<std::string, ::image_option> m_image_options_cannonical;
+ std::unordered_map<std::string, ::image_option *> 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;
+ int m_coin_impulse;
+ bool m_joystick_contradictory;
+ bool m_sleep;
+ bool m_refresh_speed;
+ ui_option m_ui;
+
+ // special option; the system name we tried to specify
+ std::string m_attempted_system_name;
+
+ // special option; the software set name that we did specify
+ std::string m_software_name;
};
#endif // MAME_EMU_EMUOPTS_H