addToRunTimeSelectionTable.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 Description
25  Macros for easy insertion into run-time selection tables
26 
27 \*---------------------------------------------------------------------------*/
28 
29 #ifndef addToRunTimeSelectionTable_H
30 #define addToRunTimeSelectionTable_H
31 
32 #include "macros.H"
33 
34 namespace Foam
35 {
36  class word;
37 
39  (
40  const char* baseType,
41  const char* baseTypeName,
42  const word& thisTypeName,
43  const char* libName
44  );
45 }
46 
47 
48 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
49 
50 //- Add to hash-table of functions with typename as the key
51 #define addToRunTimeSelectionTable\
52 (baseType,thisType,argNames) \
53  \
54  /* Add the thisType constructor function to the table */ \
55  baseType::add##argNames##ConstructorToTable<thisType> \
56  add##thisType##argNames##ConstructorTo##baseType##Table_; \
57  \
58  bool add##thisType##argNames##To##baseType##ToC_ = \
59  addToRunTimeSelectionTableToC \
60  (#baseType, baseType::typeName_(), thisType::typeName, STR(LIB_NAME))
61 
62 
63 //- Add to hash-table of functions with 'lookup' as the key
64 #define addNamedToRunTimeSelectionTable\
65 (baseType,thisType,argNames,lookup) \
66  \
67  /* Add the thisType constructor function to the table, find by lookup */ \
68  baseType::add##argNames##ConstructorToTable<thisType> \
69  add_##lookup##_##thisType##argNames##ConstructorTo##baseType##Table_ \
70  (#lookup); \
71  \
72  bool add_##lookup##_##thisType##argNames##To##baseType##ToC_ = \
73  addToRunTimeSelectionTableToC \
74  (#baseType, baseType::typeName_(), #lookup, STR(LIB_NAME))
75 
76 
77 //- Add backward-compatibility duplicate of thisType, replacing oldType,
78 // to hash-table of functions with 'lookup' as the key
79 #define addBackwardCompatibleToRunTimeSelectionTable\
80 (baseType,thisType,argNames,oldType,lookup) \
81  \
82  /* Add the thisType constructor function to the table, find by lookup */ \
83  baseType::add##argNames##ConstructorToTable<thisType> \
84  add_##oldType##_##thisType##argNames##ConstructorTo##baseType##Table_ \
85  (lookup);
86 
87 
88 //- Add to hash-table of functions with typename as the key
89 #define addRemovableToRunTimeSelectionTable\
90 (baseType,thisType,argNames) \
91  \
92  /* Add the thisType constructor function to the table */ \
93  baseType::addRemovable##argNames##ConstructorToTable<thisType> \
94  addRemovable##thisType##argNames##ConstructorTo##baseType##Table_; \
95  \
96  bool addRemovable##thisType##argNames##To##baseType##ToC_ = \
97  addToRunTimeSelectionTableToC \
98  (#baseType, baseType::typeName_(), thisType::typeName, STR(LIB_NAME))
99 
100 
101 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
102 
103 //- Add to hash-table of functions with typename as the key.
104 // Use when baseType requires the Targ template argument as well
105 #define addTemplatedToRunTimeSelectionTable\
106 (baseType,thisType,Targ,argNames) \
107  \
108  /* Add the thisType constructor function to the table */ \
109  baseType<Targ>::add##argNames##ConstructorToTable<thisType<Targ>> \
110  add##thisType##Targ##argNames##ConstructorTo##baseType##Targ##Table_; \
111  \
112  bool add##thisType##Targ##argNames##To##baseType##Targ##ToC_ = \
113  addToRunTimeSelectionTableToC \
114  ( \
115  #baseType, \
116  baseType<Targ>::typeName_(), \
117  thisType<Targ>::typeName, \
118  STR(LIB_NAME) \
119  )
120 
121 
122 //- Add to hash-table of functions with 'lookup' as the key.
123 // Use when baseType requires the Targ template argument as well
124 #define addNamedTemplatedToRunTimeSelectionTable\
125 (baseType,thisType,Targ,argNames,lookup) \
126  \
127  /* Add the thisType constructor function to the table, find by lookup */ \
128  baseType<Targ>::add##argNames##ConstructorToTable<thisType<Targ>> \
129  add_##lookup##_##thisType##Targ##argNames##ConstructorTo##baseType## \
130  Targ##Table_(#lookup); \
131  \
132  bool add_##lookup##_##thisType##Targ##argNames##To##baseType##Targ##ToC_ = \
133  addToRunTimeSelectionTableToC \
134  (#baseType, baseType<Targ>::typeName_(), #lookup, STR(LIB_NAME))
135 
136 
137 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
138 
139 #endif
140 
141 // ************************************************************************* //
General C-preprocessor macros.
Namespace for OpenFOAM.
bool addToRunTimeSelectionTableToC(const char *baseType, const char *baseTypeName, const word &thisTypeName, const char *libName)