ML Reference
mlArgumentList.h
Go to the documentation of this file.
1/*************************************************************************************
2**
3** Copyright 2009, MeVis Medical Solutions AG
4**
5** The user may use this file in accordance with the license agreement provided with
6** the Software or, alternatively, in accordance with the terms contained in a
7** written agreement between the user and MeVis Medical Solutions AG.
8**
9** For further information use the contact form at https://www.mevislab.de/contact
10**
11**************************************************************************************/
12
13#ifndef ML_ARGUMENT_LIST_H
14#define ML_ARGUMENT_LIST_H
15
18
19#include "mlUtilsSystem.h"
20
21ML_UTILS_START_NAMESPACE
22
25{
26};
27
29template<class Arg1>
31{
32 ArgumentList1(const Arg1& arg1):_arg1(arg1) {}
33 Arg1 _arg1;
34};
35
37template<class Arg1, class Arg2>
39{
40 ArgumentList2(const Arg1& arg1, const Arg2& arg2):_arg1(arg1),_arg2(arg2) {}
41 Arg1 _arg1;
42 Arg2 _arg2;
43};
44
46template<class Arg1, class Arg2, class Arg3>
48{
49 ArgumentList3(const Arg1& arg1, const Arg2& arg2, const Arg3& arg3):_arg1(arg1),_arg2(arg2),_arg3(arg3) {}
50 Arg1 _arg1;
51 Arg2 _arg2;
52 Arg3 _arg3;
53};
54
56template<class Arg1, class Arg2, class Arg3, class Arg4>
58{
59 ArgumentList4(const Arg1& arg1, const Arg2& arg2, const Arg3& arg3, const Arg4& arg4):_arg1(arg1),_arg2(arg2),_arg3(arg3),_arg4(arg4) {}
60 Arg1 _arg1;
61 Arg2 _arg2;
62 Arg3 _arg3;
63 Arg4 _arg4;
64};
65
67template<class Arg1, class Arg2, class Arg3, class Arg4, class Arg5>
69{
70 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) {}
71 Arg1 _arg1;
72 Arg2 _arg2;
73 Arg3 _arg3;
74 Arg4 _arg4;
75 Arg5 _arg5;
76};
77
78//----------------------------------------------------------------
83template<class Arg1>
85{ return ArgumentList1<Arg1>(arg1); }
86
88template<class Arg1, class Arg2>
89inline ArgumentList2<Arg1, Arg2> MLGenerateArgumentList(const Arg1& arg1, const Arg2& arg2)
90{ return ArgumentList2<Arg1, Arg2>(arg1, arg2); }
92template<class Arg1, class Arg2, class Arg3>
93inline ArgumentList3<Arg1, Arg2, Arg3> MLGenerateArgumentList(const Arg1& arg1, const Arg2& arg2, const Arg3& arg3)
94{ return ArgumentList3<Arg1, Arg2, Arg3>(arg1, arg2, arg3); }
95
97template<class Arg1, class Arg2, class Arg3, class Arg4>
98inline ArgumentList4<Arg1, Arg2, Arg3, Arg4> MLGenerateArgumentList(const Arg1& arg1, const Arg2& arg2, const Arg3& arg3, const Arg4& arg4)
99{ return ArgumentList4<Arg1, Arg2, Arg3, Arg4>(arg1, arg2, arg3, arg4); }
101template<class Arg1, class Arg2, class Arg3, class Arg4, class Arg5>
102inline ArgumentList5<Arg1, Arg2, Arg3, Arg4, Arg5> MLGenerateArgumentList(const Arg1& arg1, const Arg2& arg2, const Arg3& arg3, const Arg4& arg4, const Arg5& arg5)
103{ return ArgumentList5<Arg1, Arg2, Arg3, Arg4, Arg5>(arg1, arg2, arg3, arg4, arg5); }
104
105//----------------------------------------------------------------
107template<class Object, class Method>
108void MLCallMethodWithArguments(Object* object, Method method, const ArgumentList0&) {
109 (object->*method)();
110}
112template<class Object, class Method, class Arg1>
113void MLCallMethodWithArguments(Object* object, Method method, const ArgumentList1<Arg1>& args) {
114 (object->*method)(args._arg1);
115}
117template<class Object, class Method, class Arg1, class Arg2>
118void MLCallMethodWithArguments(Object* object, Method method, const ArgumentList2<Arg1, Arg2>& args) {
119 (object->*method)(args._arg1, args._arg2);
120}
121
123template<class Object, class Method, class Arg1, class Arg2, class Arg3>
124void MLCallMethodWithArguments(Object* object, Method method, const ArgumentList3<Arg1, Arg2, Arg3>& args) {
125 (object->*method)(args._arg1, args._arg2, args._arg3);
126}
128template<class Object, class Method, class Arg1, class Arg2, class Arg3, class Arg4>
129void MLCallMethodWithArguments(Object* object, Method method, const ArgumentList4<Arg1, Arg2, Arg3, Arg4>& args) {
130 (object->*method)(args._arg1, args._arg2, args._arg3, args._arg4);
131}
133template<class Object, class Method, class Arg1, class Arg2, class Arg3, class Arg4, class Arg5>
134void MLCallMethodWithArguments(Object* object, Method method, const ArgumentList5<Arg1, Arg2, Arg3, Arg4, Arg5>& args) {
135 (object->*method)(args._arg1, args._arg2, args._arg3, args._arg4, args._arg5);
136}
137
138ML_UTILS_END_NAMESPACE
139
140#endif // __mlArgumentList_H
141
142
ArgumentList0 MLGenerateArgumentList()
Creates argument list with 0 arguments.
void MLCallMethodWithArguments(Object *object, Method method, const ArgumentList0 &)
Calls a method on given object with 0 arguments.
Empty argument to allow running with 0 arguments.
ArgumentList with 1 argument.
ArgumentList1(const Arg1 &arg1)
ArgumentList with 2 arguments.
ArgumentList2(const Arg1 &arg1, const Arg2 &arg2)
ArgumentList with 3 arguments.
ArgumentList3(const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3)
ArgumentList with 4 arguments.
ArgumentList4(const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4)
ArgumentList with 5 arguments.
ArgumentList5(const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4, const Arg5 &arg5)