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 #ifndef ops_H
00038 #define ops_H
00039
00040
00041
00042 namespace Foam
00043 {
00044
00045
00046
00047 #define EqOp(opName, op) \
00048 \
00049 template<class T1, class T2> \
00050 class opName##Op2 \
00051 { \
00052 public: \
00053 \
00054 void operator()(T1& x, const T2& y) const \
00055 { \
00056 op; \
00057 } \
00058 }; \
00059 \
00060 template<class T> \
00061 class opName##Op \
00062 { \
00063 public: \
00064 \
00065 void operator()(T& x, const T& y) const \
00066 { \
00067 op; \
00068 } \
00069 };
00070
00071 EqOp(eq, x = y)
00072 EqOp(plusEq, x += y)
00073 EqOp(minusEq, x -= y)
00074 EqOp(multiplyEq, x *= y)
00075 EqOp(divideEq, x /= y)
00076 EqOp(eqMag, x = mag(y))
00077 EqOp(plusEqMagSqr, x += magSqr(y))
00078 EqOp(maxEq, x = max(x, y))
00079 EqOp(minEq, x = min(x, y))
00080 EqOp(andEq, x = (x && y))
00081 EqOp(orEq, x = (x || y))
00082
00083 EqOp(eqMinus, x = -y)
00084
00085 #undef EqOp
00086
00087
00088
00089
00090 #define Op(opName, op) \
00091 \
00092 template<class T, class T1, class T2> \
00093 class opName##Op3 \
00094 { \
00095 public: \
00096 \
00097 T operator()(const T1& x, const T2& y) const \
00098 { \
00099 return op; \
00100 } \
00101 }; \
00102 \
00103 template<class T1, class T2> \
00104 class opName##Op2 \
00105 { \
00106 public: \
00107 \
00108 T1 operator()(const T1& x, const T2& y) const \
00109 { \
00110 return op; \
00111 } \
00112 }; \
00113 \
00114 template<class T> \
00115 class opName##Op \
00116 { \
00117 public: \
00118 \
00119 T operator()(const T& x, const T& y) const \
00120 { \
00121 return op; \
00122 } \
00123 };
00124
00125 Op(sum, x + y)
00126
00127 Op(plus, x + y)
00128 Op(minus, x - y)
00129 Op(multiply, x * y)
00130 Op(divide, x / y)
00131 Op(max, max(x, y))
00132 Op(min, min(x, y))
00133 Op(scale, scale(x, y))
00134 Op(and, x && y)
00135 Op(or, x || y)
00136
00137 #undef Op
00138
00139
00140
00141
00142 }
00143
00144
00145
00146 #endif
00147
00148