4#ifndef QNATIVEINTERFACE_H
5#define QNATIVEINTERFACE_H
7#include <QtCore/qglobal.h>
16#define QT_DECLARE_NATIVE_INTERFACE_3(NativeInterface, Revision, BaseType) \
18 virtual ~NativeInterface(); \
21 using baseType = BaseType; \
22 static constexpr char const *name = QT_STRINGIFY(NativeInterface); \
23 static constexpr int revision = Revision; \
26 template <typename, typename> \
27 friend struct QNativeInterface::Private::has_type_info; \
30 friend bool constexpr QNativeInterface::Private::hasTypeInfo(); \
33 friend struct QNativeInterface::Private::TypeInfo; \
35 NativeInterface() = default; \
36 Q_DISABLE_COPY_MOVE(NativeInterface)
41#define QT_DECLARE_NATIVE_INTERFACE_2(NativeInterface, Revision) \
42 static_assert(false, "Must provide a base type when specifying revision");
44#define QT_DECLARE_NATIVE_INTERFACE_1(NativeInterface) \
45 QT_DECLARE_NATIVE_INTERFACE_3(NativeInterface, 0, void)
47#define QT_DECLARE_NATIVE_INTERFACE(...) \
48 QT_OVERLOADED_MACRO(QT_DECLARE_NATIVE_INTERFACE, __VA_ARGS__)
54 template <
typename NativeInterface,
typename =
void>
59 template <
typename NativeInterface>
61 typename NativeInterface::TypeInfo,
62 typename NativeInterface::TypeInfo::baseType,
63 decltype(&NativeInterface::TypeInfo::name),
64 decltype(&NativeInterface::TypeInfo::revision)
65 >> : std::true_type {};
70 template <
typename NativeInterface>
76 template <
typename NativeInterface>
82 static constexpr bool haveTypeInfo = hasTypeInfo<NativeInterface>();
86 template <
typename BaseType>
90 return std::is_base_of<typename NativeInterface::TypeInfo::baseType, BaseType>::value;
98 template <
typename BaseType>
107 return NativeInterface::TypeInfo::revision;
112 static constexpr char const *
name()
115 return NativeInterface::TypeInfo::name;
123 template <
typename I>
129#define QT_DECLARE_NATIVE_INTERFACE_ACCESSOR(T) \
130 template <typename QNativeInterface> \
131 QNativeInterface *nativeInterface() const;
133#define QT_DECLARE_NATIVE_INTERFACE_ACCESSOR(T) \
134 template <typename NativeInterface, typename TypeInfo = QNativeInterface::Private::NativeInterface<NativeInterface>, \
135 typename BaseType = T, std::enable_if_t<TypeInfo::template isCompatibleWith<T>, bool> = true> \
136 NativeInterface *nativeInterface() const \
138 return static_cast<NativeInterface*>(resolveInterface( \
139 TypeInfo::name(), TypeInfo::revision())); \
142 void *resolveInterface(const char *name, int revision) const; \
bool constexpr hasTypeInfo()
Combined button and popup list for selecting options.
static constexpr char const * name()
static constexpr bool isCompatibleHelper()
static constexpr bool haveTypeInfo
static constexpr bool isCompatibleWith
static constexpr int revision()