|
QGroundControl
Ground Control Station for MAVLink Drones
|
#include <LoopState.h>
Inheritance diagram for LoopState< T >:
Collaboration diagram for LoopState< T >:Public Types | |
| using | ItemAction = std::function< void(const T &item, int index)> |
| using | ItemPredicate = std::function< bool(const T &item, int index)> |
Public Types inherited from QGCAbstractState | |
| using | EntryCallback = std::function< void()> |
| using | ExitCallback = std::function< void()> |
| using | EventHandler = std::function< bool(QEvent *)> |
Public Member Functions | |
| LoopState (const QString &stateName, QState *parent, const QList< T > &items, ItemAction action) | |
| void | setFilter (ItemPredicate filter) |
| Set a predicate to filter items (only items where predicate returns true are processed) | |
| int | currentIndex () const |
| Get the current index being processed. | |
| T | currentItem () const |
| Get the current item being processed. | |
| int | totalItems () const |
| Get the total number of items. | |
| int | processedCount () const |
| Get the number of items processed so far. | |
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) | |
| 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 (EventHandler handler) |
| Set a custom event handler for this state. | |
Protected Member Functions | |
| void | onEnter () override |
| Override to perform actions on state entry. | |
Protected Member Functions inherited from QGCAbstractState | |
| 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 |
Additional Inherited Members | |
Signals inherited from QGCAbstractState | |
| void | advance () |
| void | error () |
A state that iterates over a collection, executing an action for each item.
The state calls the iterator function for each item, emitting itemProcessed() after each. When all items are processed, it emits advance().
Example usage:
Definition at line 26 of file LoopState.h.
| using LoopState< T >::ItemAction = std::function<void(const T& item, int index)> |
Definition at line 29 of file LoopState.h.
| using LoopState< T >::ItemPredicate = std::function<bool(const T& item, int index)> |
Definition at line 30 of file LoopState.h.
|
inline |
Create a LoopState
| stateName | Name for logging |
| parent | Parent state |
| items | Collection to iterate over |
| action | Action to execute for each item |
Definition at line 37 of file LoopState.h.
|
inline |
Get the current index being processed.
Definition at line 49 of file LoopState.h.
|
inline |
Get the current item being processed.
Definition at line 52 of file LoopState.h.
|
inlineoverrideprotectedvirtual |
Override to perform actions on state entry.
Reimplemented from QGCAbstractState.
Definition at line 62 of file LoopState.h.
|
inline |
Get the number of items processed so far.
Definition at line 59 of file LoopState.h.
|
inline |
Set a predicate to filter items (only items where predicate returns true are processed)
Definition at line 46 of file LoopState.h.
|
inline |
Get the total number of items.
Definition at line 56 of file LoopState.h.