QtGStreamer  0.10.2
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator
wrap.h
00001 /*
00002     Copyright (C) 2010 Collabora Ltd. <info@collabora.co.uk>
00003       @author George Kiagiadakis <george.kiagiadakis@collabora.co.uk>
00004 
00005     This library is free software; you can redistribute it and/or modify
00006     it under the terms of the GNU Lesser General Public License as published
00007     by the Free Software Foundation; either version 2.1 of the License, or
00008     (at your option) any later version.
00009 
00010     This program is distributed in the hope that it will be useful,
00011     but WITHOUT ANY WARRANTY; without even the implied warranty of
00012     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013     GNU Lesser General Public License for more details.
00014 
00015     You should have received a copy of the GNU Lesser General Public License
00016     along with this program.  If not, see <http://www.gnu.org/licenses/>.
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 } //namespace Private
00073 } //namespace QGlib
00074 
00075 
00076 #endif // QGLIB_WRAP_H