Files
pip/libs/main/state_machine/pistatemachine_base.h
peri4 cd7e053fc5 version 4.2.0
move toStdFunction() to pibase.h
refactor PIParseHelper, now it much more abstract and useful
fix PIIODevice::createFromFullPath() when whitespaces at start or end are presence
PIStreamPacker add events for start and end packet receive
PIClientServer::ClientBase add virtual methods for start and end packet receive. also one can enable diagnostics with enableDiagnostics() method
PICout now call flush() on each end of output
add PIString::entries(const PIString & str)
2024-10-15 12:02:18 +03:00

68 lines
1.8 KiB
C++

/*! \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 <http://www.gnu.org/licenses/>.
*/
#ifndef pistatemachine_base_H
#define pistatemachine_base_H
#include "piconstchars.h"
namespace PIStateMachineHelpers {
class FunctionBase {
public:
virtual ~FunctionBase() {}
virtual uint formatHash() = 0;
};
template<typename... Args>
class Function: public FunctionBase {
public:
uint formatHash() override {
static uint ret = PIConstChars(typeid(std::function<void(Args...)>).name()).hash();
return ret;
}
std::function<bool(Args...)> func;
};
template<typename Ret, typename... Args>
FunctionBase * makeFunction(std::function<Ret(Args...)> func) {
auto * ret = new Function<Args...>();
ret->func = func;
return ret;
}
} // namespace PIStateMachineHelpers
class PITransitionBase;
class PITransitionTimeout;
class PIStateBase;
class PIStateLambda;
class PIStateFinal;
class PIStateMachine;
#endif