Class CbState

Inheritance Relationships

Base Type

Class Documentation

class CbState : public yasmin::State

Represents a state that executes a callback function.

The CbState class inherits from the State class and is designed to execute a user-defined callback function, utilizing a shared pointer to a Blackboard object to obtain necessary data.

Public Functions

CbState(std::set<std::string> outcomes, std::string (*callback)(std::shared_ptr<blackboard::Blackboard> blackboard))

Constructs a CbState object.

Parameters:
  • outcomes – A set of possible outcomes for this state.

  • callback – A function pointer to the callback function that will be executed when this state is activated.

Throws:

std::invalid_argument – If the outcomes set is empty.

virtual std::string execute(std::shared_ptr<blackboard::Blackboard> blackboard) override

Executes the callback function.

This function is called to execute the callback and retrieve the result. It may use the provided Blackboard for additional data.

Parameters:

blackboard – A shared pointer to the Blackboard object used during execution.

Throws:

std::runtime_error – If the callback execution fails.

Returns:

The result of the callback function execution as a string.