17#ifndef YASMIN__CONCURRENCE_HPP
18#define YASMIN__CONCURRENCE_HPP
51 typedef std::map<std::shared_ptr<State>, std::string>
StateMap;
56 const std::set<std::shared_ptr<State>>
states;
66 std::map<std::shared_ptr<State>, std::shared_ptr<std::string>>
86 static std::set<std::string>
125 std::string name =
typeid(*this).name();
131 abi::__cxa_demangle(name.c_str(),
nullptr,
nullptr, &status);
140 for (
auto it =
states.begin(); it !=
states.end(); ++it) {
141 name += (*it)->to_string();
144 if (std::next(it) !=
states.end()) {
std::string execute(std::shared_ptr< blackboard::Blackboard > blackboard) override
Executes the state's specific logic.
Definition concurrence.cpp:67
std::set< std::string > possible_outcomes
The set of possible outcomes.
Definition concurrence.hpp:70
void cancel_state() override
Cancels the current state execution.
Definition concurrence.cpp:135
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:143
Concurrence(std::set< std::shared_ptr< State > > states, std::string default_outcome, OutcomeMap outcome_map)
Constructs a State with a set of possible outcomes.
Definition concurrence.cpp:28
std::atomic_bool canceled
Indicates if the state has been canceled.
Definition concurrence.hpp:74
std::string to_string() override
Converts the state to a string representation.
Definition concurrence.hpp:124
std::mutex intermediate_outcome_mutex
Mutex for intermediate outcome map.
Definition concurrence.hpp:79
std::atomic_bool running
Indicates if the state is currently running.
Definition concurrence.hpp:76
std::map< std::string, StateMap > OutcomeMap
Definition concurrence.hpp:52
std::map< std::shared_ptr< State >, std::string > StateMap
Definition concurrence.hpp:51
const std::set< std::shared_ptr< State > > states
The states to run concurrently.
Definition concurrence.hpp:56
const std::string default_outcome
Default outcome.
Definition concurrence.hpp:59
OutcomeMap outcome_map
Definition concurrence.hpp:63
std::map< std::shared_ptr< State >, std::shared_ptr< std::string > > intermediate_outcome_map
Stores the intermedaite outcomes of the concurrent states.
Definition concurrence.hpp:67
State(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