1 /****************************************************************************
3 ** Copyright (C) Qxt Foundation. Some rights reserved.
5 ** This file is part of the QxtCore module of the Qt eXTension library
7 ** This library is free software; you can redistribute it and/or modify it
8 ** under the terms of th Common Public License, version 1.0, as published by
11 ** This file is provided "AS IS", without WARRANTIES OR CONDITIONS OF ANY
12 ** KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY
13 ** WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR
14 ** FITNESS FOR A PARTICULAR PURPOSE.
16 ** You should have received a copy of the CPL along with this file.
17 ** See the LICENSE file and the cpl1.0.txt file included with the source
18 ** distribution for more information. If you did not receive a copy of the
19 ** license, contact the Qxt Foundation.
21 ** <http://libqxt.sourceforge.net> <foundation@libqxt.org>
23 ****************************************************************************/
24 #ifndef QXTMETAOBJECT_H
25 #define QXTMETAOBJECT_H
27 #include <QMetaObject>
29 #include <QGenericArgument>
31 #include "qxtnullable.h"
33 class QxtBoundArgument;
34 class QxtBoundFunction;
36 #define QXT_PROTO_10ARGS(T) T p1 = T(), T p2 = T(), T p3 = T(), T p4 = T(), T p5 = T(), T p6 = T(), T p7 = T(), T p8 = T(), T p9 = T(), T p10 = T()
37 #define QXT_PROTO_9ARGS(T) T p2 = T(), T p3 = T(), T p4 = T(), T p5 = T(), T p6 = T(), T p7 = T(), T p8 = T(), T p9 = T(), T p10 = T()
38 #define QXT_IMPL_10ARGS(T) T p1, T p2, T p3, T p4, T p5, T p6, T p7, T p8, T p9, T p10
40 class QxtGenericFunctionPointer {
41 template<typename FUNCTION>
42 friend QxtGenericFunctionPointer qxtFuncPtr(FUNCTION funcPtr);
44 QxtGenericFunctionPointer(const QxtGenericFunctionPointer& other) {
45 funcPtr = other.funcPtr;
46 typeName = other.typeName;
49 typedef void(voidFunc)();
54 QxtGenericFunctionPointer(voidFunc* ptr, const QByteArray& typeIdName) {
56 typeName = typeIdName;
60 template<typename FUNCTION>
61 QxtGenericFunctionPointer qxtFuncPtr(FUNCTION funcPtr) {
62 return QxtGenericFunctionPointer(reinterpret_cast<QxtGenericFunctionPointer::voidFunc*>(funcPtr), typeid(funcPtr).name());
65 namespace QxtMetaObject
67 QXT_CORE_EXPORT QByteArray methodName(const char* method);
68 QXT_CORE_EXPORT QByteArray methodSignature(const char* method);
70 QXT_CORE_EXPORT bool isSignalOrSlot (const char* method);
72 QXT_CORE_EXPORT QxtBoundFunction* bind(QObject* recv, const char* invokable, QXT_PROTO_10ARGS(QGenericArgument));
73 QXT_CORE_EXPORT QxtBoundFunction* bind(QObject* recv, const char* invokable, QVariant p1, QXT_PROTO_9ARGS(QVariant));
74 QXT_CORE_EXPORT bool connect(QObject* sender, const char* signal, QxtBoundFunction* slot,
75 Qt::ConnectionType type = Qt::AutoConnection);
79 * \relates QxtMetaObject
80 * \sa QxtMetaObject::bind
81 * Refers to the n'th parameter of QxtBoundFunction::invoke() or a signal connected to
84 #define QXT_BIND(n) QGenericArgument("QxtBoundArgument", reinterpret_cast<void*>(n))
86 #endif // QXTMETAOBJECT_H