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{
27
28template <typename TOrthogonal, typename TSourceObject>
30{
32 {
33 RCLCPP_WARN(
34 getLogger(),
35 "SmaccAsyncClientBehavior already has event posting functions assigned. Skipping "
36 "re-assignment. This could be a problem if you are using the same behavior in multiple "
37 "states. This may be related with the deprecation of onStateOrthogonalAllocation in favor of "
38 "onStateOrthogonalAllocation.");
39
40 return;
41 }
42
43 postFinishEventFn_ = [this]
44 {
45 this->onFinished_();
47 };
48
49 postSuccessEventFn_ = [this]
50 {
51 this->onSuccess_();
53 };
54
55 postFailureEventFn_ = [this]
56 {
57 this->onFailure_();
59 };
60}
61
62template <typename TCallbackMethod, typename T>
63boost::signals2::connection SmaccAsyncClientBehavior::onSuccess(
64 TCallbackMethod callback, T * object)
65{
66 return this->getStateMachine()->createSignalConnection(onSuccess_, callback, object);
67}
68
69template <typename TCallbackMethod, typename T>
70boost::signals2::connection SmaccAsyncClientBehavior::onFinished(
71 TCallbackMethod callback, T * object)
72{
73 return this->getStateMachine()->createSignalConnection(onFinished_, callback, object);
74}
75
76template <typename TCallbackMethod, typename T>
77boost::signals2::connection SmaccAsyncClientBehavior::onFailure(
78 TCallbackMethod callback, T * object)
79{
80 return this->getStateMachine()->createSignalConnection(onFailure_, callback, object);
81}
82} // 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)