QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
WaitForSignalState.h
Go to the documentation of this file.
1#pragma once
2
3#include "WaitStateBase.h"
4
5#include <QtCore/QMetaObject>
6
7#include <functional>
8
12{
13 Q_OBJECT
14 Q_DISABLE_COPY(WaitForSignalState)
15
16public:
22 template<typename Func>
23 WaitForSignalState(const QString& stateName, QState* parent,
24 typename QtPrivate::FunctionPointer<Func>::Object* sender,
25 Func signal, int timeoutMsecs = 0)
27 {
28 // Store the connection setup as a lambda to be called on entry
29 // Use a lambda to handle signals with any parameter types
30 _connectFunc = [this, sender, signal]() {
31 _signalConnection = connect(sender, signal, this, [this]() {
32 _onSignalReceived();
33 });
34 };
35 }
36
37protected:
38 void connectWaitSignal() override;
39 void disconnectWaitSignal() override;
40
41private:
42 void _onSignalReceived();
43
44 QMetaObject::Connection _signalConnection;
45 std::function<void()> _connectFunc;
46};
QString stateName() const
void disconnectWaitSignal() override
Subclasses override to tear down their signal connections.
void connectWaitSignal() override
Subclasses override to set up their signal connections.
WaitForSignalState(const QString &stateName, QState *parent, typename QtPrivate::FunctionPointer< Func >::Object *sender, Func signal, int timeoutMsecs=0)
int timeoutMsecs() const