summaryrefslogtreecommitdiffstatshomepage
path: root/src/emu/devdelegate.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/emu/devdelegate.cpp')
-rw-r--r--src/emu/devdelegate.cpp37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/emu/devdelegate.cpp b/src/emu/devdelegate.cpp
new file mode 100644
index 00000000000..53a03763e4a
--- /dev/null
+++ b/src/emu/devdelegate.cpp
@@ -0,0 +1,37 @@
+// license:BSD-3-Clause
+// copyright-holders:Aaron Giles
+/***************************************************************************
+
+ devdelegate.c
+
+ Delegates that are late-bound to MAME devices.
+
+***************************************************************************/
+
+#include "emu.h"
+
+
+//-------------------------------------------------
+// bound_object - use the device name to locate
+// a device relative to the given search root;
+// fatal error if not found
+//-------------------------------------------------
+
+delegate_late_bind &device_delegate_helper::bound_object(device_t &search_root)
+{
+ device_t *device = search_root.subdevice(m_device_name);
+ if (device == NULL)
+ throw emu_fatalerror("Unable to locate device '%s' relative to '%s'\n", m_device_name, search_root.tag());
+ return *device;
+}
+
+
+//-------------------------------------------------
+// safe_tag - return a tag string or (unknown) if
+// the object is not valid
+//-------------------------------------------------
+
+const char *device_delegate_helper::safe_tag(device_t *object)
+{
+ return (object != NULL) ? object->tag() : "(unknown)";
+}