Go to the documentation of this file.
40 #ifndef runTimeSelectionTables_H
41 #define runTimeSelectionTables_H
52 #define declareRunTimeSelectionTable\
53 (autoPtr,baseType,argNames,argList,parList) \
56 typedef autoPtr< baseType > (*argNames##ConstructorPtr)argList; \
59 typedef HashTable< argNames##ConstructorPtr, word, string::hash > \
60 argNames##ConstructorTable; \
63 static argNames##ConstructorTable* argNames##ConstructorTablePtr_; \
66 template< class baseType##Type > \
67 class add##argNames##ConstructorToTable \
71 static autoPtr< baseType > New argList \
73 return autoPtr< baseType >(new baseType##Type parList); \
76 add##argNames##ConstructorToTable \
78 const word& lookup = baseType##Type::typeName \
81 construct##argNames##ConstructorTables(); \
82 argNames##ConstructorTablePtr_->insert(lookup, New); \
85 ~add##argNames##ConstructorToTable() \
87 destroy##argNames##ConstructorTables(); \
92 static void construct##argNames##ConstructorTables(); \
95 static void destroy##argNames##ConstructorTables()
101 #define declareRunTimeNewSelectionTable\
102 (autoPtr,baseType,argNames,argList,parList) \
105 typedef autoPtr< baseType > (*argNames##ConstructorPtr)argList; \
108 typedef HashTable< argNames##ConstructorPtr, word, string::hash > \
109 argNames##ConstructorTable; \
112 static argNames##ConstructorTable* argNames##ConstructorTablePtr_; \
115 template< class baseType##Type > \
116 class add##argNames##ConstructorToTable \
120 static autoPtr< baseType > New##baseType argList \
122 return autoPtr< baseType >(baseType##Type::New parList.ptr()); \
125 add##argNames##ConstructorToTable \
127 const word& lookup = baseType##Type::typeName \
130 construct##argNames##ConstructorTables(); \
131 argNames##ConstructorTablePtr_->insert \
138 ~add##argNames##ConstructorToTable() \
140 destroy##argNames##ConstructorTables(); \
145 static void construct##argNames##ConstructorTables(); \
148 static void destroy##argNames##ConstructorTables()
153 #define defineRunTimeSelectionTableConstructor\
154 (baseType,argNames) \
157 void baseType::construct##argNames##ConstructorTables() \
159 static bool constructed = false; \
163 baseType::argNames##ConstructorTablePtr_ \
164 = new baseType::argNames##ConstructorTable; \
166 constructed = true; \
173 #define defineRunTimeSelectionTableDestructor\
174 (baseType,argNames) \
177 void baseType::destroy##argNames##ConstructorTables() \
179 if (baseType::argNames##ConstructorTablePtr_) \
181 delete baseType::argNames##ConstructorTablePtr_; \
182 baseType::argNames##ConstructorTablePtr_ = NULL; \
189 #define defineRunTimeSelectionTablePtr\
190 (baseType,argNames) \
193 baseType::argNames##ConstructorTable* \
194 baseType::argNames##ConstructorTablePtr_ = NULL
198 #define defineTemplateRunTimeSelectionTablePtr(baseType,argNames) \
201 typename baseType::argNames##ConstructorTable* \
202 baseType::argNames##ConstructorTablePtr_ = NULL
211 #define defineRunTimeSelectionTable\
212 (baseType,argNames) \
214 defineRunTimeSelectionTablePtr(baseType,argNames); \
215 defineRunTimeSelectionTableConstructor(baseType,argNames); \
216 defineRunTimeSelectionTableDestructor(baseType,argNames)
223 #define defineTemplateRunTimeSelectionTable\
224 (baseType,argNames) \
227 defineRunTimeSelectionTablePtr(baseType,argNames); \
229 defineRunTimeSelectionTableConstructor(baseType,argNames); \
231 defineRunTimeSelectionTableDestructor(baseType,argNames)
240 #define defineTemplatedRunTimeSelectionTableConstructor\
241 (baseType,argNames,Targ) \
244 void baseType< Targ >::construct##argNames##ConstructorTables() \
246 static bool constructed = false; \
250 baseType< Targ >::argNames##ConstructorTablePtr_ \
251 = new baseType< Targ >::argNames##ConstructorTable; \
253 constructed = true; \
261 #define defineTemplatedRunTimeSelectionTableDestructor\
262 (baseType,argNames,Targ) \
265 void baseType< Targ >::destroy##argNames##ConstructorTables() \
267 if (baseType< Targ >::argNames##ConstructorTablePtr_) \
269 delete baseType< Targ >::argNames##ConstructorTablePtr_; \
270 baseType< Targ >::argNames##ConstructorTablePtr_ = NULL; \
278 #define defineTemplatedRunTimeSelectionTablePtr\
279 (baseType,argNames,Targ) \
282 baseType< Targ >::argNames##ConstructorTable* \
283 baseType< Targ >::argNames##ConstructorTablePtr_ = NULL
290 #define defineTemplatedRunTimeSelectionTable\
291 (baseType,argNames,Targ) \
294 defineTemplatedRunTimeSelectionTablePtr(baseType,argNames,Targ); \
296 defineTemplatedRunTimeSelectionTableConstructor(baseType,argNames,Targ); \
298 defineTemplatedRunTimeSelectionTableDestructor(baseType,argNames,Targ)