1
/****************************************************************************
3
** Copyright (C) Qxt Foundation. Some rights reserved.
5
** This file is part of the QxtCore module of the Qxt library.
7
** This library is free software; you can redistribute it and/or modify it
8
** under the terms of the Common Public License, version 1.0, as published
9
** by IBM, and/or under the terms of the GNU Lesser General Public License,
10
** version 2.1, as published by the Free Software Foundation.
12
** This file is provided "AS IS", without WARRANTIES OR CONDITIONS OF ANY
13
** KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY
14
** WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR
15
** FITNESS FOR A PARTICULAR PURPOSE.
17
** You should have received a copy of the CPL and the LGPL along with this
18
** file. See the LICENSE file and the cpl1.0.txt/lgpl-2.1.txt files
19
** included with the source distribution for more information.
20
** If you did not receive a copy of the licenses, contact the Qxt Foundation.
22
** <http://libqxt.org> <foundation@libqxt.org>
24
****************************************************************************/
25
#ifndef QXTMETAOBJECT_H
26
#define QXTMETAOBJECT_H
28
#include <QMetaObject>
30
#include <QGenericArgument>
32
#include "qxtnullable.h"
33
#include "qxtglobal.h"
34
QT_FORWARD_DECLARE_CLASS(QByteArray)
35
class QxtBoundArgument;
36
class QxtBoundFunction;
38
#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()
39
#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()
40
#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
42
class QXT_CORE_EXPORT QxtGenericFunctionPointer
44
template<typename FUNCTION>
45
friend QxtGenericFunctionPointer qxtFuncPtr(FUNCTION funcPtr);
47
QxtGenericFunctionPointer(const QxtGenericFunctionPointer& other)
49
funcPtr = other.funcPtr;
50
typeName = other.typeName;
53
typedef void(voidFunc)();
58
QxtGenericFunctionPointer(voidFunc* ptr, const QByteArray& typeIdName)
61
typeName = typeIdName;
65
template<typename FUNCTION>
66
QxtGenericFunctionPointer qxtFuncPtr(FUNCTION funcPtr)
68
return QxtGenericFunctionPointer(reinterpret_cast<QxtGenericFunctionPointer::voidFunc*>(funcPtr), typeid(funcPtr).name());
71
namespace QxtMetaObject
73
QXT_CORE_EXPORT QByteArray methodName(const char* method);
74
QXT_CORE_EXPORT QByteArray methodSignature(const char* method);
76
QXT_CORE_EXPORT bool isSignalOrSlot(const char* method);
78
QXT_CORE_EXPORT QxtBoundFunction* bind(QObject* recv, const char* invokable, QXT_PROTO_10ARGS(QGenericArgument));
79
QXT_CORE_EXPORT QxtBoundFunction* bind(QObject* recv, const char* invokable, QVariant p1, QXT_PROTO_9ARGS(QVariant));
80
QXT_CORE_EXPORT bool connect(QObject* sender, const char* signal, QxtBoundFunction* slot,
81
Qt::ConnectionType type = Qt::AutoConnection);
83
QXT_CORE_EXPORT bool invokeMethod(QObject* object, const char* member,
84
const QVariant& arg0 = QVariant(), const QVariant& arg1 = QVariant(),
85
const QVariant& arg2 = QVariant(), const QVariant& arg3 = QVariant(),
86
const QVariant& arg4 = QVariant(), const QVariant& arg5 = QVariant(),
87
const QVariant& arg6 = QVariant(), const QVariant& arg7 = QVariant(),
88
const QVariant& arg8 = QVariant(), const QVariant& arg9 = QVariant());
90
QXT_CORE_EXPORT bool invokeMethod(QObject* object, const char* member, Qt::ConnectionType type,
91
const QVariant& arg0 = QVariant(), const QVariant& arg1 = QVariant(),
92
const QVariant& arg2 = QVariant(), const QVariant& arg3 = QVariant(),
93
const QVariant& arg4 = QVariant(), const QVariant& arg5 = QVariant(),
94
const QVariant& arg6 = QVariant(), const QVariant& arg7 = QVariant(),
95
const QVariant& arg8 = QVariant(), const QVariant& arg9 = QVariant());
99
* \relates QxtMetaObject
100
* Refers to the n'th parameter of QxtBoundFunction::invoke() or of a signal connected to
101
* a QxtBoundFunction.
102
* \sa QxtMetaObject::bind
104
#define QXT_BIND(n) QGenericArgument("QxtBoundArgument", reinterpret_cast<void*>(n))
106
#endif // QXTMETAOBJECT_H