ML Reference
MeVis/Foundation/Sources/MLUtilities/mlArgumentList.h
Go to the documentation of this file.
00001 // **InsertLicense** code
00002 //----------------------------------------------------------------------------------
00005 
00010 //----------------------------------------------------------------------------------
00011 
00012 #ifndef __mlArgumentList_H
00013 #define __mlArgumentList_H
00014 
00015 #include "mlUtilsSystem.h"
00016 
00017 ML_UTILS_START_NAMESPACE
00018 
00020 struct ArgumentList0
00021 {
00022 };
00023 
00025 template<class Arg1>
00026 struct ArgumentList1
00027 {
00028   ArgumentList1(const Arg1& arg1):_arg1(arg1) {}
00029   Arg1 _arg1;
00030 };
00031 
00033 template<class Arg1, class Arg2>
00034 struct ArgumentList2
00035 {
00036   ArgumentList2(const Arg1& arg1, const Arg2& arg2):_arg1(arg1),_arg2(arg2) {}
00037   Arg1 _arg1;
00038   Arg2 _arg2;
00039 };
00040 
00042 template<class Arg1, class Arg2, class Arg3>
00043 struct ArgumentList3
00044 {
00045   ArgumentList3(const Arg1& arg1, const Arg2& arg2, const Arg3& arg3):_arg1(arg1),_arg2(arg2),_arg3(arg3) {}
00046   Arg1 _arg1;
00047   Arg2 _arg2;
00048   Arg3 _arg3;
00049 };
00050 
00052 template<class Arg1, class Arg2, class Arg3, class Arg4>
00053 struct ArgumentList4
00054 {
00055   ArgumentList4(const Arg1& arg1, const Arg2& arg2, const Arg3& arg3, const Arg4& arg4):_arg1(arg1),_arg2(arg2),_arg3(arg3),_arg4(arg4) {}
00056   Arg1 _arg1;
00057   Arg2 _arg2;
00058   Arg3 _arg3;
00059   Arg4 _arg4;
00060 };
00061 
00063 template<class Arg1, class Arg2, class Arg3, class Arg4, class Arg5>
00064 struct ArgumentList5
00065 {
00066   ArgumentList5(const Arg1& arg1, const Arg2& arg2, const Arg3& arg3, const Arg4& arg4, const Arg5& arg5):_arg1(arg1),_arg2(arg2),_arg3(arg3),_arg4(arg4),_arg5(arg5) {}
00067   Arg1 _arg1;
00068   Arg2 _arg2;
00069   Arg3 _arg3;
00070   Arg4 _arg4;
00071   Arg5 _arg5;
00072 };
00073 
00074 //----------------------------------------------------------------
00076 inline ArgumentList0 MLGenerateArgumentList()
00077 { return ArgumentList0(); };
00079 template<class Arg1>
00080 inline ArgumentList1<Arg1> MLGenerateArgumentList(const Arg1& arg1)
00081 { return ArgumentList1<Arg1>(arg1); }
00082 
00084 template<class Arg1, class Arg2>
00085 inline ArgumentList2<Arg1, Arg2> MLGenerateArgumentList(const Arg1& arg1, const Arg2& arg2)
00086 { return ArgumentList2<Arg1, Arg2>(arg1, arg2); }
00088 template<class Arg1, class Arg2, class Arg3>
00089 inline ArgumentList3<Arg1, Arg2, Arg3> MLGenerateArgumentList(const Arg1& arg1, const Arg2& arg2, const Arg3& arg3)
00090 { return ArgumentList3<Arg1, Arg2, Arg3>(arg1, arg2, arg3); }
00091 
00093 template<class Arg1, class Arg2, class Arg3, class Arg4>
00094 inline ArgumentList4<Arg1, Arg2, Arg3, Arg4> MLGenerateArgumentList(const Arg1& arg1, const Arg2& arg2, const Arg3& arg3, const Arg4& arg4)
00095 { return ArgumentList4<Arg1, Arg2, Arg3, Arg4>(arg1, arg2, arg3, arg4); }
00097 template<class Arg1, class Arg2, class Arg3, class Arg4, class Arg5>
00098 inline ArgumentList5<Arg1, Arg2, Arg3, Arg4, Arg5> MLGenerateArgumentList(const Arg1& arg1, const Arg2& arg2, const Arg3& arg3, const Arg4& arg4, const Arg5& arg5)
00099 { return ArgumentList5<Arg1, Arg2, Arg3, Arg4, Arg5>(arg1, arg2, arg3, arg4, arg5); }
00100 
00101 //----------------------------------------------------------------
00103 template<class Object, class Method>
00104 void MLCallMethodWithArguments(Object* object, Method method, const ArgumentList0&) {
00105   (object->*method)();
00106 }
00108 template<class Object, class Method, class Arg1>
00109 void MLCallMethodWithArguments(Object* object, Method method, const ArgumentList1<Arg1>& args) {
00110   (object->*method)(args._arg1);
00111 }
00113 template<class Object, class Method, class Arg1, class Arg2>
00114 void MLCallMethodWithArguments(Object* object, Method method, const ArgumentList2<Arg1, Arg2>& args) {
00115   (object->*method)(args._arg1, args._arg2);
00116 }
00117 
00119 template<class Object, class Method, class Arg1, class Arg2, class Arg3>
00120 void MLCallMethodWithArguments(Object* object, Method method, const ArgumentList3<Arg1, Arg2, Arg3>& args) {
00121   (object->*method)(args._arg1, args._arg2, args._arg3);
00122 }
00124 template<class Object, class Method, class Arg1, class Arg2, class Arg3, class Arg4>
00125 void MLCallMethodWithArguments(Object* object, Method method, const ArgumentList4<Arg1, Arg2, Arg3, Arg4>& args) {
00126   (object->*method)(args._arg1, args._arg2, args._arg3, args._arg4);
00127 }
00129 template<class Object, class Method, class Arg1, class Arg2, class Arg3, class Arg4, class Arg5>
00130 void MLCallMethodWithArguments(Object* object, Method method, const ArgumentList5<Arg1, Arg2, Arg3, Arg4, Arg5>& args) {
00131   (object->*method)(args._arg1, args._arg2, args._arg3, args._arg4, args._arg5);
00132 }
00133 
00134 ML_UTILS_END_NAMESPACE
00135 
00136 #endif // __mlArgumentList_H
00137 
00138