QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
QGCAbstractState Class Reference

#include <QGCAbstractState.h>

+ Inheritance diagram for QGCAbstractState:
+ Collaboration diagram for QGCAbstractState:

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)
 
QGCStateMachinemachine () const
 
Vehiclevehicle () const
 
QString stateName () const
 
class StateContextcontext () 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 (EventHandler 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
 

Detailed Description

Lightweight base class for simple states.

When to use QGCAbstractState vs QGCState

Use QGCAbstractState when:

  • You want callback-driven entry/exit behavior
  • You want a lighter API surface than QGCState

Use QGCState when:

  • You need to add outgoing transitions using addTransition()
  • You need child states (hierarchical state machine)
  • You need local error state handling (setLocalErrorState())
  • You need property assignment support

Notes

  • Local error-state helpers are not provided; use registerState() for global error handling.

Definition at line 27 of file QGCAbstractState.h.

Member Typedef Documentation

◆ EntryCallback

using QGCAbstractState::EntryCallback = std::function<void()>

Definition at line 33 of file QGCAbstractState.h.

◆ EventHandler

using QGCAbstractState::EventHandler = std::function<bool(QEvent*)>

Definition at line 35 of file QGCAbstractState.h.

◆ ExitCallback

using QGCAbstractState::ExitCallback = std::function<void()>

Definition at line 34 of file QGCAbstractState.h.

Constructor & Destructor Documentation

◆ QGCAbstractState()

QGCAbstractState::QGCAbstractState ( const QString &  stateName,
QState *  parent 
)

Definition at line 5 of file QGCAbstractState.cc.

References stateName().

Member Function Documentation

◆ advance

◆ context()

StateContext * QGCAbstractState::context ( ) const

Get the state machine's context for inter-state data passing

Returns
Pointer to the context, or nullptr if not in a QGCStateMachine

Definition at line 21 of file QGCAbstractState.cc.

References machine().

◆ error

◆ event()

bool QGCAbstractState::event ( QEvent *  event)
overrideprotected

◆ machine()

QGCStateMachine * QGCAbstractState::machine ( ) const

◆ onEnter()

virtual void QGCAbstractState::onEnter ( )
inlineprotectedvirtual

Override to perform actions on state entry.

Reimplemented in ErrorRecoveryState, CircuitBreakerState, FallbackChainState, LoopState< T >, ProgressState, RetryState, RollbackState, and SequenceState.

Definition at line 73 of file QGCAbstractState.h.

Referenced by onEntry().

◆ onEntry()

void QGCAbstractState::onEntry ( QEvent *  event)
overrideprotected

Definition at line 41 of file QGCAbstractState.cc.

References event(), onEnter(), and stateName().

Referenced by ParallelState::onEntry(), SubMachineState::onEntry(), and setCallbacks().

◆ onExit()

void QGCAbstractState::onExit ( QEvent *  event)
overrideprotected

Definition at line 53 of file QGCAbstractState.cc.

References event(), onLeave(), and stateName().

Referenced by ParallelState::onExit(), SubMachineState::onExit(), and setCallbacks().

◆ onLeave()

virtual void QGCAbstractState::onLeave ( )
inlineprotectedvirtual

Override to perform actions on state exit.

Definition at line 76 of file QGCAbstractState.h.

Referenced by onExit().

◆ setCallbacks()

void QGCAbstractState::setCallbacks ( EntryCallback  onEntry,
ExitCallback  onExit = nullptr 
)

Set both entry and exit callbacks.

Definition at line 35 of file QGCAbstractState.cc.

References onEntry(), and onExit().

◆ setEventHandler()

void QGCAbstractState::setEventHandler ( EventHandler  handler)
inline

Set a custom event handler for this state.

Definition at line 65 of file QGCAbstractState.h.

◆ setOnEntry()

void QGCAbstractState::setOnEntry ( EntryCallback  callback)
inline

Set a callback to be invoked when the state is entered.

Definition at line 52 of file QGCAbstractState.h.

◆ setOnExit()

void QGCAbstractState::setOnExit ( ExitCallback  callback)
inline

Set a callback to be invoked when the state is exited.

Definition at line 55 of file QGCAbstractState.h.

◆ stateName()

◆ vehicle()


The documentation for this class was generated from the following files: