QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
RollbackState.h
Go to the documentation of this file.
1#pragma once
2
3#include "QGCState.h"
4
5#include <functional>
6
23class RollbackState : public QGCState
24{
25 Q_OBJECT
26 Q_DISABLE_COPY(RollbackState)
27
28public:
30 using ForwardAction = std::function<bool()>;
31
33 using RollbackAction = std::function<void()>;
34
39 RollbackState(const QString& stateName, QState* parent,
40 ForwardAction forwardAction, RollbackAction rollbackAction);
41
43 bool wasRolledBack() const { return _wasRolledBack; }
44
46 bool rollbackSucceeded() const { return _rollbackSucceeded; }
47
48signals:
51
54
57
60
61protected:
62 void onEnter() override;
63
64private:
65 ForwardAction _forwardAction;
66 RollbackAction _rollbackAction;
67 bool _wasRolledBack = false;
68 bool _rollbackSucceeded = false;
69};
QString stateName() const
Full-featured base class for QGroundControl state machine states.
Definition QGCState.h:23
A state that executes an action with automatic rollback on failure.
void onEnter() override
Override to perform actions on state entry.
bool wasRolledBack() const
Check if rollback was executed.
std::function< bool()> ForwardAction
Forward action - returns true on success.
void forwardSucceeded()
Emitted when forward action succeeds.
void rollingBack()
Emitted when rollback starts.
bool rollbackSucceeded() const
Check if rollback succeeded (only valid if wasRolledBack() is true)
void forwardFailed()
Emitted when forward action fails (before rollback)
void rollbackComplete()
Emitted when rollback completes.
std::function< void()> RollbackAction
Rollback action - executed on forward failure.