Class Concurrence

Inheritance Relationships

Base Type

Class Documentation

class Concurrence : public yasmin::State

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.

Public Functions

Concurrence(const StateMap &states, const std::string &default_outcome, const OutcomeMap &outcome_map, const ParameterMappingsMap &parameter_mappings = {})

Shared pointer type for Concurrence.

Constructs a State with a set of possible outcomes.

Parameters:
  • 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.

void set_parameter_mappings(const std::string &state_name, const ParameterMappings &parameter_mappings)

Sets parameter mappings for a child state.

Parameters:
  • state_name – The child state name.

  • parameter_mappings – Mapping entries child_parameter -> parent_parameter.

const ParameterMappingsMap &get_parameter_mappings() const noexcept

Returns the parameter mappings for this concurrence state.

Returns:

A constant reference to the parameter mappings.

virtual void configure() override

Configures this concurrence state and all of its children.

virtual std::string execute(Blackboard::SharedPtr blackboard) override

Executes the state’s specific logic.

This method is intended to be overridden by derived classes to provide specific execution logic.

Parameters:

blackboard – A shared pointer to the Blackboard to use during execution.

Returns:

A string representing the outcome of the execution.

virtual void cancel_state() override

Cancels the current state execution.

This method sets the canceled flag to true and logs the action.

const StateMap &get_states() const noexcept

Returns the map of states managed by this concurrence state.

Returns:

A map of state names to states.

const OutcomeMap &get_outcome_map() const noexcept

Returns the outcome map for this concurrence state.

Returns:

A map of outcome names to their requirements.

const std::string &get_default_outcome() const noexcept

Returns the default outcome for this concurrence state.

Returns:

The default outcome as a string.

virtual std::string to_string() const override

Converts the state to a string representation.

Returns:

A string representation of the state.

Protected Attributes

const StateMap states

The states to run concurrently (name -> state)

const std::string default_outcome

Default outcome.

OutcomeMap outcome_map

Specifies which combination of state outputs should produce a given overall output

StateOutcomeMap intermediate_outcome_map

Stores the intermediate outcomes of the concurrent states.

Outcomes possible_outcomes

The set of possible outcomes.

ParameterMappingsMap parameter_mappings

Per-child parameter mappings applied during configure()