Go to the documentation of this file.
40 #ifndef runTimeSelectionTables_H
41 #define runTimeSelectionTables_H
49 #define declareRunTimeSelectionTable(autoPtr,baseType,argNames,argList,parList)\
52 typedef autoPtr<baseType> (*argNames##ConstructorPtr)argList; \
55 typedef HashTable<argNames##ConstructorPtr, word, string::hash> \
56 argNames##ConstructorTable; \
59 static argNames##ConstructorTable* argNames##ConstructorTablePtr_; \
62 static void construct##argNames##ConstructorTables(); \
65 static void destroy##argNames##ConstructorTables(); \
68 template<class baseType##Type> \
69 class add##argNames##ConstructorToTable \
73 static autoPtr<baseType> New argList \
75 return autoPtr<baseType>(new baseType##Type parList); \
78 explicit add##argNames##ConstructorToTable \
80 const word& lookup = baseType##Type::typeName \
83 construct##argNames##ConstructorTables(); \
84 if (!argNames##ConstructorTablePtr_->insert(lookup, New)) \
86 std::cerr<< "Duplicate entry " << lookup \
87 << " in runtime selection table " << #baseType \
89 error::safePrintStack(std::cerr); \
93 ~add##argNames##ConstructorToTable() \
95 destroy##argNames##ConstructorTables(); \
98 add##argNames##ConstructorToTable \
99 (const add##argNames##ConstructorToTable&) = delete; \
102 (const add##argNames##ConstructorToTable&) = delete; \
107 template<class baseType##Type> \
108 class addRemovable##argNames##ConstructorToTable \
114 static autoPtr<baseType> New argList \
116 return autoPtr<baseType>(new baseType##Type parList); \
119 explicit addRemovable##argNames##ConstructorToTable \
121 const word& lookup = baseType##Type::typeName \
126 construct##argNames##ConstructorTables(); \
127 argNames##ConstructorTablePtr_->set(lookup, New); \
130 ~addRemovable##argNames##ConstructorToTable() \
132 if (argNames##ConstructorTablePtr_) \
134 argNames##ConstructorTablePtr_->erase(name); \
138 addRemovable##argNames##ConstructorToTable \
139 (const addRemovable##argNames##ConstructorToTable&) = delete; \
142 (const addRemovable##argNames##ConstructorToTable&) = delete; \
148 #define declareRunTimeNewSelectionTable( \
149 autoPtr,baseType,argNames,argList,parList) \
152 typedef autoPtr<baseType> (*argNames##ConstructorPtr)argList; \
155 typedef HashTable<argNames##ConstructorPtr, word, string::hash> \
156 argNames##ConstructorTable; \
159 static argNames##ConstructorTable* argNames##ConstructorTablePtr_; \
162 static void construct##argNames##ConstructorTables(); \
165 static void destroy##argNames##ConstructorTables(); \
168 template<class baseType##Type> \
169 class add##argNames##ConstructorToTable \
173 static autoPtr<baseType> New##baseType argList \
175 return autoPtr<baseType>(baseType##Type::New parList.ptr()); \
178 explicit add##argNames##ConstructorToTable \
180 const word& lookup = baseType##Type::typeName \
183 construct##argNames##ConstructorTables(); \
186 !argNames##ConstructorTablePtr_->insert \
193 std::cerr<< "Duplicate entry " << lookup \
194 << " in runtime selection table " << #baseType \
196 error::safePrintStack(std::cerr); \
200 ~add##argNames##ConstructorToTable() \
202 destroy##argNames##ConstructorTables(); \
205 add##argNames##ConstructorToTable \
206 (const add##argNames##ConstructorToTable&) = delete; \
209 (const add##argNames##ConstructorToTable&) = delete; \
213 template<class baseType##Type> \
214 class addRemovable##argNames##ConstructorToTable \
220 static autoPtr<baseType> New##baseType argList \
222 return autoPtr<baseType>(baseType##Type::New parList.ptr()); \
225 explicit addRemovable##argNames##ConstructorToTable \
227 const word& lookup = baseType##Type::typeName \
232 construct##argNames##ConstructorTables(); \
233 argNames##ConstructorTablePtr_->set \
240 ~addRemovable##argNames##ConstructorToTable() \
242 if (argNames##ConstructorTablePtr_) \
244 argNames##ConstructorTablePtr_->erase(name); \
248 addRemovable##argNames##ConstructorToTable \
249 (const addRemovable##argNames##ConstructorToTable&) = delete; \
252 (const addRemovable##argNames##ConstructorToTable&) = delete; \
257 #define defineRunTimeSelectionTableConstructor(baseType,argNames) \
260 void baseType::construct##argNames##ConstructorTables() \
262 static bool constructed = false; \
265 constructed = true; \
266 baseType::argNames##ConstructorTablePtr_ \
267 = new baseType::argNames##ConstructorTable; \
273 #define defineRunTimeSelectionTableDestructor(baseType,argNames) \
276 void baseType::destroy##argNames##ConstructorTables() \
278 if (baseType::argNames##ConstructorTablePtr_) \
280 delete baseType::argNames##ConstructorTablePtr_; \
281 baseType::argNames##ConstructorTablePtr_ = nullptr; \
287 #define defineRunTimeSelectionTablePtr(baseType,argNames) \
290 baseType::argNames##ConstructorTable* \
291 baseType::argNames##ConstructorTablePtr_(nullptr)
298 #define defineRunTimeSelectionTable(baseType,argNames) \
300 defineRunTimeSelectionTablePtr(baseType,argNames); \
301 defineRunTimeSelectionTableConstructor(baseType,argNames); \
302 defineRunTimeSelectionTableDestructor(baseType,argNames)
307 #define defineTemplateRunTimeSelectionTable(baseType,argNames) \
310 defineRunTimeSelectionTablePtr(baseType,argNames); \
312 defineRunTimeSelectionTableConstructor(baseType,argNames); \
314 defineRunTimeSelectionTableDestructor(baseType,argNames)
320 #define defineTemplatedRunTimeSelectionTableConstructor(baseType,argNames,Targ)\
323 void baseType<Targ>::construct##argNames##ConstructorTables() \
325 static bool constructed = false; \
328 constructed = true; \
329 baseType<Targ>::argNames##ConstructorTablePtr_ \
330 = new baseType<Targ>::argNames##ConstructorTable; \
336 #define defineTemplatedRunTimeSelectionTableDestructor(baseType,argNames,Targ) \
339 void baseType<Targ>::destroy##argNames##ConstructorTables() \
341 if (baseType<Targ>::argNames##ConstructorTablePtr_) \
343 delete baseType<Targ>::argNames##ConstructorTablePtr_; \
344 baseType<Targ>::argNames##ConstructorTablePtr_ = nullptr; \
351 #define defineTemplatedRunTimeSelectionTablePtr(baseType,argNames,Targ) \
354 baseType<Targ>::argNames##ConstructorTable* \
355 baseType<Targ>::argNames##ConstructorTablePtr_(nullptr)
360 #define defineTemplatedRunTimeSelectionTable(baseType,argNames,Targ) \
363 defineTemplatedRunTimeSelectionTablePtr(baseType,argNames,Targ); \
365 defineTemplatedRunTimeSelectionTableConstructor(baseType,argNames,Targ); \
367 defineTemplatedRunTimeSelectionTableDestructor(baseType,argNames,Targ)
#define defineRunTimeSelectionTableDestructor(baseType, argNames)
#define defineTemplateRunTimeSelectionTable(baseType, argNames)
Define run-time selection table for template classes.
#define defineRunTimeSelectionTableConstructor(baseType, argNames)
#define defineRunTimeSelectionTablePtr(baseType, argNames)
#define defineTemplatedRunTimeSelectionTablePtr(baseType, argNames, Targ)
Create pointer to hash-table of functions.