SMACC2
smacc_orthogonal.hpp
Go to the documentation of this file.
1// Copyright 2021 RobosoftAI 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#include <smacc2/common.hpp>
23#include <utility>
24
25namespace smacc2
26{
28{
29public:
31
33
34 void addClientBehavior(std::shared_ptr<smacc2::ISmaccClientBehavior> clientBehavior);
35
36 void runtimeConfigure();
37
38 void onEntry();
39
40 void onExit();
41
42 virtual std::string getName() const;
43
44 template <typename SmaccComponentType>
45 void requiresComponent(SmaccComponentType *& storage);
46
47 template <typename SmaccClientType>
48 bool requiresClient(SmaccClientType *& storage);
49
50 inline const std::vector<std::shared_ptr<smacc2::ISmaccClient>> & getClients();
51
52 inline const std::vector<std::shared_ptr<smacc2::ISmaccClientBehavior>> & getClientBehaviors()
53 const;
54
55 template <typename T>
56 void setGlobalSMData(std::string name, T value);
57
58 template <typename T>
59 bool getGlobalSMData(std::string name, T & ret);
60
61 template <typename TClientBehavior>
62 TClientBehavior * getClientBehavior();
63
64 rclcpp::Node::SharedPtr getNode();
65 inline rclcpp::Logger getLogger() { return getNode()->get_logger(); }
66
67protected:
68 virtual void onInitialize();
69
70 void initializeClients();
71
72 template <typename TOrthogonal, typename TClient>
73 void assignClientToOrthogonal(TClient * client);
74
75 std::vector<std::shared_ptr<smacc2::ISmaccClient>> clients_;
76
77private:
79
80 std::vector<std::shared_ptr<smacc2::ISmaccClientBehavior>> clientBehaviors_;
81 friend class ISmaccStateMachine;
82};
83
84} // namespace smacc2
std::vector< std::shared_ptr< smacc2::ISmaccClientBehavior > > clientBehaviors_
ISmaccStateMachine * getStateMachine()
void setStateMachine(ISmaccStateMachine *value)
Definition: orthogonal.cpp:32
const std::vector< std::shared_ptr< smacc2::ISmaccClientBehavior > > & getClientBehaviors() const
TClientBehavior * getClientBehavior()
void setGlobalSMData(std::string name, T value)
bool getGlobalSMData(std::string name, T &ret)
virtual void onInitialize()
Definition: orthogonal.cpp:68
void requiresComponent(SmaccComponentType *&storage)
void addClientBehavior(std::shared_ptr< smacc2::ISmaccClientBehavior > clientBehavior)
Definition: orthogonal.cpp:49
std::vector< std::shared_ptr< smacc2::ISmaccClient > > clients_
ISmaccStateMachine * stateMachine_
bool requiresClient(SmaccClientType *&storage)
void assignClientToOrthogonal(TClient *client)
virtual std::string getName() const
Definition: orthogonal.cpp:70
rclcpp::Node::SharedPtr getNode()
Definition: orthogonal.cpp:47
const std::vector< std::shared_ptr< smacc2::ISmaccClient > > & getClients()