SMACC2
Loading...
Searching...
No Matches
smacc_client_behavior_base.hpp
Go to the documentation of this file.
1// Copyright 2025 Robosoft Inc.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15/*****************************************************************************************************************
16 *
17 * Authors: Pablo Inigo Blasco, Brett Aldrich
18 *
19 ******************************************************************************************************************/
20
21#pragma once
22
23#include <string>
24
25#include <smacc2/common.hpp>
26
27namespace smacc2
28{
29
31{
32public:
34
35 virtual ~ISmaccClientBehavior();
36
38
39 std::string getName() const;
40
41 template <typename SmaccClientType>
42 void requiresClient(SmaccClientType *& storage);
43
44 template <typename SmaccComponentType>
46 SmaccComponentType *& storage,
48
49 // named variant: resolves the component instance created with this name
50 // (e.g. createComponent<CpActionClient<Spin>>("/spin")), for clients holding
51 // several components of the same type
52 template <typename SmaccComponentType>
54 std::string name, SmaccComponentType *& storage,
56
57 virtual void onEntry() {}
58
59 virtual void onExit() {}
60
61 //internal visibility (private + friend)
62 virtual void executeOnEntry();
63
64 //internal visibility (private + friend)
65 virtual void executeOnExit();
66
67protected:
68 virtual void runtimeConfigure();
69
70 template <typename EventType>
71 void postEvent(const EventType & ev);
72
73 template <typename EventType>
74 void postEvent();
75
77
78 virtual void dispose();
79
80 virtual rclcpp::Node::SharedPtr getNode() const;
81
82 virtual rclcpp::Logger getLogger() const;
83
84private:
85 template <typename TOrthogonal, typename TSourceObject>
87
88 // a reference to the owner state machine
90
91 // a reference to the state where the client behavior is being executed
94
95 friend class ISmaccState;
96 friend class ISmaccOrthogonal;
98};
99} // namespace smacc2
smacc2::ISmaccOrthogonal * currentOrthogonal
virtual rclcpp::Logger getLogger() const
virtual rclcpp::Node::SharedPtr getNode() const
void requiresClient(SmaccClientType *&storage)
void requiresComponent(SmaccComponentType *&storage, ComponentRequirement requirementType=ComponentRequirement::SOFT)
ComponentRequirement
Definition common.hpp:74