HOPS
HOPS class reference
MHO_BinaryOperator.hh
Go to the documentation of this file.
1 #ifndef MHO_BinaryOperator_HH__
2 #define MHO_BinaryOperator_HH__
3 
4 #include "MHO_ArgumentCarrier.hh"
5 
6 #include <tuple>
7 
8 namespace hops
9 {
10 
20 template< class XArgType1, class XArgType2 = XArgType1, class XArgType3 = XArgType2 >
21 class MHO_BinaryOperator: public MHO_ArgumentCarrier< const XArgType1*, const XArgType2*, XArgType3* >
22 {
23  public:
25  virtual ~MHO_BinaryOperator(){};
26 
27  void SetArgs(const XArgType1* in1, const XArgType2* in2, XArgType3* out)
28  {
29  this->fArgs = std::make_tuple(in1, in2, out);
30  }
31 
32  virtual bool Initialize() override
33  {
34  return this->Apply(
35  [this](const XArgType1* in1, const XArgType2* in2, XArgType3* out) { return InitializeImpl(in1, in2, out); });
36  }
37 
38  virtual bool Execute() override
39  {
40  return this->Apply(
41  [this](const XArgType1* in1, const XArgType2* in2, XArgType3* out) { return ExecuteImpl(in1, in2, out); });
42  }
43 
44  protected:
45  virtual bool InitializeImpl(const XArgType1* /*in1*/, const XArgType2* /*in2*/, XArgType3* /*out*/) { return true; }
46 
47  virtual bool ExecuteImpl(const XArgType1* in1, const XArgType2* in2, XArgType3* out) = 0;
48 };
49 
50 } // namespace hops
51 
52 #endif
Variadic base that stores an operator's typed arguments (pointers expected) in a tuple and exposes a ...
Definition: MHO_ArgumentCarrier.hh:22
std::tuple< Args... > fArgs
Definition: MHO_ArgumentCarrier.hh:24
auto Apply(Func &&func) -> decltype(mho_tuple_apply(std::forward< Func >(func), fArgs))
Definition: MHO_ArgumentCarrier.hh:26
An operator that takes two array types as input (XArgType1 and XArgType2) and writes to a single outp...
Definition: MHO_BinaryOperator.hh:22
virtual bool ExecuteImpl(const XArgType1 *in1, const XArgType2 *in2, XArgType3 *out)=0
virtual bool InitializeImpl(const XArgType1 *, const XArgType2 *, XArgType3 *)
Definition: MHO_BinaryOperator.hh:45
virtual bool Initialize() override
Function Initialize.
Definition: MHO_BinaryOperator.hh:32
void SetArgs(const XArgType1 *in1, const XArgType2 *in2, XArgType3 *out)
Definition: MHO_BinaryOperator.hh:27
MHO_BinaryOperator()
Definition: MHO_BinaryOperator.hh:24
virtual ~MHO_BinaryOperator()
Definition: MHO_BinaryOperator.hh:25
virtual bool Execute() override
Function Execute.
Definition: MHO_BinaryOperator.hh:38
Definition: MHO_AdhocFlagging.hh:18