00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef QGLIB_WRAP_H
00019 #define QGLIB_WRAP_H
00020
00021 #include "global.h"
00022
00023 namespace QGlib {
00024
00025 class RefCountedObject;
00026 class Type;
00027
00037 QTGLIB_EXPORT RefCountedObject *constructWrapper(Type instanceType, void *instance);
00038
00039 template <typename T, typename Enable = void>
00040 struct WrapImpl {};
00041
00042 #define QGLIB_REGISTER_WRAPIMPL_FOR_SUBCLASSES_OF(BaseClass, WrapFunc) \
00043 namespace QGlib { \
00044 template <typename T> \
00045 struct WrapImpl<T, typename boost::enable_if< boost::is_base_of<BaseClass, T> >::type > \
00046 { \
00047 static inline RefCountedObject *wrap(typename T::CType *object) \
00048 { \
00049 return WrapFunc(object); \
00050 } \
00051 }; \
00052 } //namespace QGlib
00053
00054 #define QGLIB_REGISTER_INTERFACE(IfaceClass) \
00055 namespace QGlib { \
00056 template <> \
00057 struct WrapImpl<IfaceClass, void> \
00058 { \
00059 static inline RefCountedObject *wrap(IfaceClass::CType *object) \
00060 { \
00061 return Private::wrapInterface(GetType<IfaceClass>(), object); \
00062 } \
00063 }; \
00064 } //namespace QGlib
00065
00066 namespace Private {
00067
00068 QTGLIB_EXPORT RefCountedObject *wrapObject(void *gobject);
00069 QTGLIB_EXPORT RefCountedObject *wrapParamSpec(void *param);
00070 QTGLIB_EXPORT RefCountedObject *wrapInterface(Type interfaceType, void *gobject);
00071
00072 }
00073 }
00074
00075
00076 #endif // QGLIB_WRAP_H