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 #include <OpenFOAM/token.H>
00033
00034 #ifndef memberFunctionSelectionTables_H
00035 #define memberFunctionSelectionTables_H
00036
00037 #include <OpenFOAM/HashTable.H>
00038
00039
00040
00041
00042
00043
00044
00045 #define declareMemberFunctionSelectionTable\
00046 (returnType,baseType,memberFunction,argNames,argList,parList) \
00047 \
00048 \
00049 typedef returnType (*memberFunction##argNames##MemberFunctionPtr)argList; \
00050 \
00051 \
00052 typedef HashTable \
00053 <memberFunction##argNames##MemberFunctionPtr, word, string::hash> \
00054 memberFunction##argNames##MemberFunctionTable; \
00055 \
00056 \
00057 static memberFunction##argNames##MemberFunctionTable* \
00058 memberFunction##argNames##MemberFunctionTablePtr_; \
00059 \
00060 \
00061 template<class baseType##Type> \
00062 class add##memberFunction##argNames##MemberFunctionToTable \
00063 { \
00064 public: \
00065 \
00066 add##memberFunction##argNames##MemberFunctionToTable \
00067 ( \
00068 const word& lookup = baseType##Type::typeName \
00069 ) \
00070 { \
00071 construct##memberFunction##argNames##MemberFunctionTables(); \
00072 memberFunction##argNames##MemberFunctionTablePtr_->insert \
00073 ( \
00074 lookup, \
00075 baseType##Type::memberFunction \
00076 ); \
00077 } \
00078 \
00079 ~add##memberFunction##argNames##MemberFunctionToTable() \
00080 { \
00081 destroy##memberFunction##argNames##MemberFunctionTables(); \
00082 } \
00083 }; \
00084 \
00085 \
00086 static void construct##memberFunction##argNames##MemberFunctionTables(); \
00087 \
00088 \
00089 static void destroy##memberFunction##argNames##MemberFunctionTables()
00090
00091
00092
00093
00094 #define defineMemberFunctionSelectionTableMemberFunction\
00095 (baseType,memberFunction,argNames) \
00096 \
00097 \
00098 void baseType::construct##memberFunction##argNames##MemberFunctionTables()\
00099 { \
00100 static bool constructed = false; \
00101 \
00102 if (!constructed) \
00103 { \
00104 baseType::memberFunction##argNames##MemberFunctionTablePtr_ \
00105 = new baseType::memberFunction##argNames##MemberFunctionTable;\
00106 \
00107 constructed = true; \
00108 } \
00109 }
00110
00111
00112
00113
00114 #define defineMemberFunctionSelectionTableDestructor\
00115 (baseType,memberFunction,argNames) \
00116 \
00117 \
00118 void baseType::destroy##memberFunction##argNames##MemberFunctionTables() \
00119 { \
00120 if (baseType::memberFunction##argNames##MemberFunctionTablePtr_) \
00121 { \
00122 delete baseType::memberFunction##argNames##MemberFunctionTablePtr_;\
00123 baseType::memberFunction##argNames##MemberFunctionTablePtr_ = NULL;\
00124 } \
00125 }
00126
00127
00128
00129
00130 #define defineMemberFunctionSelectionTablePtr\
00131 (baseType,memberFunction,argNames) \
00132 \
00133 \
00134 baseType::memberFunction##argNames##MemberFunctionTable* \
00135 baseType::memberFunction##argNames##MemberFunctionTablePtr_ = NULL
00136
00137
00138
00139 #define defineTemplateMemberFunctionSelectionTablePtr\
00140 (baseType,memberFunction,argNames) \
00141 \
00142 \
00143 typename baseType::memberFunction##argNames##MemberFunctionTable* \
00144 baseType::memberFunction##argNames##MemberFunctionTablePtr_ = NULL
00145
00146
00147
00148
00149
00150
00151
00152 #define defineMemberFunctionSelectionTable\
00153 (baseType,memberFunction,argNames) \
00154 \
00155 defineMemberFunctionSelectionTablePtr \
00156 (baseType,memberFunction,argNames); \
00157 defineMemberFunctionSelectionTableMemberFunction \
00158 (baseType,memberFunction,argNames) \
00159 defineMemberFunctionSelectionTableDestructor \
00160 (baseType,memberFunction,argNames)
00161
00162
00163
00164
00165
00166
00167 #define defineTemplateMemberFunctionSelectionTable\
00168 (baseType,memberFunction,argNames) \
00169 \
00170 template<> \
00171 defineMemberFunctionSelectionTablePtr \
00172 (baseType,memberFunction,argNames); \
00173 template<> \
00174 defineMemberFunctionSelectionTableMemberFunction \
00175 (baseType,memberFunction,argNames) \
00176 template<> \
00177 defineMemberFunctionSelectionTableDestructor \
00178 (baseType,memberFunction,argNames)
00179
00180
00181
00182
00183
00184
00185
00186 #define defineTemplatedMemberFunctionSelectionTableMemberFunction\
00187 (baseType,memberFunction,argNames,Targ) \
00188 \
00189 \
00190 void baseType<Targ>::construct##memberFunction##argNames##MemberFunctionTables()\
00191 { \
00192 static bool constructed = false; \
00193 \
00194 if (!constructed) \
00195 { \
00196 baseType<Targ>::memberFunction##argNames##MemberFunctionTablePtr_ \
00197 = new baseType<Targ>::memberFunction##argNames##MemberFunctionTable;\
00198 \
00199 constructed = true; \
00200 } \
00201 }
00202
00203
00204
00205
00206
00207 #define defineTemplatedMemberFunctionSelectionTableDestructor\
00208 (baseType,memberFunction,argNames,Targ) \
00209 \
00210 \
00211 void baseType<Targ>::destroy##memberFunction##argNames##MemberFunctionTables() \
00212 { \
00213 if (baseType<Targ>::memberFunction##argNames##MemberFunctionTablePtr_) \
00214 { \
00215 delete baseType<Targ>::memberFunction##argNames##MemberFunctionTablePtr_;\
00216 baseType<Targ>::memberFunction##argNames##MemberFunctionTablePtr_ = NULL;\
00217 } \
00218 }
00219
00220
00221
00222
00223
00224 #define defineTemplatedMemberFunctionSelectionTablePtr\
00225 (baseType,memberFunction,argNames,Targ) \
00226 \
00227 \
00228 baseType<Targ>::memberFunction##argNames##MemberFunctionTable* \
00229 baseType<Targ>::memberFunction##argNames##MemberFunctionTablePtr_ = NULL
00230
00231
00232
00233
00234
00235
00236 #define defineTemplatedMemberFunctionSelectionTable\
00237 (baseType,memberFunction,argNames,Targ) \
00238 \
00239 template<> \
00240 defineTemplatedMemberFunctionSelectionTablePtr \
00241 (baseType,memberFunction,argNames,Targ); \
00242 template<> \
00243 defineTemplatedMemberFunctionSelectionTableMemberFunction \
00244 (baseType,memberFunction,argNames,Targ) \
00245 template<> \
00246 defineTemplatedMemberFunctionSelectionTableDestructor \
00247 (baseType,memberFunction,argNames,Targ)
00248
00249
00250
00251 #endif
00252
00253