runTimeSelectionTables.H
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 #include "token.H"
00040
00041 #ifndef runTimeSelectionTables_H
00042 #define runTimeSelectionTables_H
00043
00044 #include "autoPtr.H"
00045 #include "HashTable.H"
00046
00047
00048
00049
00050
00051
00052
00053 #define declareRunTimeSelectionTable\
00054 (autoPtr,baseType,argNames,argList,parList) \
00055 \
00056 \
00057 typedef autoPtr< baseType > (*argNames##ConstructorPtr)argList; \
00058 \
00059 \
00060 typedef HashTable< argNames##ConstructorPtr, word, string::hash > \
00061 argNames##ConstructorTable; \
00062 \
00063 \
00064 static argNames##ConstructorTable* argNames##ConstructorTablePtr_; \
00065 \
00066 \
00067 template< class baseType##Type > \
00068 class add##argNames##ConstructorToTable \
00069 { \
00070 public: \
00071 \
00072 static autoPtr< baseType > New argList \
00073 { \
00074 return autoPtr< baseType >(new baseType##Type parList); \
00075 } \
00076 \
00077 add##argNames##ConstructorToTable \
00078 ( \
00079 const word& lookup = baseType##Type::typeName \
00080 ) \
00081 { \
00082 construct##argNames##ConstructorTables(); \
00083 argNames##ConstructorTablePtr_->insert(lookup, New); \
00084 } \
00085 \
00086 ~add##argNames##ConstructorToTable() \
00087 { \
00088 destroy##argNames##ConstructorTables(); \
00089 } \
00090 }; \
00091 \
00092 \
00093 static void construct##argNames##ConstructorTables(); \
00094 \
00095 \
00096 static void destroy##argNames##ConstructorTables()
00097
00098
00099
00100
00101
00102 #define declareRunTimeNewSelectionTable\
00103 (autoPtr,baseType,argNames,argList,parList) \
00104 \
00105 \
00106 typedef autoPtr< baseType > (*argNames##ConstructorPtr)argList; \
00107 \
00108 \
00109 typedef HashTable< argNames##ConstructorPtr, word, string::hash > \
00110 argNames##ConstructorTable; \
00111 \
00112 \
00113 static argNames##ConstructorTable* argNames##ConstructorTablePtr_; \
00114 \
00115 \
00116 template< class baseType##Type > \
00117 class add##argNames##ConstructorToTable \
00118 { \
00119 public: \
00120 \
00121 static autoPtr< baseType > New##baseType argList \
00122 { \
00123 return autoPtr< baseType >(baseType##Type::New parList.ptr()); \
00124 } \
00125 \
00126 add##argNames##ConstructorToTable \
00127 ( \
00128 const word& lookup = baseType##Type::typeName \
00129 ) \
00130 { \
00131 construct##argNames##ConstructorTables(); \
00132 argNames##ConstructorTablePtr_->insert \
00133 ( \
00134 lookup, \
00135 New##baseType \
00136 ); \
00137 } \
00138 \
00139 ~add##argNames##ConstructorToTable() \
00140 { \
00141 destroy##argNames##ConstructorTables(); \
00142 } \
00143 }; \
00144 \
00145 \
00146 static void construct##argNames##ConstructorTables(); \
00147 \
00148 \
00149 static void destroy##argNames##ConstructorTables()
00150
00151
00152
00153
00154 #define defineRunTimeSelectionTableConstructor\
00155 (baseType,argNames) \
00156 \
00157 \
00158 void baseType::construct##argNames##ConstructorTables() \
00159 { \
00160 static bool constructed = false; \
00161 \
00162 if (!constructed) \
00163 { \
00164 baseType::argNames##ConstructorTablePtr_ \
00165 = new baseType::argNames##ConstructorTable; \
00166 \
00167 constructed = true; \
00168 } \
00169 }
00170
00171
00172
00173
00174 #define defineRunTimeSelectionTableDestructor\
00175 (baseType,argNames) \
00176 \
00177 \
00178 void baseType::destroy##argNames##ConstructorTables() \
00179 { \
00180 if (baseType::argNames##ConstructorTablePtr_) \
00181 { \
00182 delete baseType::argNames##ConstructorTablePtr_; \
00183 baseType::argNames##ConstructorTablePtr_ = NULL; \
00184 } \
00185 }
00186
00187
00188
00189
00190 #define defineRunTimeSelectionTablePtr\
00191 (baseType,argNames) \
00192 \
00193 \
00194 baseType::argNames##ConstructorTable* \
00195 baseType::argNames##ConstructorTablePtr_ = NULL
00196
00197
00198
00199 #define defineTemplateRunTimeSelectionTablePtr(baseType,argNames) \
00200 \
00201 \
00202 typename baseType::argNames##ConstructorTable* \
00203 baseType::argNames##ConstructorTablePtr_ = NULL
00204
00205
00206
00207
00208
00209
00210
00211
00212 #define defineRunTimeSelectionTable\
00213 (baseType,argNames) \
00214 \
00215 defineRunTimeSelectionTablePtr(baseType,argNames); \
00216 defineRunTimeSelectionTableConstructor(baseType,argNames); \
00217 defineRunTimeSelectionTableDestructor(baseType,argNames)
00218
00219
00220
00221
00222
00223
00224 #define defineTemplateRunTimeSelectionTable\
00225 (baseType,argNames) \
00226 \
00227 template<> \
00228 defineRunTimeSelectionTablePtr(baseType,argNames); \
00229 template<> \
00230 defineRunTimeSelectionTableConstructor(baseType,argNames); \
00231 template<> \
00232 defineRunTimeSelectionTableDestructor(baseType,argNames)
00233
00234
00235
00236
00237
00238
00239
00240
00241 #define defineTemplatedRunTimeSelectionTableConstructor\
00242 (baseType,argNames,Targ) \
00243 \
00244 \
00245 void baseType< Targ >::construct##argNames##ConstructorTables() \
00246 { \
00247 static bool constructed = false; \
00248 \
00249 if (!constructed) \
00250 { \
00251 baseType< Targ >::argNames##ConstructorTablePtr_ \
00252 = new baseType< Targ >::argNames##ConstructorTable; \
00253 \
00254 constructed = true; \
00255 } \
00256 }
00257
00258
00259
00260
00261
00262 #define defineTemplatedRunTimeSelectionTableDestructor\
00263 (baseType,argNames,Targ) \
00264 \
00265 \
00266 void baseType< Targ >::destroy##argNames##ConstructorTables() \
00267 { \
00268 if (baseType< Targ >::argNames##ConstructorTablePtr_) \
00269 { \
00270 delete baseType< Targ >::argNames##ConstructorTablePtr_; \
00271 baseType< Targ >::argNames##ConstructorTablePtr_ = NULL; \
00272 } \
00273 }
00274
00275
00276
00277
00278
00279 #define defineTemplatedRunTimeSelectionTablePtr\
00280 (baseType,argNames,Targ) \
00281 \
00282 \
00283 baseType< Targ >::argNames##ConstructorTable* \
00284 baseType< Targ >::argNames##ConstructorTablePtr_ = NULL
00285
00286
00287
00288
00289
00290
00291 #define defineTemplatedRunTimeSelectionTable\
00292 (baseType,argNames,Targ) \
00293 \
00294 template<> \
00295 defineTemplatedRunTimeSelectionTablePtr(baseType,argNames,Targ); \
00296 template<> \
00297 defineTemplatedRunTimeSelectionTableConstructor(baseType,argNames,Targ); \
00298 template<> \
00299 defineTemplatedRunTimeSelectionTableDestructor(baseType,argNames,Targ)
00300
00301
00302
00303
00304 #endif
00305
00306
Copyright © 2000-2009 OpenCFD Ltd