Lightweight base class for simple states. More...
#include <QGCAbstractState.h>
Public Types | |
| using | EntryCallback = std::function<void()> |
| using | ExitCallback = std::function<void()> |
| using | EventHandler = std::function<bool(QEvent*)> |
Signals | |
| void | advance () |
| void | error () |
Public Member Functions | |
| QGCAbstractState (const QString &stateName, QState *parent) | |
| QGCStateMachine * | machine () const |
| Vehicle * | vehicle () const |
| QString | stateName () const |
| class StateContext * | context () const |
| void | setOnEntry (EntryCallback callback) |
| Set a callback to be invoked when the state is entered. | |
| void | setOnExit (ExitCallback callback) |
| Set a callback to be invoked when the state is exited. | |
| void | setCallbacks (EntryCallback onEntry, ExitCallback onExit=nullptr) |
| Set both entry and exit callbacks. | |
| void | setEventHandler (EventHandlerEventHandler handler) |
| Set a custom event handler for this state. | |
Protected Member Functions | |
| virtual void | onEnter () |
| Override to perform actions on state entry. | |
| virtual void | onLeave () |
| Override to perform actions on state exit. | |
| void | onEntry (QEvent *event) override |
| void | onExit (QEvent *event) override |
| bool | event (QEvent *event) override |
Lightweight base class for simple states.
Use QGCAbstractState when:
Use QGCState when:
Definition at line 28 of file QGCAbstractState.h.
| using QGCAbstractState::EntryCallback = std::function<void()> |
Definition at line 34 of file QGCAbstractState.h.
| using QGCAbstractState::EventHandler = std::function<bool(QEvent*)> |
Definition at line 36 of file QGCAbstractState.h.
| using QGCAbstractState::ExitCallback = std::function<void()> |
Definition at line 35 of file QGCAbstractState.h.
| QGCAbstractState::QGCAbstractState | ( | const QString & | stateName, |
| QState * | parent ) |
Definition at line 5 of file QGCAbstractState.cc.
References stateName().
Referenced by QGCState::QGCState().
|
signal |
| StateContext * QGCAbstractState::context | ( | ) | const |
Get the state machine's context for inter-state data passing
Definition at line 21 of file QGCAbstractState.cc.
References QGCStateMachine::context(), and machine().
|
signal |
|
overrideprotected |
Definition at line 65 of file QGCAbstractState.cc.
References event().
Referenced by ParallelState::allComplete(), SubMachineState::childError(), event(), ParallelState::onEntry(), onEntry(), SubMachineState::onEntry(), ParallelState::onExit(), onExit(), and SubMachineState::onExit().
| QGCStateMachine * QGCAbstractState::machine | ( | ) | const |
Definition at line 11 of file QGCAbstractState.cc.
Referenced by EventQueuedState::connectWaitSignal(), context(), WaitStateBase::restartWait(), stateName(), and vehicle().
|
inlineprotectedvirtual |
Override to perform actions on state entry.
Reimplemented in CircuitBreakerState, ErrorRecoveryState, FallbackChainState, LoopState< T >, ProgressState, RetryState, RollbackState, and SequenceState.
Definition at line 74 of file QGCAbstractState.h.
Referenced by onEntry().
|
overrideprotected |
Definition at line 41 of file QGCAbstractState.cc.
References event(), onEnter(), and stateName().
Referenced by ParallelState::onEntry(), SubMachineState::onEntry(), and setCallbacks().
|
overrideprotected |
Definition at line 53 of file QGCAbstractState.cc.
References event(), onLeave(), and stateName().
Referenced by ParallelState::onExit(), SubMachineState::onExit(), and setCallbacks().
|
inlineprotectedvirtual |
Override to perform actions on state exit.
Definition at line 77 of file QGCAbstractState.h.
Referenced by onExit().
| void QGCAbstractState::setCallbacks | ( | EntryCallback | onEntry, |
| ExitCallback | onExit = nullptr ) |
Set both entry and exit callbacks.
Definition at line 35 of file QGCAbstractState.cc.
|
inline |
Set a custom event handler for this state.
Definition at line 66 of file QGCAbstractState.h.
|
inline |
Set a callback to be invoked when the state is entered.
Definition at line 53 of file QGCAbstractState.h.
|
inline |
Set a callback to be invoked when the state is exited.
Definition at line 56 of file QGCAbstractState.h.
| QString QGCAbstractState::stateName | ( | ) | const |
Definition at line 26 of file QGCAbstractState.cc.
References machine().
Referenced by AsyncFunctionState::AsyncFunctionState(), CircuitBreakerState::CircuitBreakerState(), ConditionalState::ConditionalState(), DelayState::DelayState(), ErrorRecoveryState::ErrorRecoveryState(), EventQueuedState::EventQueuedState(), EventQueuedState::EventQueuedState(), FallbackChainState::FallbackChainState(), FunctionState::FunctionState(), LoopState< T >::LoopState(), CircuitBreakerState::onEnter(), RollbackState::onEnter(), ParallelState::onEntry(), onEntry(), SubMachineState::onEntry(), ParallelState::onExit(), onExit(), SubMachineState::onExit(), AsyncFunctionState::onWaitEntered(), EventQueuedState::onWaitEntered(), RequestMessageState::onWaitEntered(), RetryableRequestMessageState::onWaitEntered(), SkippableAsyncState::onWaitEntered(), RequestMessageState::onWaitTimeout(), RetryableRequestMessageState::onWaitTimeout(), ParallelState::ParallelState(), ProgressState::ProgressState(), ProgressState::ProgressState(), QGCAbstractState(), QGCState::QGCState(), CircuitBreakerState::reset(), RetryableRequestMessageState::RetryableRequestMessageState(), RetryState::RetryState(), RollbackState::RollbackState(), SequenceState::SequenceState(), QGCState::setLocalErrorState(), ShowAppMessageState::ShowAppMessageState(), SkippableAsyncState::SkippableAsyncState(), SubMachineState::SubMachineState(), WaitForSignalState::WaitForSignalState(), and WaitStateBase::WaitStateBase().
| Vehicle * QGCAbstractState::vehicle | ( | ) | const |
Definition at line 16 of file QGCAbstractState.cc.
References machine(), and QGCStateMachine::vehicle().
Referenced by SendMavlinkCommandState::connectWaitSignal(), WaitForMavlinkMessageState::connectWaitSignal(), WaitForParamResponseState::connectWaitSignal(), SendMavlinkCommandState::disconnectWaitSignal(), WaitForMavlinkMessageState::disconnectWaitSignal(), WaitForParamResponseState::disconnectWaitSignal(), RequestMessageState::onWaitEntered(), and SendMavlinkCommandState::onWaitEntered().