MEL
Microthread & Execution library
FunctorImpl.h
1 namespace mel
2 {
3  namespace mpl
4  {
9  #if VARIABLE_NUM_ARGS == VARIABLE_MAX_ARGS
11  template < class Fun1, class Fun2 >
12  class Chainer_Base
13  {
14  public:
15  Chainer_Base( const Fun1& f1, const Fun2& f2 ):mF1( f1 ), mF2( f2 ){};
16  template <class F>
17  bool operator == ( const F& ob2 ) const
18  {
19  return equality( Int2Type< Conversion<F, Chainer_Base<Fun1,Fun2> >::exists >(),ob2 );
20  }
21  private:
22  template <class F>
23  bool equality( Int2Type<false>,const F&) const
24  {
25  return false;
26  }
27  bool equality( Int2Type<true >,const Chainer_Base<Fun1,Fun2>& ob2) const
28  {
29  //return mF1 == ob2.mF1 && mF2 == ob2.mF2;
30  return mel::mpl::equal<true>( mF1, ob2.mF1 ) &&::mel::mpl::equal<true>( mF2,ob2.mF2 );
31  }
32 
33 
34  protected:
35  Fun1 mF1;
36  Fun2 mF2;
37  };
39  template < class Fun1, class Fun2,VARIABLE_ARGS > class Chainer : public Chainer_Base<Fun1,Fun2>
40  {
41  public:
42  Chainer( const Fun1& f1, const Fun2& f2 ): Chainer_Base<Fun1,Fun2>(f1,f2)
43  {
44  }
45  //TODO �que devuelvo?
46  void operator()( VARIABLE_ARGS_IMPL )
47  {
48  Chainer_Base<Fun1,Fun2>::mF1( VARIABLE_ARGS_USE );
49  Chainer_Base<Fun1,Fun2>::mF2( VARIABLE_ARGS_USE );
50  }
51  };
53  //specialization for void arguments
54  template <class Fun1, class Fun2>
55  class Chainer<Fun1,Fun2> : public Chainer_Base<Fun1,Fun2>
56  {
57  public:
58  Chainer( const Fun1& f1, const Fun2& f2 ): Chainer_Base<Fun1,Fun2>(f1,f2)
59  {
60  }
61  void operator()( )
62  {
63  Chainer_Base<Fun1,Fun2>::mF1( );
64  Chainer_Base<Fun1,Fun2>::mF2( );
65  }
66  };
68  template <VARIABLE_ARGS_NODEFAULT,class F1, class F2>
69  Chainer<F1,F2,VARIABLE_ARGS_DECL> chain( F1 f1, F2 f2 )
70  {
71  return Chainer<F1,F2,VARIABLE_ARGS_DECL>(f1,f2);
72  }
73  #else
74 
75  template < class Fun1, class Fun2,VARIABLE_ARGS >
76  class Chainer<Fun1,Fun2,VARIABLE_ARGS_DECL,void> : public Chainer_Base<Fun1,Fun2>
77  {
78  public:
79  Chainer( const Fun1& f1, const Fun2& f2 ): Chainer_Base<Fun1,Fun2>(f1,f2)
80  {
81  }
82  //TODO �que devuelvo?
83  void operator()( VARIABLE_ARGS_IMPL )
84  {
85  Chainer_Base<Fun1,Fun2>::mF1( VARIABLE_ARGS_USE );
86  Chainer_Base<Fun1,Fun2>::mF2( VARIABLE_ARGS_USE );
87  }
88  };
89  template <VARIABLE_ARGS,class F1, class F2>
90  Chainer<F1,F2,VARIABLE_ARGS_DECL> chain( F1 f1, F2 f2 )
91  {
92  return Chainer<F1,F2,VARIABLE_ARGS_DECL>(f1,f2);
93  }
94 
95 
96  #endif
97  }
98 }
Definition: FunctorImpl.h:40
Small operator==(const AnyType &, const AnyType &)
Definition: Callback_Impl.h:11