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

#include <SubMachineState.h>

+ Inheritance diagram for SubMachineState:
+ Collaboration diagram for SubMachineState:

Public Types

using MachineFactory = std::function< QGCStateMachine *(SubMachineState *parent)>
 
- Public Types inherited from QGCAbstractState
using EntryCallback = std::function< void()>
 
using ExitCallback = std::function< void()>
 
using EventHandler = std::function< bool(QEvent *)>
 

Signals

void childError ()
 Emitted when the child machine encounters an error.
 
- Signals inherited from QGCAbstractState
void advance ()
 
void error ()
 

Public Member Functions

 SubMachineState (const QString &stateName, QState *parent, MachineFactory factory)
 
QGCStateMachinechildMachine () const
 Get the currently running child machine (nullptr if not running)
 
- Public Member Functions inherited from QGCState
 QGCState (const QString &stateName, QState *parentState)
 
template<typename PointerToMemberFunction >
QSignalTransition * addThisTransition (PointerToMemberFunction signal, QAbstractState *target)
 Simpler version of QState::addTransition which assumes the sender is this.
 
void setLocalErrorState (QAbstractState *errorState)
 
QAbstractState * localErrorState () const
 Get the per-state error state (nullptr if using global)
 
void setProperty (QObject *object, const char *name, const QVariant &value)
 
void setEnabled (QObject *object, bool enabled)
 Convenience overload for setting enabled state on widgets/controls.
 
void setVisible (QObject *object, bool visible)
 Convenience overload for setting visible state on widgets/controls.
 
- Public Member Functions inherited from QGCAbstractState
 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

void onEntry (QEvent *event) override
 
void onExit (QEvent *event) override
 
- Protected Member Functions inherited from QGCAbstractState
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

State that invokes a child state machine When entered, creates and starts a child state machine. When the child machine finishes, emits advance() or error().

Definition at line 12 of file SubMachineState.h.

Member Typedef Documentation

◆ MachineFactory

Factory function type for creating child state machines

Parameters
parentThe SubMachineState that will own the child machine
Returns
The configured child state machine (do not start it)

Definition at line 21 of file SubMachineState.h.

Constructor & Destructor Documentation

◆ SubMachineState()

SubMachineState::SubMachineState ( const QString &  stateName,
QState *  parent,
MachineFactory  factory 
)

Create a sub-machine state

Parameters
stateNameName for debugging
parentParent state or machine
factoryFunction that creates the child state machine

Definition at line 5 of file SubMachineState.cc.

Member Function Documentation

◆ childError

void SubMachineState::childError ( )
signal

Emitted when the child machine encounters an error.

◆ childMachine()

QGCStateMachine * SubMachineState::childMachine ( ) const
inline

Get the currently running child machine (nullptr if not running)

Definition at line 30 of file SubMachineState.h.

◆ onEntry()

void SubMachineState::onEntry ( QEvent *  event)
overrideprotected

◆ onExit()

void SubMachineState::onExit ( QEvent *  event)
overrideprotected

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