SMACC2
Loading...
Searching...
No Matches
smacc_client_behavior_base.cpp
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
22
23namespace smacc2
24{
29
31
33{
34 RCLCPP_WARN_STREAM(getLogger(), "[" << getName() << "]" << " Client behavior deallocated");
35}
36
37std::string ISmaccClientBehavior::getName() const { return demangleSymbol(typeid(*this).name()); }
38
40{
41 auto * state = stateMachine_ != nullptr ? stateMachine_->getCurrentState() : nullptr;
42 return state != nullptr ? state->getClassName() : std::string();
43}
44
46{
47 return currentOrthogonal != nullptr ? currentOrthogonal->getName() : std::string();
48}
49
50rclcpp::Node::SharedPtr ISmaccClientBehavior::getNode() const
51{
52 // Null until the orthogonal attaches the behavior; getLogger() falls back to the SMACC logger then.
53 if (this->stateMachine_ == nullptr)
54 {
55 return nullptr;
56 }
57 return this->stateMachine_->getNode();
58}
59
60rclcpp::Logger ISmaccClientBehavior::getLogger() const
61{
62 auto nh = this->getNode();
63 if (nh != nullptr)
64 {
65 return nh->get_logger();
66 }
67 else
68 {
69 return rclcpp::get_logger("SMACC");
70 }
71}
72
74{
75 RCLCPP_DEBUG(
76 getLogger(), "[%s] Default empty SmaccClientBehavior runtimeConfigure()",
77 this->getName().c_str());
78}
79
81{
82 RCLCPP_DEBUG(
83 getLogger(), "[%s] Default empty SmaccClientBehavior onEntry()", this->getName().c_str());
84 this->onEntry();
85}
86
88{
89 RCLCPP_DEBUG(
90 getLogger(), "[%s] Default empty SmaccClientBehavior onExit()", this->getName().c_str());
91 this->onExit();
92}
93
95
96} // namespace smacc2
smacc2::ISmaccOrthogonal * currentOrthogonal
virtual rclcpp::Logger getLogger() const
void postInitializationFailureEvent(const std::string &what)
virtual rclcpp::Node::SharedPtr getNode() const
std::function< void(const std::string &)> postInitializationFailureEventFn_
virtual std::string getName() const
rclcpp::Node::SharedPtr getNode()
virtual std::string getClassName()
std::string demangleSymbol()