MotorControlModuleSDFM_TMS3.../Projects/EFC_Communication/UMLibrary/schematic/FunctorLogic.hpp
2024-06-07 11:12:56 +03:00

50 lines
1.3 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*
* FunctorLogic.hpp
*
* Created on: 20 мая 2020 г.
* Author: LeonidTitov
*/
#ifndef UMLIBRARY_SCHEMATIC_FUNCTORLOGIC_HPP_
#define UMLIBRARY_SCHEMATIC_FUNCTORLOGIC_HPP_
#include "../systemic/IFunctor.hh"
#include <utility>
#include <functional>
namespace systemic { namespace detail {
template<typename Logic, typename ReturnType, typename ... Args>
class FunctorLogic : public IFunctor<ReturnType, Args...> {
public:
FunctorLogic(Logic logic, IFunctor<ReturnType, Args...> & lhs, IFunctor<ReturnType, Args...> & rhs );
ReturnType operator()( Args ... args );
private:
Logic logic;
IFunctor<ReturnType, Args...> & lhs;
IFunctor<ReturnType, Args...> & rhs;
};
template<typename Logic, typename ReturnType, typename ... Args>
inline systemic::detail::FunctorLogic<Logic, ReturnType, Args...>::FunctorLogic(
Logic logic, IFunctor<ReturnType, Args...> & lhs,
IFunctor<ReturnType, Args...> & rhs) : logic(logic), lhs(lhs), rhs(rhs) {}
template<typename Logic, typename ReturnType, typename ... Args>
inline ReturnType systemic::detail::FunctorLogic<Logic, ReturnType, Args...>::operator()(
Args ... args ) {
return logic( lhs( args... ), rhs( args... ) );
}
}
}
#endif /* UMLIBRARY_SCHEMATIC_FUNCTORLOGIC_HPP_ */