QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
FallbackChainState.h
Go to the documentation of this file.
1#pragma once
2
3#include "QGCState.h"
4
5#include <functional>
6
23{
24 Q_OBJECT
25 Q_DISABLE_COPY(FallbackChainState)
26
27public:
29 using Strategy = std::function<bool()>;
30
32 QString name;
34 };
35
36 FallbackChainState(const QString& stateName, QState* parent);
37
41 void addStrategy(const QString& name, Strategy action);
42
44 QString successfulStrategy() const { return _successfulStrategy; }
45
47 int currentStrategyIndex() const { return _currentIndex; }
48
50 int strategyCount() const { return _strategies.size(); }
51
52signals:
54 void tryingStrategy(const QString& name, int index, int total);
55
57 void strategyFailed(const QString& name);
58
60 void strategySucceeded(const QString& name);
61
62protected:
63 void onEnter() override;
64
65private slots:
66 void _tryNextStrategy();
67
68private:
69 QList<StrategyEntry> _strategies;
70 int _currentIndex = -1;
71 QString _successfulStrategy;
72};
std::function< bool()> Strategy
Strategy action - returns true on success.
void onEnter() override
Override to perform actions on state entry.
int strategyCount() const
Get the total number of strategies.
void strategyFailed(const QString &name)
Emitted when a strategy fails and moving to next.
QString successfulStrategy() const
Get the name of the strategy that succeeded.
void tryingStrategy(const QString &name, int index, int total)
Emitted when trying a strategy.
void strategySucceeded(const QString &name)
Emitted when a strategy succeeds.
void addStrategy(const QString &name, Strategy action)
int currentStrategyIndex() const
Get the current strategy index being tried.
QString stateName() const