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.h138
1 files changed, 48 insertions, 90 deletions
diff --git a/src/scxml/qscxmlstatemachine.h b/src/scxml/qscxmlstatemachine.h
index 830238c..090a1b6 100644
--- a/src/scxml/qscxmlstatemachine.h
+++ b/src/scxml/qscxmlstatemachine.h
@@ -111,79 +111,49 @@ public:
QMetaObject::Connection connectToState(const QString &scxmlStateName,
const QObject *receiver, const char *method,
Qt::ConnectionType type = Qt::AutoConnection);
-#ifdef Q_QDOC
- template<typename PointerToMemberFunction>
- QMetaObject::Connection connectToState(const QString &scxmlStateName,
- const QObject *receiver, PointerToMemberFunction method,
- Qt::ConnectionType type = Qt::AutoConnection);
- template<typename Functor>
- QMetaObject::Connection connectToState(const QString &scxmlStateName, Functor functor,
- Qt::ConnectionType type = Qt::AutoConnection);
- template<typename Functor>
- QMetaObject::Connection connectToState(const QString &scxmlStateName,
- const QObject *context, Functor functor,
- Qt::ConnectionType type = Qt::AutoConnection);
-#else
// connect state to a QObject slot
- template <typename Func1>
+ template <typename PointerToMemberFunction>
inline QMetaObject::Connection connectToState(
const QString &scxmlStateName,
- const typename QtPrivate::FunctionPointer<Func1>::Object *receiver, Func1 slot,
+ const typename QtPrivate::FunctionPointer<PointerToMemberFunction>::Object *receiver,
+ PointerToMemberFunction method,
Qt::ConnectionType type = Qt::AutoConnection)
{
- typedef QtPrivate::FunctionPointer<Func1> SlotType;
+ typedef QtPrivate::FunctionPointer<PointerToMemberFunction> SlotType;
return connectToStateImpl(
scxmlStateName, receiver, nullptr,
- new QtPrivate::QSlotObject<Func1, typename SlotType::Arguments, void>(slot),
+ new QtPrivate::QSlotObject<PointerToMemberFunction,
+ typename SlotType::Arguments, void>(method),
type);
}
// connect state to a functor or function pointer (without context)
- template <typename Func1>
+ template <typename Functor>
inline typename QtPrivate::QEnableIf<
- !QtPrivate::FunctionPointer<Func1>::IsPointerToMemberFunction &&
- !std::is_same<const char*, Func1>::value, QMetaObject::Connection>::Type
- connectToState(const QString &scxmlStateName, Func1 slot,
+ !QtPrivate::FunctionPointer<Functor>::IsPointerToMemberFunction &&
+ !std::is_same<const char*, Functor>::value, QMetaObject::Connection>::Type
+ connectToState(const QString &scxmlStateName, Functor functor,
Qt::ConnectionType type = Qt::AutoConnection)
{
// Use this as context
- return connectToState(scxmlStateName, this, slot, type);
+ return connectToState(scxmlStateName, this, functor, type);
}
// connectToState to a functor or function pointer (with context)
- template <typename Func1>
+ template <typename Functor>
inline typename QtPrivate::QEnableIf<
- !QtPrivate::FunctionPointer<Func1>::IsPointerToMemberFunction &&
- !std::is_same<const char*, Func1>::value, QMetaObject::Connection>::Type
- connectToState(const QString &scxmlStateName, QObject *context, Func1 slot,
+ !QtPrivate::FunctionPointer<Functor>::IsPointerToMemberFunction &&
+ !std::is_same<const char*, Functor>::value, QMetaObject::Connection>::Type
+ connectToState(const QString &scxmlStateName, const QObject *context, Functor functor,
Qt::ConnectionType type = Qt::AutoConnection)
{
- QtPrivate::QSlotObjectBase *slotObj = new QtPrivate::QFunctorSlotObject<Func1, 1,
- QtPrivate::List<bool>, void>(slot);
- return connectToStateImpl(scxmlStateName, context, reinterpret_cast<void **>(&slot),
+ QtPrivate::QSlotObjectBase *slotObj = new QtPrivate::QFunctorSlotObject<Functor, 1,
+ QtPrivate::List<bool>, void>(functor);
+ return connectToStateImpl(scxmlStateName, context, reinterpret_cast<void **>(&functor),
slotObj, type);
}
-#endif
-
-#ifdef Q_QDOC
- static std::function<void(bool)> onEntry(const QObject *receiver, const char *method);
- static std::function<void(bool)> onExit(const QObject *receiver, const char *method);
-
- template<typename Functor>
- static std::function<void(bool)> onEntry(Functor functor);
-
- template<typename Functor>
- static std::function<void(bool)> onExit(Functor functor);
-
- template<typename PointerToMemberFunction>
- static std::function<void(bool)> onEntry(const QObject *receiver,
- PointerToMemberFunction method);
- template<typename PointerToMemberFunction>
- static std::function<void(bool)> onExit(const QObject *receiver,
- PointerToMemberFunction method);
-#else
static std::function<void(bool)> onEntry(const QObject *receiver, const char *method)
{
const QPointer<QObject> receiverPointer(const_cast<QObject *>(receiver));
@@ -220,89 +190,77 @@ public:
};
}
- template<typename Func1>
+ template<typename PointerToMemberFunction>
static std::function<void(bool)> onEntry(
- const typename QtPrivate::FunctionPointer<Func1>::Object *receiver, Func1 slot)
+ const typename QtPrivate::FunctionPointer<PointerToMemberFunction>::Object *receiver,
+ PointerToMemberFunction method)
{
- typedef typename QtPrivate::FunctionPointer<Func1>::Object Object;
+ typedef typename QtPrivate::FunctionPointer<PointerToMemberFunction>::Object Object;
const QPointer<Object> receiverPointer(const_cast<Object *>(receiver));
- return [receiverPointer, slot](bool isEnteringState) {
+ return [receiverPointer, method](bool isEnteringState) {
if (isEnteringState && !receiverPointer.isNull())
- (receiverPointer->*slot)();
+ (receiverPointer->*method)();
};
}
- template<typename Func1>
+ template<typename PointerToMemberFunction>
static std::function<void(bool)> onExit(
- const typename QtPrivate::FunctionPointer<Func1>::Object *receiver, Func1 slot)
+ const typename QtPrivate::FunctionPointer<PointerToMemberFunction>::Object *receiver,
+ PointerToMemberFunction method)
{
- typedef typename QtPrivate::FunctionPointer<Func1>::Object Object;
+ typedef typename QtPrivate::FunctionPointer<PointerToMemberFunction>::Object Object;
const QPointer<Object> receiverPointer(const_cast<Object *>(receiver));
- return [receiverPointer, slot](bool isEnteringState) {
+ return [receiverPointer, method](bool isEnteringState) {
if (!isEnteringState && !receiverPointer.isNull())
- (receiverPointer->*slot)();
+ (receiverPointer->*method)();
};
}
-#endif // !Q_QDOC
QMetaObject::Connection connectToEvent(const QString &scxmlEventSpec,
const QObject *receiver, const char *method,
Qt::ConnectionType type = Qt::AutoConnection);
-#ifdef Q_QDOC
- template<typename PointerToMemberFunction>
- QMetaObject::Connection connectToEvent(const QString &scxmlEventSpec,
- const QObject *receiver, PointerToMemberFunction method,
- Qt::ConnectionType type = Qt::AutoConnection);
- template<typename Functor>
- QMetaObject::Connection connectToEvent(const QString &scxmlEventSpec, Functor functor,
- Qt::ConnectionType type = Qt::AutoConnection);
- template<typename Functor>
- QMetaObject::Connection connectToEvent(const QString &scxmlEventSpec,
- const QObject *context, Functor functor,
- Qt::ConnectionType type = Qt::AutoConnection);
-#else
-
// connect state to a QObject slot
- template <typename Func1>
+ template <typename PointerToMemberFunction>
inline QMetaObject::Connection connectToEvent(
const QString &scxmlEventSpec,
- const typename QtPrivate::FunctionPointer<Func1>::Object *receiver, Func1 slot,
+ const typename QtPrivate::FunctionPointer<PointerToMemberFunction>::Object *receiver,
+ PointerToMemberFunction method,
Qt::ConnectionType type = Qt::AutoConnection)
{
- typedef QtPrivate::FunctionPointer<Func1> SlotType;
+ typedef QtPrivate::FunctionPointer<PointerToMemberFunction> SlotType;
return connectToEventImpl(
scxmlEventSpec, receiver, nullptr,
- new QtPrivate::QSlotObject<Func1, typename SlotType::Arguments, void>(slot),
+ new QtPrivate::QSlotObject<PointerToMemberFunction,
+ typename SlotType::Arguments, void>(method),
type);
}
// connect state to a functor or function pointer (without context)
- template <typename Func1>
+ template <typename Functor>
inline typename QtPrivate::QEnableIf<
- !QtPrivate::FunctionPointer<Func1>::IsPointerToMemberFunction &&
- !std::is_same<const char*, Func1>::value, QMetaObject::Connection>::Type
- connectToEvent(const QString &scxmlEventSpec, Func1 slot,
+ !QtPrivate::FunctionPointer<Functor>::IsPointerToMemberFunction &&
+ !std::is_same<const char*, Functor>::value, QMetaObject::Connection>::Type
+ connectToEvent(const QString &scxmlEventSpec, Functor functor,
Qt::ConnectionType type = Qt::AutoConnection)
{
// Use this as context
- return connectToEvent(scxmlEventSpec, this, slot, type);
+ return connectToEvent(scxmlEventSpec, this, functor, type);
}
// connectToEvent to a functor or function pointer (with context)
- template <typename Func1>
+ template <typename Functor>
inline typename QtPrivate::QEnableIf<
- !QtPrivate::FunctionPointer<Func1>::IsPointerToMemberFunction &&
- !std::is_same<const char*, Func1>::value, QMetaObject::Connection>::Type
- connectToEvent(const QString &scxmlEventSpec, QObject *context, Func1 slot,
+ !QtPrivate::FunctionPointer<Functor>::IsPointerToMemberFunction &&
+ !std::is_same<const char*, Functor>::value, QMetaObject::Connection>::Type
+ connectToEvent(const QString &scxmlEventSpec, const QObject *context, Functor functor,
Qt::ConnectionType type = Qt::AutoConnection)
{
- QtPrivate::QSlotObjectBase *slotObj = new QtPrivate::QFunctorSlotObject<Func1, 1,
- QtPrivate::List<QScxmlEvent>, void>(slot);
- return connectToEventImpl(scxmlEventSpec, context, reinterpret_cast<void **>(&slot),
+ QtPrivate::QSlotObjectBase *slotObj = new QtPrivate::QFunctorSlotObject<Functor, 1,
+ QtPrivate::List<QScxmlEvent>, void>(functor);
+ return connectToEventImpl(scxmlEventSpec, context, reinterpret_cast<void **>(&functor),
slotObj, type);
}
-#endif
Q_INVOKABLE void submitEvent(QScxmlEvent *event);
Q_INVOKABLE void submitEvent(const QString &eventName);