/*! \file pistatemachine_base.h * \ingroup StateMachine * \~\brief * \~english Some template helpers for PIStateMachine * \~russian Несколько шаблонов для PIStateMachine */ /* PIP - Platform Independent Primitives Some template helpers for PIStateMachine Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@yandex.ru This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this program. If not, see . */ #ifndef pistatemachine_base_H #define pistatemachine_base_H #include "piconstchars.h" namespace PIStateMachineHelpers { template struct FunctionType { using Type = void; }; template struct FunctionType { using Type = std::function; }; template typename FunctionType::Type toStdFunction(L const & func) { return func; } class FunctionBase { public: virtual ~FunctionBase() {} virtual uint formatHash() = 0; }; template class Function: public FunctionBase { public: uint formatHash() override { static uint ret = PIConstChars(typeid(std::function).name()).hash(); return ret; } std::function func; }; template FunctionBase * makeFunction(std::function func) { auto * ret = new Function(); ret->func = func; return ret; } } // namespace PIStateMachineHelpers class PITransitionBase; class PITransitionTimeout; class PIStateBase; class PIStateLambda; class PIStateFinal; class PIStateMachine; #endif