Go to the documentation of
this file.
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042 #ifndef QTCONCURRENT_FUNCTIONWRAPPERS_H
00043 #define QTCONCURRENT_FUNCTIONWRAPPERS_H
00044
00045 #include <QtCore/qglobal.h>
00046
00047 #ifndef QT_NO_CONCURRENT
00048
00049 QT_BEGIN_HEADER
00050 QT_BEGIN_NAMESPACE
00051
00052 QT_MODULE(Core)
00053
00054 #ifndef qdoc
00055
00056 namespace QtConcurrent {
00057
00058 template <typename T>
00059 class FunctionWrapper0
00060 {
00061 public:
00062 typedef T (*FunctionPointerType)();
00063 typedef T result_type;
00064 inline FunctionWrapper0(FunctionPointerType _functionPointer)
00065 :functionPointer(_functionPointer) { }
00066
00067 inline T operator()()
00068 {
00069 return functionPointer();
00070 }
00071 private:
00072 FunctionPointerType functionPointer;
00073 };
00074
00075 template <typename T, typename U>
00076 class FunctionWrapper1
00077 {
00078 public:
00079 typedef T (*FunctionPointerType)(U u);
00080 typedef T result_type;
00081 inline FunctionWrapper1(FunctionPointerType _functionPointer)
00082 :functionPointer(_functionPointer) { }
00083
00084 inline T operator()(U u)
00085 {
00086 return functionPointer(u);
00087 }
00088
00089 private:
00090 FunctionPointerType functionPointer;
00091 };
00092
00093 template <typename T, typename U, typename V>
00094 class FunctionWrapper2
00095 {
00096 public:
00097 typedef T (*FunctionPointerType)(U u, V v);
00098 typedef T result_type;
00099 inline FunctionWrapper2(FunctionPointerType _functionPointer)
00100 :functionPointer(_functionPointer) { }
00101
00102 inline T operator()(U u, V v)
00103 {
00104 return functionPointer(u, v);
00105 }
00106 private:
00107 FunctionPointerType functionPointer;
00108 };
00109
00110 template <typename T, typename C>
00111 class MemberFunctionWrapper
00112 {
00113 public:
00114 typedef T (C::*FunctionPointerType)();
00115 typedef T result_type;
00116 inline MemberFunctionWrapper(FunctionPointerType _functionPointer)
00117 :functionPointer(_functionPointer) { }
00118
00119 inline T operator()(C &c)
00120 {
00121 return (c.*functionPointer)();
00122 }
00123 private:
00124 FunctionPointerType functionPointer;
00125 };
00126
00127 template <typename T, typename C, typename U>
00128 class MemberFunctionWrapper1
00129 {
00130 public:
00131 typedef T (C::*FunctionPointerType)(U);
00132 typedef T result_type;
00133
00134 inline MemberFunctionWrapper1(FunctionPointerType _functionPointer)
00135 : functionPointer(_functionPointer)
00136 { }
00137
00138 inline T operator()(C &c, U u)
00139 {
00140 return (c.*functionPointer)(u);
00141 }
00142
00143 private:
00144 FunctionPointerType functionPointer;
00145 };
00146
00147 template <typename T, typename C>
00148 class ConstMemberFunctionWrapper
00149 {
00150 public:
00151 typedef T (C::*FunctionPointerType)() const;
00152 typedef T result_type;
00153 inline ConstMemberFunctionWrapper(FunctionPointerType _functionPointer)
00154 :functionPointer(_functionPointer) { }
00155
00156 inline T operator()(const C &c) const
00157 {
00158 return (c.*functionPointer)();
00159 }
00160 private:
00161 FunctionPointerType functionPointer;
00162 };
00163
00164 }
00165
00166 #endif //qdoc
00167
00168 QT_END_NAMESPACE
00169 QT_END_HEADER
00170
00171 #endif // QT_NO_CONCURRENT
00172
00173 #endif