summaryrefslogtreecommitdiffstatshomepage
path: root/src/emu/devdelegate.cpp
blob: 0396b583706b95c0fe187a23ead385efd90a30c2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// license:BSD-3-Clause
// copyright-holders:Aaron Giles, Vas Crabb
/***************************************************************************

    devdelegate.c

    Delegates that are late-bound to MAME devices.

***************************************************************************/

#include "emu.h"
#include "devdelegate.h"


namespace emu { namespace detail {

delegate_late_bind &device_delegate_helper::bound_object() const
{
	if (!m_tag)
		return m_base.get();
	device_t *const device(m_base.get().subdevice(m_tag));
	if (!device)
		throw emu_fatalerror("Unable to locate device '%s' relative to '%s'\n", m_tag, m_base.get().tag());
	return *device;
}


void device_delegate_helper::set_tag(char const *tag)
{
	m_base = m_base.get().mconfig().current_device();
	m_tag = tag;
}

} } // namespace emu::detail