|
C++ YASMIN (Yet Another State MachINe)
|
Runs a series of states in parallel. More...
#include <concurrence.hpp>


Public Member Functions | |
| Concurrence (const StateMap &states, const std::string &default_outcome, const OutcomeMap &outcome_map) | |
| Shared pointer type for Concurrence. | |
| std::string | execute (Blackboard::SharedPtr blackboard) override |
| Executes the state's specific logic. | |
| void | cancel_state () override |
| Cancels the current state execution. | |
| const StateMap & | get_states () const noexcept |
| Returns the map of states managed by this concurrence state. | |
| const OutcomeMap & | get_outcome_map () const noexcept |
| Returns the outcome map for this concurrence state. | |
| const std::string & | get_default_outcome () const noexcept |
| Returns the default outcome for this concurrence state. | |
| std::string | to_string () const override |
| Converts the state to a string representation. | |
Public Member Functions inherited from yasmin::State | |
| State (const Outcomes &outcomes) | |
| Shared pointer type for State. | |
| virtual | ~State ()=default |
| Virtual destructor for proper polymorphic destruction. | |
| bool | is_idle () const noexcept |
| Checks if the state is idle. | |
| bool | is_running () const noexcept |
| Checks if the state is currently running. | |
| bool | is_canceled () const noexcept |
| Checks if the state has been canceled. | |
| bool | is_completed () const noexcept |
| Checks if the state has completed execution. | |
| std::string | operator() (Blackboard::SharedPtr blackboard) |
| Executes the state and returns the outcome. | |
| Outcomes const & | get_outcomes () const noexcept |
| Gets the set of possible outcomes for this state. | |
Protected Attributes | |
| const StateMap | states |
| The states to run concurrently (name -> state) | |
| const std::string | default_outcome |
| Default outcome. | |
| OutcomeMap | outcome_map |
| StateOutcomeMap | intermediate_outcome_map |
| Stores the intermediate outcomes of the concurrent states. | |
| Outcomes | possible_outcomes |
| The set of possible outcomes. | |
Protected Attributes inherited from yasmin::State | |
| Outcomes | outcomes |
| The possible outcomes of this state. | |
Static Private Member Functions | |
| static Outcomes | generate_possible_outcomes (const OutcomeMap &outcome_map, const std::string &default_outcome) |
| Helper function to generate a set of possible outcomes from an outcome map. | |
Private Attributes | |
| std::mutex | intermediate_outcome_mutex |
| Mutex for intermediate outcome map. | |
Runs a series of states in parallel.
The Concurrence class runs a set of states concurrently, waiting for the termination of each, and then returns a single output according to a provided rule map, or a default outcome if no rule is satisfied.
| Concurrence::Concurrence | ( | const StateMap & | states, |
| const std::string & | default_outcome, | ||
| const OutcomeMap & | outcome_map ) |
Shared pointer type for Concurrence.
Constructs a State with a set of possible outcomes.
| states | A map of state names to states that will run concurrently. |
| default_outcome | The default outcome to return if no outcome map rules are satisfied. |
| outcome_map | A map of outcome names to requirements for achieving that outcome. |
|
overridevirtual |
Cancels the current state execution.
This method sets the canceled flag to true and logs the action.
Reimplemented from yasmin::State.
|
overridevirtual |
Executes the state's specific logic.
| blackboard | A shared pointer to the Blackboard to use during execution. |
This method is intended to be overridden by derived classes to provide specific execution logic.
Reimplemented from yasmin::State.
|
staticprivate |
Helper function to generate a set of possible outcomes from an outcome map.
| outcome_map | |
| default_outcome |
|
noexcept |
Returns the default outcome for this concurrence state.
|
noexcept |
Returns the outcome map for this concurrence state.
|
noexcept |
Returns the map of states managed by this concurrence state.
|
overridevirtual |
Converts the state to a string representation.
Reimplemented from yasmin::State.
|
protected |
Default outcome.
|
protected |
Stores the intermediate outcomes of the concurrent states.
|
private |
Mutex for intermediate outcome map.
|
protected |
Specifies which combination of state outputs should produce a given overall output
|
protected |
The set of possible outcomes.
|
protected |
The states to run concurrently (name -> state)