QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
RetryTransition.h
Go to the documentation of this file.
1#pragma once
2
4
5#include <QtCore/QLoggingCategory>
6
7#include <functional>
8
27{
28 Q_OBJECT
29 Q_DISABLE_COPY(RetryTransition)
30
31public:
32 using RetryAction = std::function<void()>;
33
40 template<typename Func>
41 RetryTransition(const typename QtPrivate::FunctionPointer<Func>::Object* sender,
42 Func signalFn,
43 QAbstractState* target,
44 RetryAction retryAction,
45 int maxRetries = 1)
46 : QGCSignalTransition(sender, signalFn)
47 , _retryAction(std::move(retryAction))
48 , _maxRetries(maxRetries)
49 {
50 setTargetState(target);
51 }
52
54 void reset() { _retryCount = 0; }
55
57 int retryCount() const { return _retryCount; }
58
60 int maxRetries() const { return _maxRetries; }
61
62protected:
65 bool eventTest(QEvent* event) override;
66
68 void onTransition(QEvent* event) override;
69
70private:
71 RetryAction _retryAction;
72 int _maxRetries = 1;
73 int _retryCount = 0;
74};
Base class for signal-based transitions that need access to QGCStateMachine and Vehicle.
void onTransition(QEvent *event) override
Called when transition fires (after max retries)
int retryCount() const
Get current retry count.
std::function< void()> RetryAction
void reset()
Reset retry count (call when re-entering the source state)
int maxRetries() const
Get max retries setting.
RetryTransition(const typename QtPrivate::FunctionPointer< Func >::Object *sender, Func signalFn, QAbstractState *target, RetryAction retryAction, int maxRetries=1)
bool eventTest(QEvent *event) override