QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
ConditionalState.h
Go to the documentation of this file.
1#pragma once
2
3#include "QGCState.h"
4
5#include <functional>
6
12{
13 Q_OBJECT
14 Q_DISABLE_COPY(ConditionalState)
15
16public:
17 using Predicate = std::function<bool()>;
18 using Action = std::function<void()>;
19
24 ConditionalState(const QString& stateName, QState* parent, Predicate predicate, Action action = Action());
25
27 void setPredicate(Predicate predicate) { _predicate = std::move(predicate); }
28
30 void setAction(Action action) { _action = std::move(action); }
31
32signals:
34 void skipped();
35
36private slots:
37 void _onEntered();
38
39private:
40 Predicate _predicate;
41 Action _action;
42};
A state that evaluates a predicate on entry and either executes or skips.
void setPredicate(Predicate predicate)
Set the predicate.
void setAction(Action action)
Set the action.
void skipped()
Emitted when the predicate returns false and the state is skipped.
std::function< void()> Action
std::function< bool()> Predicate
QString stateName() const
Full-featured base class for QGroundControl state machine states.
Definition QGCState.h:23