16#ifndef YASMIN__STATE_HPP_
17#define YASMIN__STATE_HPP_
22#include <unordered_map>
142 std::
string operator()(
Blackboard::SharedPtr blackboard);
202 const std::
string &description);
216 const std::unordered_map<std::
string, std::
string> &
237 const std::
string &description);
246 template <typename T>
248 const std::
string &description, T default_value) {
271 const std::string &description);
303 const std::string &description);
312 template <
typename T>
314 const std::string &description, T default_value) {
332 template <
typename T>
343 template <
typename T>
362 const std::string &source_parameter_name,
363 const std::string &target_parameter_name);
A thread-safe storage for key-value pairs of varying types.
Definition blackboard.hpp:67
std::shared_ptr< Blackboard > SharedPtr
Shared pointer type for Blackboard.
Definition blackboard.hpp:100
Represents a state in a state machine.
Definition state.hpp:49
const std::vector< BlackboardKeyInfo > & get_input_keys() const
Gets the input keys metadata.
Definition state.cpp:233
void set_parameter(const std::string ¶meter_name, T value)
Sets a parameter in the state-local parameter storage.
Definition state.hpp:344
bool is_running() const noexcept
Checks if the state is currently running.
Definition state.cpp:85
StateStatus get_status() const
Gets the current status of the state.
Definition state.cpp:79
const std::vector< BlackboardKeyInfo > & get_parameters() const
Gets the declared parameter metadata.
Definition state.cpp:290
const std::unordered_map< std::string, std::string > & get_outcome_descriptions() const
Gets all outcome descriptions.
Definition state.cpp:194
Outcomes outcomes
The possible outcomes of this state.
Definition state.hpp:53
virtual void configure()
Configures the state before execution.
Definition state.hpp:165
bool is_parameter_declared(const std::string ¶meter_name) const
Checks whether a parameter was declared in the state metadata.
Definition state.cpp:274
bool is_idle() const noexcept
Checks if the state is idle.
Definition state.cpp:81
void declare_parameter(const std::string ¶meter_name, const std::string &description, T default_value)
Declares a parameter with a name, description, and default value.
Definition state.hpp:313
State(const Outcomes &outcomes)
Shared pointer type for State.
Definition state.cpp:64
virtual std::string execute(Blackboard::SharedPtr blackboard)
Executes the state's specific logic.
Definition state.hpp:153
void add_input_key(const BlackboardKeyInfo &key_info)
Adds an input key to the state's metadata.
Definition state.cpp:198
std::atomic< StateStatus > status
Current status of the state.
Definition state.hpp:66
bool is_canceled() const noexcept
Checks if the state has been canceled.
Definition state.cpp:89
const StateMetadata & get_metadata() const
Gets the complete state metadata.
Definition state.cpp:294
void set_status(StateStatus new_status)
Sets the current status of the state.
Definition state.cpp:75
bool is_completed() const noexcept
Checks if the state has completed execution.
Definition state.cpp:93
StateMetadata & get_metadata_ref() const
Gets a mutable reference to this state's metadata.
Definition state.cpp:54
void copy_parameter_from(const State &source_state, const std::string &source_parameter_name, const std::string &target_parameter_name)
Copies a parameter value from another state.
Definition state.cpp:282
void add_output_key(const BlackboardKeyInfo &key_info)
Adds an output key to the state's metadata.
Definition state.cpp:213
const std::string & get_outcome_description(const std::string &outcome) const
Gets the human-readable description for an outcome.
Definition state.cpp:175
void set_description(const std::string &description)
Sets the description for this state.
Definition state.cpp:156
const std::vector< BlackboardKeyInfo > & get_output_keys() const
Gets the output keys metadata.
Definition state.cpp:237
const std::string & get_description() const
Gets the description of this state.
Definition state.cpp:160
virtual std::string to_string() const
Converts the state to a string representation.
Definition state.cpp:298
Outcomes const & get_outcomes() const noexcept
Gets the set of possible outcomes for this state.
Definition state.cpp:154
bool has_parameter(const std::string ¶meter_name) const
Checks if a parameter exists in the state-local parameter storage.
Definition state.cpp:270
T get_parameter(const std::string ¶meter_name) const
Gets a parameter from the state-local parameter storage.
Definition state.hpp:333
virtual void cancel_state()
Cancels the current state execution.
Definition state.hpp:172
void declare_parameter(const BlackboardKeyInfo ¶meter_info)
Declares a parameter in the state metadata.
Definition state.cpp:241
void set_outcome_description(const std::string &outcome, const std::string &description)
Sets a human-readable description for an outcome.
Definition state.cpp:164
virtual ~State()
Virtual destructor.
Definition state.cpp:70
Blackboard::SharedPtr get_parameters_blackboard() const
Gets the private parameter blackboard of this state.
Definition state.cpp:59
#define YASMIN_LOG_INFO(text,...)
Definition logs.hpp:169
Definition blackboard.hpp:34
StringSet Outcomes
Set of possible outcomes for states.
Definition types.hpp:77
StateStatus
Enumeration representing the current status of a state.
Definition state.hpp:34
@ RUNNING
State is currently executing.
Definition state.hpp:36
@ COMPLETED
State execution has completed successfully.
Definition state.hpp:38
@ IDLE
State is idle and ready to execute.
Definition state.hpp:35
@ CANCELED
State execution has been canceled.
Definition state.hpp:37
Information about a blackboard key including name and optional default value.
Definition blackboard_key_info.hpp:35
#define YASMIN_PTR_ALIASES(ClassName)
Macro to define all pointer aliases for a class.
Definition types.hpp:52