50 lines
1.3 KiB
C++
50 lines
1.3 KiB
C++
/*
|
|
* 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_ */
|