|
QGroundControl
Ground Control Station for MAVLink Drones
|
#include <StateContext.h>
Public Member Functions | |
| StateContext ()=default | |
| ~StateContext ()=default | |
| template<typename T > | |
| void | set (const QString &key, T &&value) |
| template<typename T > | |
| std::optional< T > | get (const QString &key) const |
| template<typename T > | |
| T | getOr (const QString &key, const T &defaultValue) const |
| bool | contains (const QString &key) const |
| template<typename T > | |
| bool | containsType (const QString &key) const |
| bool | remove (const QString &key) |
| void | clear () |
| Clear all stored values. | |
| int | count () const |
| Get the number of stored values. | |
| QStringList | keys () const |
| Get all keys in the context. | |
| void | setVariant (const QString &key, const QVariant &value) |
| Store a QVariant value. | |
| QVariant | variant (const QString &key) const |
| Retrieve a QVariant value. | |
| bool | containsVariant (const QString &key) const |
| Check if a variant key exists. | |
Type-safe context for passing data between states in a state machine.
StateContext provides a way for states to share data without tight coupling. Data is stored by key and can be retrieved with type checking.
Example usage:
The context can also be accessed via QGCStateMachine::context().
Definition at line 30 of file StateContext.h.
|
default |
|
default |
|
inline |
Clear all stored values.
Definition at line 108 of file StateContext.h.
|
inline |
Check if a key exists in the context
| key | The key to check |
Definition at line 81 of file StateContext.h.
|
inline |
Check if a key exists and holds the specified type
| key | The key to check |
Definition at line 90 of file StateContext.h.
|
inline |
Check if a variant key exists.
Definition at line 142 of file StateContext.h.
|
inline |
Get the number of stored values.
Definition at line 114 of file StateContext.h.
|
inline |
Retrieve a value by key with type checking
| key | The key to look up |
Definition at line 53 of file StateContext.h.
|
inline |
Retrieve a value by key, returning a default if not found
| key | The key to look up |
| defaultValue | Value to return if key not found or type mismatch |
Definition at line 72 of file StateContext.h.
|
inline |
Get all keys in the context.
Definition at line 120 of file StateContext.h.
|
inline |
Remove a value by key
| key | The key to remove |
Definition at line 102 of file StateContext.h.
|
inline |
Store a value with the given key
| key | Unique identifier for the value |
| value | The value to store |
Definition at line 44 of file StateContext.h.
|
inline |
Store a QVariant value.
Definition at line 130 of file StateContext.h.
|
inline |
Retrieve a QVariant value.
Definition at line 136 of file StateContext.h.