/thirdparty/qxt/qxtweb-standalone/qxtweb/qxtmetaobject.h

http://github.com/tomahawk-player/tomahawk · C Header · 106 lines · 63 code · 13 blank · 30 comment · 0 complexity · 10b99ed47fff2fc0235087a12890a09e MD5 · raw file

  1. /****************************************************************************
  2. **
  3. ** Copyright (C) Qxt Foundation. Some rights reserved.
  4. **
  5. ** This file is part of the QxtCore module of the Qxt library.
  6. **
  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.
  11. **
  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.
  16. **
  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.
  21. **
  22. ** <http://libqxt.org> <foundation@libqxt.org>
  23. **
  24. ****************************************************************************/
  25. #ifndef QXTMETAOBJECT_H
  26. #define QXTMETAOBJECT_H
  27. #include <QMetaObject>
  28. #include <QVariant>
  29. #include <QGenericArgument>
  30. #include <typeinfo>
  31. #include "qxtnullable.h"
  32. #include "qxtglobal.h"
  33. QT_FORWARD_DECLARE_CLASS(QByteArray)
  34. class QxtBoundArgument;
  35. 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
  39. class QXT_CORE_EXPORT QxtGenericFunctionPointer
  40. {
  41. template<typename FUNCTION>
  42. friend QxtGenericFunctionPointer qxtFuncPtr(FUNCTION funcPtr);
  43. public:
  44. QxtGenericFunctionPointer(const QxtGenericFunctionPointer& other)
  45. {
  46. funcPtr = other.funcPtr;
  47. typeName = other.typeName;
  48. }
  49. typedef void(voidFunc)();
  50. voidFunc* funcPtr;
  51. QByteArray typeName;
  52. protected:
  53. QxtGenericFunctionPointer(voidFunc* ptr, const QByteArray& typeIdName)
  54. {
  55. funcPtr = ptr;
  56. typeName = typeIdName;
  57. }
  58. };
  59. template<typename FUNCTION>
  60. QxtGenericFunctionPointer qxtFuncPtr(FUNCTION funcPtr)
  61. {
  62. return QxtGenericFunctionPointer(reinterpret_cast<QxtGenericFunctionPointer::voidFunc*>(funcPtr), typeid(funcPtr).name());
  63. }
  64. namespace QxtMetaObject
  65. {
  66. QXT_CORE_EXPORT QByteArray methodName(const char* method);
  67. QXT_CORE_EXPORT QByteArray methodSignature(const char* method);
  68. QXT_CORE_EXPORT bool isSignalOrSlot(const char* method);
  69. QXT_CORE_EXPORT QxtBoundFunction* bind(QObject* recv, const char* invokable, QXT_PROTO_10ARGS(QGenericArgument));
  70. QXT_CORE_EXPORT QxtBoundFunction* bind(QObject* recv, const char* invokable, QVariant p1, QXT_PROTO_9ARGS(QVariant));
  71. QXT_CORE_EXPORT bool connect(QObject* sender, const char* signal, QxtBoundFunction* slot,
  72. Qt::ConnectionType type = Qt::AutoConnection);
  73. QXT_CORE_EXPORT bool invokeMethod(QObject* object, const char* member,
  74. const QVariant& arg0 = QVariant(), const QVariant& arg1 = QVariant(),
  75. const QVariant& arg2 = QVariant(), const QVariant& arg3 = QVariant(),
  76. const QVariant& arg4 = QVariant(), const QVariant& arg5 = QVariant(),
  77. const QVariant& arg6 = QVariant(), const QVariant& arg7 = QVariant(),
  78. const QVariant& arg8 = QVariant(), const QVariant& arg9 = QVariant());
  79. QXT_CORE_EXPORT bool invokeMethod(QObject* object, const char* member, Qt::ConnectionType type,
  80. const QVariant& arg0 = QVariant(), const QVariant& arg1 = QVariant(),
  81. const QVariant& arg2 = QVariant(), const QVariant& arg3 = QVariant(),
  82. const QVariant& arg4 = QVariant(), const QVariant& arg5 = QVariant(),
  83. const QVariant& arg6 = QVariant(), const QVariant& arg7 = QVariant(),
  84. const QVariant& arg8 = QVariant(), const QVariant& arg9 = QVariant());
  85. }
  86. /*!
  87. * \relates QxtMetaObject
  88. * Refers to the n'th parameter of QxtBoundFunction::invoke() or of a signal connected to
  89. * a QxtBoundFunction.
  90. * \sa QxtMetaObject::bind
  91. */
  92. #define QXT_BIND(n) QGenericArgument("QxtBoundArgument", reinterpret_cast<void*>(n))
  93. #endif // QXTMETAOBJECT_H