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 <functional>
20#include <memory>
21#include <set>
22#include <string>
23
25#include "yasmin/state.hpp"
26
27namespace yasmin {
28
37class CbState : public State {
38
39private:
41 std::function<std::string(std::shared_ptr<blackboard::Blackboard>)> callback;
42
43public:
53 CbState(const std::set<std::string> &outcomes,
54 std::function<std::string(std::shared_ptr<blackboard::Blackboard>)>
55 callback);
56
70 std::string
71 execute(std::shared_ptr<blackboard::Blackboard> blackboard) override;
72};
73
74} // namespace yasmin
75
76#endif // YASMIN__CB_STATE_HPP
std::string execute(std::shared_ptr< blackboard::Blackboard > blackboard) override
Executes the callback function.
Definition cb_state.cpp:31
CbState(const std::set< std::string > &outcomes, std::function< std::string(std::shared_ptr< blackboard::Blackboard >)> callback)
Constructs a CbState object.
Definition cb_state.cpp:20
std::function< std::string(std::shared_ptr< blackboard::Blackboard >)> callback
Pointer to the callback function to be executed.
Definition cb_state.hpp:41
State(const std::set< std::string > &outcomes)
Constructs a State with a set of possible outcomes.
Definition state.cpp:27
std::set< std::string > outcomes
The possible outcomes of this state.
Definition state.hpp:57
Definition blackboard.hpp:30
Definition blackboard.hpp:29