summaryrefslogblamecommitdiffstatshomepage
path: root/src/emu/devdelegate.cpp
blob: 0396b583706b95c0fe187a23ead385efd90a30c2 (plain) (tree)
1
2
3
4
5
6
7
8
                       
                                           





                                                                            


                                                                            
                        

 
                                  
 
                                                                
 




                                                                                                                   



                       
                                                     
 

                                                         
 

                            
// 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