17#ifndef YASMIN__CONCURRENCE_HPP
18#define YASMIN__CONCURRENCE_HPP
52 typedef std::map<std::string, StateOutcomeMap>
OutcomeMap;
56 const std::map<std::string, std::shared_ptr<State>>
states;
80 static std::set<std::string>
120 const std::map<std::string, std::shared_ptr<State>> &
get_states()
const;
139 std::string name =
"Concurrence [";
141 for (
auto it =
states.begin(); it !=
states.end(); ++it) {
142 name += it->first +
" (" + it->second->to_string() +
")";
145 if (std::next(it) !=
states.end()) {
std::map< std::string, std::shared_ptr< std::string > > intermediate_outcome_map
Stores the intermediate outcomes of the concurrent states.
Definition concurrence.hpp:66
const std::string & get_default_outcome() const
Returns the default outcome for this concurrence state.
Definition concurrence.cpp:170
std::string execute(std::shared_ptr< blackboard::Blackboard > blackboard) override
Executes the state's specific logic.
Definition concurrence.cpp:84
std::set< std::string > possible_outcomes
The set of possible outcomes.
Definition concurrence.hpp:69
void cancel_state() override
Cancels the current state execution.
Definition concurrence.cpp:154
static std::set< std::string > 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.
Definition concurrence.cpp:175
const OutcomeMap & get_outcome_map() const
Returns the outcome map for this concurrence state.
Definition concurrence.cpp:166
const std::map< std::string, std::shared_ptr< State > > & get_states() const
Returns the map of states managed by this concurrence state.
Definition concurrence.cpp:162
std::map< std::string, StateOutcomeMap > OutcomeMap
Definition concurrence.hpp:52
std::string to_string() override
Converts the state to a string representation.
Definition concurrence.hpp:138
std::mutex intermediate_outcome_mutex
Mutex for intermediate outcome map.
Definition concurrence.hpp:73
std::map< std::string, std::string > StateOutcomeMap
Definition concurrence.hpp:51
Concurrence(const std::map< std::string, std::shared_ptr< State > > &states, const std::string &default_outcome, const OutcomeMap &outcome_map)
Constructs a State with a set of possible outcomes.
Definition concurrence.cpp:28
const std::string default_outcome
Default outcome.
Definition concurrence.hpp:59
OutcomeMap outcome_map
Definition concurrence.hpp:63
const std::map< std::string, std::shared_ptr< State > > states
The states to run concurrently (name -> state)
Definition concurrence.hpp:56
State(const std::set< std::string > &outcomes)
Constructs a State with a set of possible outcomes.
Definition state.cpp:27
Definition blackboard.hpp:30
Definition blackboard.hpp:29