24#if SMTG_CPP11_STDLIBSUPPORT
37#define INLINE_UID(l1, l2, l3, l4) \
39 (::Steinberg::int8)(((::Steinberg::uint32)(l1) & 0x000000FF) ), (::Steinberg::int8)(((::Steinberg::uint32)(l1) & 0x0000FF00) >> 8), \
40 (::Steinberg::int8)(((::Steinberg::uint32)(l1) & 0x00FF0000) >> 16), (::Steinberg::int8)(((::Steinberg::uint32)(l1) & 0xFF000000) >> 24), \
41 (::Steinberg::int8)(((::Steinberg::uint32)(l2) & 0x00FF0000) >> 16), (::Steinberg::int8)(((::Steinberg::uint32)(l2) & 0xFF000000) >> 24), \
42 (::Steinberg::int8)(((::Steinberg::uint32)(l2) & 0x000000FF) ), (::Steinberg::int8)(((::Steinberg::uint32)(l2) & 0x0000FF00) >> 8), \
43 (::Steinberg::int8)(((::Steinberg::uint32)(l3) & 0xFF000000) >> 24), (::Steinberg::int8)(((::Steinberg::uint32)(l3) & 0x00FF0000) >> 16), \
44 (::Steinberg::int8)(((::Steinberg::uint32)(l3) & 0x0000FF00) >> 8), (::Steinberg::int8)(((::Steinberg::uint32)(l3) & 0x000000FF) ), \
45 (::Steinberg::int8)(((::Steinberg::uint32)(l4) & 0xFF000000) >> 24), (::Steinberg::int8)(((::Steinberg::uint32)(l4) & 0x00FF0000) >> 16), \
46 (::Steinberg::int8)(((::Steinberg::uint32)(l4) & 0x0000FF00) >> 8), (::Steinberg::int8)(((::Steinberg::uint32)(l4) & 0x000000FF) ) \
49#define INLINE_UID(l1, l2, l3, l4) \
51 (::Steinberg::int8)(((::Steinberg::uint32)(l1) & 0xFF000000) >> 24), (::Steinberg::int8)(((::Steinberg::uint32)(l1) & 0x00FF0000) >> 16), \
52 (::Steinberg::int8)(((::Steinberg::uint32)(l1) & 0x0000FF00) >> 8), (::Steinberg::int8)(((::Steinberg::uint32)(l1) & 0x000000FF) ), \
53 (::Steinberg::int8)(((::Steinberg::uint32)(l2) & 0xFF000000) >> 24), (::Steinberg::int8)(((::Steinberg::uint32)(l2) & 0x00FF0000) >> 16), \
54 (::Steinberg::int8)(((::Steinberg::uint32)(l2) & 0x0000FF00) >> 8), (::Steinberg::int8)(((::Steinberg::uint32)(l2) & 0x000000FF) ), \
55 (::Steinberg::int8)(((::Steinberg::uint32)(l3) & 0xFF000000) >> 24), (::Steinberg::int8)(((::Steinberg::uint32)(l3) & 0x00FF0000) >> 16), \
56 (::Steinberg::int8)(((::Steinberg::uint32)(l3) & 0x0000FF00) >> 8), (::Steinberg::int8)(((::Steinberg::uint32)(l3) & 0x000000FF) ), \
57 (::Steinberg::int8)(((::Steinberg::uint32)(l4) & 0xFF000000) >> 24), (::Steinberg::int8)(((::Steinberg::uint32)(l4) & 0x00FF0000) >> 16), \
58 (::Steinberg::int8)(((::Steinberg::uint32)(l4) & 0x0000FF00) >> 8), (::Steinberg::int8)(((::Steinberg::uint32)(l4) & 0x000000FF) ) \
63#define DECLARE_UID(name, l1, l2, l3, l4) SMTG_CONSTEXPR14 ::Steinberg::TUID name = INLINE_UID (l1, l2, l3, l4);
66#define EXTERN_UID(name) extern const ::Steinberg::TUID name;
69#define DECLARE_CLASS_IID(ClassName, l1, l2, l3, l4) \
70 static SMTG_CONSTEXPR14 const ::Steinberg::TUID ClassName##_iid = INLINE_UID (l1, l2, l3, l4); \
71 const ::Steinberg::FUID ClassName::iid (ClassName##_iid);
73#define DECLARE_CLASS_IID(ClassName, l1, l2, l3, l4) \
74 static SMTG_CONSTEXPR14 const ::Steinberg::TUID ClassName##_iid = INLINE_UID (l1, l2, l3, l4);
77#define DEF_CLASS_IID(ClassName) const ::Steinberg::FUID ClassName::iid (ClassName##_iid);
79#define INLINE_UID_OF(ClassName) ClassName##_iid
81#define INLINE_UID_FROM_FUID(x) \
82 INLINE_UID (x.getLong1 (), x.getLong2 (), x.getLong3 (), x.getLong4 ())
88#define DECLARE_FUNKNOWN_METHODS \
90 virtual ::Steinberg::tresult PLUGIN_API queryInterface (const ::Steinberg::TUID _iid, void** obj) SMTG_OVERRIDE; \
91 virtual ::Steinberg::uint32 PLUGIN_API addRef () SMTG_OVERRIDE; \
92 virtual ::Steinberg::uint32 PLUGIN_API release () SMTG_OVERRIDE; \
94 ::Steinberg::int32 __funknownRefCount; \
99#define DELEGATE_REFCOUNT(ClassName) \
101 virtual ::Steinberg::uint32 PLUGIN_API addRef () SMTG_OVERRIDE { return ClassName::addRef (); } \
102 virtual ::Steinberg::uint32 PLUGIN_API release () SMTG_OVERRIDE { return ClassName::release (); }
105#define IMPLEMENT_REFCOUNT(ClassName) \
106::Steinberg::uint32 PLUGIN_API ClassName::addRef () \
108 return ::Steinberg::FUnknownPrivate::atomicAdd (__funknownRefCount, 1); \
110::Steinberg::uint32 PLUGIN_API ClassName::release () \
112 if (::Steinberg::FUnknownPrivate::atomicAdd (__funknownRefCount, -1) == 0) \
117 return __funknownRefCount; \
121#define FUNKNOWN_CTOR { __funknownRefCount = 1; }
122#if SMTG_FUNKNOWN_DTOR_ASSERT
124#define FUNKNOWN_DTOR { assert (__funknownRefCount == 0); }
130#define QUERY_INTERFACE(iid, obj, InterfaceIID, InterfaceName) \
131if (::Steinberg::FUnknownPrivate::iidEqual (iid, InterfaceIID)) \
134 *obj = static_cast< InterfaceName* >(this); \
135 return ::Steinberg::kResultOk; \
139#define IMPLEMENT_QUERYINTERFACE(ClassName, InterfaceName, ClassIID) \
140::Steinberg::tresult PLUGIN_API ClassName::queryInterface (const ::Steinberg::TUID _iid, void** obj)\
142 QUERY_INTERFACE (_iid, obj, ::Steinberg::FUnknown::iid, InterfaceName) \
143 QUERY_INTERFACE (_iid, obj, ClassIID, InterfaceName) \
145 return ::Steinberg::kNoInterface; \
149#define IMPLEMENT_FUNKNOWN_METHODS(ClassName,InterfaceName,ClassIID) \
150 IMPLEMENT_REFCOUNT (ClassName) \
151 IMPLEMENT_QUERYINTERFACE (ClassName, InterfaceName, ClassIID)
164 kNoInterface =
static_cast<tresult
>(0x80004002L),
165 kResultOk =
static_cast<tresult
>(0x00000000L),
166 kResultTrue = kResultOk,
167 kResultFalse =
static_cast<tresult
>(0x00000001L),
168 kInvalidArgument =
static_cast<tresult
>(0x80070057L),
169 kNotImplemented =
static_cast<tresult
>(0x80004001L),
170 kInternalError =
static_cast<tresult
>(0x80004005L),
171 kNotInitialized =
static_cast<tresult
>(0x8000FFFFL),
172 kOutOfMemory =
static_cast<tresult
>(0x8007000EL)
177 kNoInterface =
static_cast<tresult
>(0x80000004L),
178 kResultOk =
static_cast<tresult
>(0x00000000L),
179 kResultTrue = kResultOk,
180 kResultFalse =
static_cast<tresult
>(0x00000001L),
181 kInvalidArgument =
static_cast<tresult
>(0x80000003L),
182 kNotImplemented =
static_cast<tresult
>(0x80000001L),
183 kInternalError =
static_cast<tresult
>(0x80000008L),
184 kNotInitialized =
static_cast<tresult
>(0x8000FFFFL),
185 kOutOfMemory =
static_cast<tresult
>(0x80000002L)
193 kResultTrue = kResultOk,
204typedef int64 LARGE_INT;
213inline SMTG_CONSTEXPR14
void copyTUID (
char* dst,
const char* src)
215 for (
auto i = 0; i < 16; ++i)
222namespace FUnknownPrivate {
223SMTG_ALWAYS_INLINE
bool iidEqual (
const void* iid1,
const void* iid2)
225 const uint64* p1 =
reinterpret_cast<const uint64*
> (iid1);
226 const uint64* p2 =
reinterpret_cast<const uint64*
> (iid2);
227 return p1[0] == p2[0] && p1[1] == p2[1];
230int32 PLUGIN_API atomicAdd (int32& value, int32 amount);
245 FUID (uint32 l1, uint32 l2, uint32 l3, uint32 l4);
249#if SMTG_CPP11_STDLIBSUPPORT
264 bool operator == (
const FUID& f)
const { return ::Steinberg::FUnknownPrivate::iidEqual (data, f.data); }
265 bool operator < (
const FUID& f)
const {
return memcmp (data, f.data, sizeof (
TUID)) < 0; }
266 bool operator != (
const FUID& f)
const {
return !::Steinberg::FUnknownPrivate::iidEqual (data, f.data); }
268 uint32 getLong1 ()
const;
269 uint32 getLong2 ()
const;
270 uint32 getLong3 ()
const;
271 uint32 getLong4 ()
const;
273 void from4Int (uint32 d1, uint32 d2, uint32 d3, uint32 d4);
274 void to4Int (uint32& d1, uint32& d2, uint32& d3, uint32& d4)
const;
290 void toString (char8*
string)
const;
315 void print (int32 style, char8*
string =
nullptr,
size_t stringBufferSize = 0)
const;
318 [[deprecated (
"Use the print method with the buffer size")]]
323 inline explicit FUID (
const char (&uid)[N])
325#if SMTG_CPP11_STDLIBSUPPORT
326 static_assert (N ==
sizeof (
TUID),
"only TUID allowed");
328 memcpy (data, uid,
sizeof (TUID));
330 inline void toTUID (TUID result)
const {
memcpy (result, data,
sizeof (TUID)); }
331 inline operator const TUID& ()
const {
return data; }
332 inline const TUID& toTUID ()
const {
return data; }
334 static FUID fromTUID (
const TUID uid)
338 memcpy (res.data, uid, sizeof (TUID));
347#if SMTG_CPP11_STDLIBSUPPORT
349inline bool operator== (
const FUID& f1, T f2)
353 "Do not compare a FUID with a TUID directly. Either convert the TUID to a FUID and compare them or use FUnknownPrivate::iidEqual");
354 return f1.operator== (f2);
396 static const FUID iid;
401DECLARE_CLASS_IID (
FUnknown, 0x00000000, 0x00000000, 0xC0000000, 0x00000046)
429 inline I* operator= (
FUnknown* unknown);
430 inline I* getInterface () {
return this->ptr; }
432#if SMTG_CPP11_STDLIBSUPPORT
442#if SMTG_CPP11_STDLIBSUPPORT
445namespace FUnknownPrivate {
454using VoidT =
typename Void<T>::Type;
461template <
typename T,
typename U =
void>
468struct HasIIDType<T, FUnknownPrivate::VoidT<typename T::IID>> :
std::true_type
479const TUID& getTUID ()
481 return T::IID::toTUID ();
488const TUID& getTUID ()
490 return T::iid.toTUID ();
496const TUID& getTUID ()
498 return T::iid.toTUID ();
505inline FUnknownPtr<I>::FUnknownPtr (FUnknown* unknown)
507 if (unknown && unknown->queryInterface (getTUID<I> (), (
void**)&this->ptr) != kResultOk)
513inline I* FUnknownPtr<I>::operator= (FUnknown* unknown)
516 if (unknown && unknown->queryInterface (getTUID<I> (), (
void**)&newPtr) == kResultOk)
518 OPtr<I> rel (newPtr);
519 return IPtr<I>::operator= (newPtr);
522 return IPtr<I>::operator= (0);
Handling 16 Byte Globally Unique Identifiers.
void toString(char8 *string) const
Converts UID to a string.
bool fromRegistryString(const char8 *string)
Sets the UID data from a string in Microsoft(R) OLE format.
bool fromString(const char8 *string)
Sets the UID data from a string.
bool isValid() const
Checks if the UID data is valid.
void toRegistryString(char8 *string) const
Converts UID to a string in Microsoft(R) OLE format.
void print(int32 style, char8 *string=nullptr, size_t stringBufferSize=0) const
Prints the UID to a string (or debug output if string is NULL).
@ kCLASS_UID
"DECLARE_CLASS_IID (Interface, 0x00000000, 0x00000000, 0x00000000, 0x00000000)"
@ kDECLARE_UID
"DECLARE_UID (0x00000000, 0x00000000, 0x00000000, 0x00000000)"
@ kINLINE_UID
"INLINE_UID (0x00000000, 0x00000000, 0x00000000, 0x00000000)"
@ kFUID
"FUID (0x00000000, 0x00000000, 0x00000000, 0x00000000)"
bool generate()
Generates a new Unique Identifier (UID).
FUnknownPtr - automatic interface conversion and smart pointer in one.
The basic interface of all interfaces.
virtual uint32 PLUGIN_API addRef()=0
Adds a reference and returns the new reference count.
virtual uint32 PLUGIN_API release()=0
Releases a reference and returns the new reference count.
virtual tresult PLUGIN_API queryInterface(const TUID _iid, void **obj)=0
Query for a pointer to the specified interface.
IPtr - Smart pointer template class.
char TUID[16]
plain UID type
Release an interface using automatic object (obsolete).