summaryrefslogtreecommitdiffstats
path: root/src/scxml/qscxmlstatemachine.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/scxml/qscxmlstatemachine.h')
-rw-r--r--src/scxml/qscxmlstatemachine.h78
1 files changed, 78 insertions, 0 deletions
diff --git a/src/scxml/qscxmlstatemachine.h b/src/scxml/qscxmlstatemachine.h
index 787a7c6..e5a0b92 100644
--- a/src/scxml/qscxmlstatemachine.h
+++ b/src/scxml/qscxmlstatemachine.h
@@ -50,6 +50,7 @@
#include <QVector>
#include <QUrl>
#include <QVariantList>
+#include <QPointer>
QT_BEGIN_NAMESPACE
class QIODevice;
@@ -169,6 +170,83 @@ public:
}
#endif
+#ifdef Q_QDOC
+ static auto onEntry(const QObject *receiver, const char *method);
+ static auto onExit(const QObject *receiver, const char *method);
+
+ template<typename Functor>
+ static auto onEntry(Functor functor);
+
+ template<typename Functor>
+ static auto onExit(Functor functor);
+
+ template<typename PointerToMemberFunction>
+ static auto onEntry(const QObject *receiver, PointerToMemberFunction method);
+
+ template<typename PointerToMemberFunction>
+ static auto onExit(const QObject *receiver, PointerToMemberFunction method);
+#elif defined(__cpp_return_type_deduction) && __cpp_return_type_deduction == 201304
+ static auto onEntry(const QObject *receiver, const char *method)
+ {
+ const QPointer<QObject> receiverPointer(const_cast<QObject *>(receiver));
+ return [receiverPointer, method](bool isEnteringState) {
+ if (isEnteringState && !receiverPointer.isNull())
+ QMetaObject::invokeMethod(const_cast<QObject *>(receiverPointer.data()), method);
+ };
+ }
+
+ static auto onExit(const QObject *receiver, const char *method)
+ {
+ const QPointer<QObject> receiverPointer(const_cast<QObject *>(receiver));
+ return [receiverPointer, method](bool isEnteringState) {
+ if (!isEnteringState && !receiverPointer.isNull())
+ QMetaObject::invokeMethod(receiverPointer.data(), method);
+ };
+ }
+
+ template<typename Functor>
+ static auto onEntry(Functor functor)
+ {
+ return [functor](bool isEnteringState) {
+ if (isEnteringState)
+ functor();
+ };
+ }
+
+ template<typename Functor>
+ static auto onExit(Functor functor)
+ {
+ return [functor](bool isEnteringState) {
+ if (!isEnteringState)
+ functor();
+ };
+ }
+
+ template<typename Func1>
+ static auto onEntry(const typename QtPrivate::FunctionPointer<Func1>::Object *receiver,
+ Func1 slot)
+ {
+ typedef typename QtPrivate::FunctionPointer<Func1>::Object Object;
+ const QPointer<Object> receiverPointer(const_cast<Object *>(receiver));
+ return [receiverPointer, slot](bool isEnteringState) {
+ if (isEnteringState && !receiverPointer.isNull())
+ (receiverPointer->*slot)();
+ };
+ }
+
+ template<typename Func1>
+ static auto onExit(const typename QtPrivate::FunctionPointer<Func1>::Object *receiver,
+ Func1 slot)
+ {
+ typedef typename QtPrivate::FunctionPointer<Func1>::Object Object;
+ const QPointer<Object> receiverPointer(const_cast<Object *>(receiver));
+ return [receiverPointer, slot](bool isEnteringState) {
+ if (!isEnteringState && !receiverPointer.isNull())
+ (receiverPointer->*slot)();
+ };
+ }
+#endif // defined(__cpp_return_type_deduction) && __cpp_return_type_deduction == 201304
+
QMetaObject::Connection connectToEvent(const QString &scxmlEventSpec,
const QObject *receiver, const char *method,
Qt::ConnectionType type = Qt::AutoConnection);