SMACC2
Loading...
Searching...
No Matches
smacc_asynchronous_client_behavior_impl.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
24
25namespace smacc2
26{
27template <typename TOrthogonal, typename TSourceObject>
32
33template <typename TOrthogonal, typename TSourceObject>
35{
37 {
38 RCLCPP_WARN(
39 getLogger(),
40 "SmaccAsyncClientBehavior already has event posting functions assigned. Skipping "
41 "re-assignment. This could be a problem if you are using the same behavior in multiple "
42 "states. This may be related with the deprecation of onOrthogonalAllocation in favor of "
43 "onStateOrthogonalAllocation.");
44
45 return;
46 }
47
48 postFinishEventFn_ = [this]
49 {
50 this->onFinished_();
52 };
53
54 postSuccessEventFn_ = [this]
55 {
56 this->onSuccess_();
58 };
59
60 postFailureEventFn_ = [this]
61 {
62 this->onFailure_();
64 };
65}
66
67template <typename TCallbackMethod, typename T>
68boost::signals2::connection SmaccAsyncClientBehavior::onSuccess(
69 TCallbackMethod callback, T * object)
70{
71 return this->getStateMachine()->createSignalConnection(onSuccess_, callback, object);
72}
73
74template <typename TCallbackMethod, typename T>
75boost::signals2::connection SmaccAsyncClientBehavior::onFinished(
76 TCallbackMethod callback, T * object)
77{
78 return this->getStateMachine()->createSignalConnection(onFinished_, callback, object);
79}
80
81template <typename TCallbackMethod, typename T>
82boost::signals2::connection SmaccAsyncClientBehavior::onFailure(
83 TCallbackMethod callback, T * object)
84{
85 return this->getStateMachine()->createSignalConnection(onFailure_, callback, object);
86}
87} // namespace smacc2
virtual rclcpp::Logger getLogger() const
boost::signals2::connection createSignalConnection(TSmaccSignal &signal, TMemberFunctionPrototype callback, TSmaccObjectType *object)
boost::signals2::connection onFinished(TCallback callback, T *object)
boost::signals2::connection onSuccess(TCallback callback, T *object)
boost::signals2::connection onFailure(TCallback callback, T *object)