diff --git a/src/devices/imagedev/chd_cd.cpp b/src/devices/imagedev/chd_cd.cpp index f090d7f0032..cac16961a31 100644 --- a/src/devices/imagedev/chd_cd.cpp +++ b/src/devices/imagedev/chd_cd.cpp @@ -61,7 +61,7 @@ void cdrom_image_device::device_config_complete() { m_extension_list = "chd,cue,toc,nrg,gdi,iso,cdr"; - m_formatlist.push_back(std::make_unique("chdcd", "CD-ROM drive", m_extension_list, cd_option_spec)); + add_format("chdcd", "CD-ROM drive", m_extension_list, cd_option_spec); // set brief and instance name update_names(); diff --git a/src/devices/imagedev/diablo.cpp b/src/devices/imagedev/diablo.cpp index 64e313865bf..a47451a1c47 100644 --- a/src/devices/imagedev/diablo.cpp +++ b/src/devices/imagedev/diablo.cpp @@ -56,7 +56,7 @@ diablo_image_device::~diablo_image_device() void diablo_image_device::device_config_complete() { - m_formatlist.push_back(std::make_unique("chd", "CHD Hard drive", "chd,dsk", dsk_option_spec)); + add_format("chd", "CHD Hard drive", "chd,dsk", dsk_option_spec); // set brief and instance name update_names(); diff --git a/src/devices/imagedev/flopdrv.cpp b/src/devices/imagedev/flopdrv.cpp index e19340c40c9..290d6671cd3 100644 --- a/src/devices/imagedev/flopdrv.cpp +++ b/src/devices/imagedev/flopdrv.cpp @@ -825,7 +825,7 @@ void legacy_floppy_image_device::device_config_complete() // only add if creatable if (floppy_options[i].param_guidelines) { // allocate a new format and append it to the list - m_formatlist.push_back(std::make_unique(floppy_options[i].name, floppy_options[i].description, floppy_options[i].extensions, floppy_options[i].param_guidelines)); + add_format(floppy_options[i].name, floppy_options[i].description, floppy_options[i].extensions, floppy_options[i].param_guidelines); } image_specify_extension( m_extension_list, 256, floppy_options[i].extensions ); } diff --git a/src/devices/imagedev/floppy.cpp b/src/devices/imagedev/floppy.cpp index 44b80e6629a..30d535c28fa 100644 --- a/src/devices/imagedev/floppy.cpp +++ b/src/devices/imagedev/floppy.cpp @@ -242,7 +242,7 @@ void floppy_image_device::set_formats(const floppy_format_type *formats) else fif_list->append(fif); - m_formatlist.push_back(std::make_unique(fif->name(), fif->description(), fif->extensions(), "")); + add_format(fif->name(), fif->description(), fif->extensions(), ""); image_specify_extension( extension_list, 256, fif->extensions() ); } diff --git a/src/devices/imagedev/harddriv.cpp b/src/devices/imagedev/harddriv.cpp index 42eeac477be..588ef862c4d 100644 --- a/src/devices/imagedev/harddriv.cpp +++ b/src/devices/imagedev/harddriv.cpp @@ -79,7 +79,7 @@ harddisk_image_device::~harddisk_image_device() void harddisk_image_device::device_config_complete() { - m_formatlist.push_back(std::make_unique("chd", "CHD Hard drive", "chd,hd", hd_option_spec)); + add_format("chd", "CHD Hard drive", "chd,hd", hd_option_spec); // set brief and instance name update_names(); diff --git a/src/emu/diimage.cpp b/src/emu/diimage.cpp index 56be4f9a6de..cb2a7f6a02d 100644 --- a/src/emu/diimage.cpp +++ b/src/emu/diimage.cpp @@ -237,6 +237,27 @@ const image_device_format *device_image_interface::device_get_named_creatable_fo } +//------------------------------------------------- +// add_format +//------------------------------------------------- + +void device_image_interface::add_format(std::unique_ptr &&format) +{ + m_formatlist.push_back(std::move(format)); +} + + +//------------------------------------------------- +// add_format +//------------------------------------------------- + +void device_image_interface::add_format(std::string &&name, std::string &&description, std::string &&extensions, std::string &&optspec) +{ + auto format = std::make_unique(std::move(name), std::move(description), std::move(extensions), std::move(optspec)); + add_format(std::move(format)); +} + + /**************************************************************************** ERROR HANDLING ****************************************************************************/ diff --git a/src/emu/diimage.h b/src/emu/diimage.h index 009cd9bc534..7854f9022c1 100644 --- a/src/emu/diimage.h +++ b/src/emu/diimage.h @@ -273,6 +273,9 @@ protected: bool load_software_part(const char *path, const software_part *&swpart); std::string software_get_default_slot(const char *default_card_slot) const; + void add_format(std::unique_ptr &&format); + void add_format(std::string &&name, std::string &&description, std::string &&extensions, std::string &&optspec); + // derived class overrides // configuration @@ -320,9 +323,6 @@ protected: std::string m_brief_instance_name; std::string m_instance_name; - // creation info - formatlist_type m_formatlist; - // in the case of arcade cabinet with fixed carts inserted, // we want to disable command line cart loading... bool m_user_loadable; @@ -331,6 +331,9 @@ protected: private: static image_error_t image_error_from_file_error(osd_file::error filerr); + + // creation info + formatlist_type m_formatlist; }; // iterator