Added a macro that exports device types

Kaleidoscope's device API defines two types to be exported
as kaleidoscope::Device and kaleidoscope::DeviceProps.

The newly introduced macro EXPORT_DEVICE can be used
to export those two type names conveniently.

The macro also serves the purpose to only export a type named
kaleidoscope::Device in non-virtual device builds. In virtual
builds, a homonymous type is exported by the virtual device header
Virtual.h.

Signed-off-by: Florian Fleissner <florian.fleissner@inpartik.de>
pull/735/head
Florian Fleissner 5 years ago committed by Jesse Vincent
parent f3cb9a437f
commit f1a92d6fb0
No known key found for this signature in database
GPG Key ID: CC228463465E40BC

@ -516,3 +516,22 @@ class Base {
} }
} }
// EXPORT_DEVICE exports a device type from a specific namespace to
// the 'kaleidoscope' namespace as type 'Device'. The corresponding
// properties type is also exported as 'DeviceProps'.
//
// Please note that this macro expects to find two types, one referenced
// by the macro argument DEVICE and another one, the properties class
// with the name of the type that is passed as DEVICE prefixed by 'Props',
// e.g. Model01 as device and Model01Props as properties class.
//
#ifndef KALEIDOSCOPE_VIRTUAL_BUILD
#define EXPORT_DEVICE(DEVICE) \
typedef DEVICE##Props DeviceProps; \
typedef DEVICE Device;
#else // ifndef KALEIDOSCOPE_VIRTUAL_BUILD
#define EXPORT_DEVICE(DEVICE) \
typedef DEVICE##Props DeviceProps;
#endif // ifndef KALEIDOSCOPE_VIRTUAL_BUILD

Loading…
Cancel
Save