summaryrefslogtreecommitdiffstatshomepage
path: root/src/emu/ui/filemngr.cpp
diff options
context:
space:
mode:
author AJR <ajrhacker@users.noreply.github.com>2016-04-18 18:53:28 -0400
committer AJR <ajrhacker@users.noreply.github.com>2016-04-18 18:53:28 -0400
commit084d3654ca14a79d9ec173bad4ddf00ad0fb5a7f (patch)
tree197ae37b68f3169048fb3cadf6947353315f3608 /src/emu/ui/filemngr.cpp
parent55d3e544e013174880c8f208264683aac6d711f9 (diff)
Iterate over devices C++11 style
Replace the old device_iterator and its specialized versions with functionally equivalent classes that use standard operators to yield references to devices/interfaces rather than pointers. With range-based for loops, they no longer have to be stored in named variables, though they can also be reused concurrently since the iteration state is now maintained by a subclass. Add a few more typical getters to device_t::subdevice_list.
Diffstat (limited to 'src/emu/ui/filemngr.cpp')
-rw-r--r--src/emu/ui/filemngr.cpp28
1 files changed, 13 insertions, 15 deletions
diff --git a/src/emu/ui/filemngr.cpp b/src/emu/ui/filemngr.cpp
index 7fbff85217f..cac30f4f525 100644
--- a/src/emu/ui/filemngr.cpp
+++ b/src/emu/ui/filemngr.cpp
@@ -113,28 +113,26 @@ void ui_menu_file_manager::populate()
}
// cycle through all devices for this system
- device_iterator iter(machine().root_device());
std::unordered_set<std::string> devtags;
- for (device_t *dev = iter.first(); dev != nullptr; dev = iter.next())
+ for (device_t &dev : device_iterator(machine().root_device()))
{
bool tag_appended = false;
- if (!devtags.insert(dev->tag()).second)
+ if (!devtags.insert(dev.tag()).second)
continue;
// check whether it owns an image interface
- image_interface_iterator subiter(*dev);
- if (subiter.count() > 0)
+ image_interface_iterator subiter(dev);
+ if (subiter.first() != nullptr)
{
// if so, cycle through all its image interfaces
- image_interface_iterator subiterator(*dev);
- for (device_image_interface *scan = subiterator.first(); scan != nullptr; scan = subiterator.next())
+ for (device_image_interface &scan : subiter)
{
- if (!scan->user_loadable())
- continue;
-
+ if (!scan.user_loadable())
+ continue;
+
// if it is a children device, and not something further down the device tree, we want it in the menu!
- if (strcmp(scan->device().owner()->tag(), dev->tag()) == 0)
- if (devtags.insert(scan->device().tag()).second)
+ if (strcmp(scan.device().owner()->tag(), dev.tag()) == 0)
+ if (devtags.insert(scan.device().tag()).second)
{
// check whether we already had some devices with the same owner: if not, output the owner tag!
if (!tag_appended)
@@ -143,12 +141,12 @@ void ui_menu_file_manager::populate()
first_entry = false;
else
item_append(ui_menu_item_type::SEPARATOR);
- item_append(string_format("[root%s]", dev->tag()).c_str(), nullptr, 0, nullptr);
+ item_append(string_format("[root%s]", dev.tag()).c_str(), nullptr, 0, nullptr);
tag_appended = true;
}
// finally, append the image interface to the menu
- fill_image_line(scan, tmp_inst, tmp_name);
- item_append(tmp_inst.c_str(), tmp_name.c_str(), 0, (void *)scan);
+ fill_image_line(&scan, tmp_inst, tmp_name);
+ item_append(tmp_inst.c_str(), tmp_name.c_str(), 0, (void *)&scan);
}
}
}