.. _program_listing_file_include_smacc2_smacc_transition.hpp: Program Listing for File smacc_transition.hpp ============================================= |exhale_lsh| :ref:`Return to documentation for file ` (``include/smacc2/smacc_transition.hpp``) .. |exhale_lsh| unicode:: U+021B0 .. UPWARDS ARROW WITH TIP LEFTWARDS .. code-block:: cpp // Copyright 2021 RobosoftAI Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. /***************************************************************************************************************** * * Authors: Pablo Inigo Blasco, Brett Aldrich * ******************************************************************************************************************/ #pragma once #include #include namespace smacc2 { template < class Event, class Destination, typename Tag, class TransitionContext, void (TransitionContext::*pTransitionAction)(const Event &)> class Transition { public: typedef Tag TRANSITION_TAG; private: template struct reactions { static boost::statechart::result react_without_action(State & stt) { RCLCPP_DEBUG(stt.getLogger(), "[Smacc Transition] REACT WITHOUT ACTION"); typedef smacc2::Transition Transtype; TRANSITION_TAG mock; specificNamedOnExit(stt, mock); stt.template notifyTransition(); return stt.template transit(); } static boost::statechart::result react_with_action(State & stt, const Event & evt) { RCLCPP_DEBUG(stt.getLogger(), "[Smacc Transition] REACT WITH ACTION AND EVENT"); typedef smacc2::Transition Transtype; TRANSITION_TAG mock; specificNamedOnExit(stt, mock); stt.template notifyTransition(); return stt.template transit(pTransitionAction, evt); } }; public: // The following declarations should be private. // They are only public because many compilers lack template friends. template static boost::statechart::detail::reaction_result react( State & stt, const EventBase & evt, const IdType & eventType) { typedef boost::statechart::detail::reaction_dispatcher< reactions, State, EventBase, Event, TransitionContext, IdType> dispatcher; return dispatcher::react(stt, evt, eventType); } }; } // namespace smacc2