C++ YASMIN (Yet Another State MachINe)
Loading...
Searching...
No Matches
cb_state.hpp
Go to the documentation of this file.
1// Copyright (C) 2023 Miguel Ángel González Santamarta
2//
3// This program is free software: you can redistribute it and/or modify
4// it under the terms of the GNU General Public License as published by
5// the Free Software Foundation, either version 3 of the License, or
6// (at your option) any later version.
7//
8// This program is distributed in the hope that it will be useful,
9// but WITHOUT ANY WARRANTY; without even the implied warranty of
10// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11// GNU General Public License for more details.
12//
13// You should have received a copy of the GNU General Public License
14// along with this program. If not, see <https://www.gnu.org/licenses/>.
15
16#ifndef YASMIN__CB_STATE_HPP
17#define YASMIN__CB_STATE_HPP
18
19#include <memory>
20#include <set>
21#include <string>
22
24#include "yasmin/state.hpp"
25
26namespace yasmin {
27
36class CbState : public State {
37
38private:
40 std::string (*callback)(std::shared_ptr<blackboard::Blackboard> blackboard);
41
42public:
52 CbState(std::set<std::string> outcomes,
53 std::string (*callback)(
54 std::shared_ptr<blackboard::Blackboard> blackboard));
55
69 std::string
70 execute(std::shared_ptr<blackboard::Blackboard> blackboard) override;
71};
72
73} // namespace yasmin
74
75#endif // YASMIN__CB_STATE_HPP
Represents a state that executes a callback function.
Definition cb_state.hpp:36
std::string execute(std::shared_ptr< blackboard::Blackboard > blackboard) override
Executes the callback function.
Definition cb_state.cpp:30
CbState(std::set< std::string > outcomes, std::string(*callback)(std::shared_ptr< blackboard::Blackboard > blackboard))
Constructs a CbState object.
Definition cb_state.cpp:20
std::string(* callback)(std::shared_ptr< blackboard::Blackboard > blackboard)
Pointer to the callback function to be executed.
Definition cb_state.hpp:40
Represents a state in a state machine.
Definition state.hpp:42
std::set< std::string > outcomes
The possible outcomes of this state.
Definition state.hpp:46
Definition blackboard.hpp:29