summaryrefslogtreecommitdiffstatshomepage
path: root/src/emu/device.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/emu/device.h')
-rw-r--r--src/emu/device.h32
1 files changed, 30 insertions, 2 deletions
diff --git a/src/emu/device.h b/src/emu/device.h
index 3dbaa5f4e37..cc8b5209945 100644
--- a/src/emu/device.h
+++ b/src/emu/device.h
@@ -75,6 +75,17 @@ namespace emu { namespace detail {
class device_type_impl_base;
+template <typename T> struct is_device_implementation
+{
+ static constexpr bool value = std::is_base_of<device_t, T>::value;
+};
+
+template <typename T> struct is_device_interface
+{
+ static constexpr bool value = std::is_base_of<device_interface, T>::value && !is_device_implementation<T>::value;
+};
+
+
struct device_feature
{
enum type : u32
@@ -203,6 +214,8 @@ private:
device_type_impl_base *m_next;
public:
+ using exposed_type = device_t;
+
device_type_impl_base(std::nullptr_t)
: m_creator(nullptr)
, m_type(typeid(std::nullptr_t))
@@ -252,6 +265,10 @@ public:
{
return m_creator(*this, mconfig, tag, owner, clock);
}
+ std::unique_ptr<device_t> create(machine_config const &mconfig, char const *tag, device_t *owner, u32 clock) const
+ {
+ return m_creator(*this, mconfig, tag, owner, clock);
+ }
explicit operator bool() const { return bool(m_creator); }
bool operator==(device_type_impl_base const &that) const { return &that == this; }
@@ -263,9 +280,20 @@ template <class DeviceClass>
class device_type_impl : public device_type_impl_base
{
public:
+ using exposed_type = DeviceClass;
+
using device_type_impl_base::device_type_impl_base;
- template <typename... Params> DeviceClass &operator()(machine_config &config, char const *tag, Params &&... args) const;
- template <typename Exposed, bool Required, typename... Params> DeviceClass &operator()(machine_config &config, device_finder<Exposed, Required> &finder, Params &&... args) const;
+ using device_type_impl_base::create;
+ using device_type_impl_base::operator();
+
+ template <typename... Params>
+ std::unique_ptr<DeviceClass> create(machine_config &mconfig, char const *tag, device_t *owner, Params &&... args) const
+ {
+ return make_unique_clear<DeviceClass>(mconfig, tag, owner, std::forward<Params>(args)...);
+ }
+
+ template <typename... Params> DeviceClass &operator()(machine_config &mconfig, char const *tag, Params &&... args) const;
+ template <typename Exposed, bool Required, typename... Params> DeviceClass &operator()(machine_config &mconfig, device_finder<Exposed, Required> &finder, Params &&... args) const;
};