combinedfunctor.hh

00001 #ifndef DUNE_AMG_COMBINEDFUNCTOR_HH
00002 #define DUNE_AMG_COMBINEDFUNCTOR_HH
00003 
00004 #include<dune/common/tuples.hh>
00005 namespace Dune
00006 {
00007   namespace Amg
00008   {
00009 
00010     template<typename T1, typename T2 = Nil, typename T3 = Nil, 
00011            typename T4 = Nil, typename T5 = Nil,typename T6 = Nil, 
00012            typename T7 = Nil, typename T8 = Nil, typename T9 = Nil>
00013     class CombinedFunctor : public Tuple<T1,T2,T3,T4,T5,T6,T7,T8,T9>
00014     {
00015     public:
00016       CombinedFunctor(const T1& t1=T1(), const T2& t2=T2(), const T3& t3=T3(), 
00017                       const T4& t4=T4(), const T5& t5=T5(), const T6& t6=T6(), 
00018                       const T7& t7=T7(), const T8& t8=T8(), const T9& t9=T8())
00019         : Tuple<T1,T2,T3,T4,T5,T6,T7,T8,T9>(t1, t2, t3,
00020                                            t4, t5, t6, 
00021                                            t7, t8, t9)
00022       {}
00023       
00024       template<class T>
00025       void operator()(const T& t)
00026       {
00027         apply(*this, t);
00028       }
00029       
00030     private:
00031       template<class T, class TT1, class TT2>
00032       inline void apply(Pair<TT1,TT2>& pair, const T& t)
00033       {
00034         pair.first()(t);
00035         apply(pair.second(), t);
00036       }
00037       
00038       template<class T, class TT1>
00039       inline void apply(Pair<TT1,Nil>& pair, const T& t)
00040       {
00041         pair.first()(t);
00042       }
00043     };
00044     
00045     
00046   }//namespace Amg
00047 }// namespace Dune
00048 #endif

Generated on 12 Dec 2007 with Doxygen (ver 1.5.1)