static inline ARA::ToRefConversionHelper<HostClassType, FirstHostRefType, ##__VA_ARGS__> toHostRef (const HostClassType* ptr) noexcept { return ARA::ToRefConversionHelper<HostClassType, FirstHostRefType, ##__VA_ARGS__> { ptr }; } \
template <typename DesiredHostClassType = HostClassType, typename HostRefType, typename std::enable_if<std::is_constructible<ARA::FromRefConversionHelper<HostClassType, FirstHostRefType, ##__VA_ARGS__>, HostRefType>::value, bool>::type = true> \
static inline DesiredHostClassType* fromHostRef (HostRefType ref) noexcept { HostClassType* object { ARA::FromRefConversionHelper<HostClassType, FirstHostRefType, ##__VA_ARGS__> (ref) }; return static_cast<DesiredHostClassType*> (object); }
Type safe conversions to/from host ref: toHostRef () and fromHostRef<> ().
This macro defines custom overloads of the toHostRef () and fromHostRef<> () conversion functions which act as type safe casts between your implementation class pointers and the opaque host refs that the ARA API uses. fromHostRef<>() additionally allows for optional up-casting from base to derived classes if needed. The first macro argument is your implementation class, followed by all host ref types that you want this class to comply with.
Whenever using your C++ object pointers as host refs, you should apply the conversion macros like so:
class MyHostAudioSource;
MyHostAudioSource* audioSource = ...;
MyHostAudioSource* audioSource = fromHostRef (audioSourceHostRef);
#define ARA_MAP_HOST_REF(HostClassType, FirstHostRefType,...)
Type safe conversions to/from host ref: toHostRef () and fromHostRef<> ().
Definition: ARAHostDispatch.h:61
struct ARAAudioSourceHostRefMarkupType * ARAAudioSourceHostRef
Reference to the host side representation of an audio source (opaque to the plug-in).
Definition: ARAInterface.h:792