1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd.
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
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.
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
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/>.
25 Macro definitions for declaring ClassName(), NamespaceName(), etc.
27 \*---------------------------------------------------------------------------*/
35 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
37 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
38 // declarations (without debug information)
39 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
42 //- Add typeName information from argument \a TypeNameString to a class.
43 // Without debug information
44 #define ClassNameNoDebug(TypeNameString) \
45 static const char* typeName_() { return TypeNameString; } \
46 static const ::Foam::word typeName
48 //- Add typeName information from argument \a TypeNameString to a namespace.
49 // Without debug information.
50 #define NamespaceNameNoDebug(TypeNameString) \
51 inline const char* typeName_() { return TypeNameString; } \
52 extern const ::Foam::word typeName
54 //- Add typeName information from argument \a TemplateNameString to a
55 // template class. Without debug information.
56 #define TemplateNameNoDebug(TemplateNameString) \
57 class TemplateNameString##Name \
60 TemplateNameString##Name() {} \
61 ClassNameNoDebug(#TemplateNameString); \
66 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
67 // declarations (with debug information)
68 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
71 //- Add typeName information from argument \a TypeNameString to a class.
72 // Also declares debug information.
73 #define ClassName(TypeNameString) \
74 ClassNameNoDebug(TypeNameString); \
77 //- Add typeName information from argument \a TypeNameString to a namespace.
78 // Also declares debug information.
79 #define NamespaceName(TypeNameString) \
80 NamespaceNameNoDebug(TypeNameString); \
83 //- Add typeName information from argument \a TypeNameString to a
84 // template class. Also declares debug information.
85 #define TemplateName(TemplateNameString) \
86 class TemplateNameString##Name \
89 TemplateNameString##Name() {} \
90 ClassName(#TemplateNameString); \
95 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
96 // definitions (without debug information)
97 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
100 //- Define the typeName, with alternative lookup as \a Name
101 #define defineTypeNameWithName(Type, Name) \
102 const ::Foam::word Type::typeName(Name)
104 //- Define the typeName
105 #define defineTypeName(Type) \
106 defineTypeNameWithName(Type, Type::typeName_())
108 #ifdef __INTEL_COMPILER
109 //- Define the typeName as \a Name for template classes
110 # define defineTemplateTypeNameWithName(Type, Name) \
111 defineTypeNameWithName(Type, Name)
112 //- Define the typeName as \a Name for template sub-classes
113 # define defineTemplate2TypeNameWithName(Type, Name) \
114 defineTypeNameWithName(Type, Name)
116 //- Define the typeName as \a Name for template classes
117 # define defineTemplateTypeNameWithName(Type, Name) \
119 defineTypeNameWithName(Type, Name)
120 //- Define the typeName as \a Name for template sub-classes
121 # define defineTemplate2TypeNameWithName(Type, Name) \
124 defineTypeNameWithName(Type, Name)
127 //- Define the typeName for template classes, useful with typedefs
128 #define defineTemplateTypeName(Type) \
129 defineTemplateTypeNameWithName(Type, #Type)
131 //- Define the typeName directly for template classes
132 #define defineNamedTemplateTypeName(Type) \
133 defineTemplateTypeNameWithName(Type, Type::typeName_())
137 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
138 // definitions (debug information only)
139 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
142 //- Define the debug information, lookup as \a Name
143 #define defineDebugSwitchWithName(Type, Name, DebugSwitch) \
144 int Type::debug(::Foam::debug::debugSwitch(Name, DebugSwitch))
146 //- Define the debug information
147 #define defineDebugSwitch(Type, DebugSwitch) \
148 defineDebugSwitchWithName(Type, Type::typeName_(), DebugSwitch)
150 #ifdef __INTEL_COMPILER
151 //- Define the debug information for templates, lookup as \a Name
152 # define defineTemplateDebugSwitchWithName(Type, Name, DebugSwitch) \
153 defineDebugSwitchWithName(Type, Name, DebugSwitch)
154 //- Define the debug information for templates sub-classes, lookup as \a Name
155 # define defineTemplate2DebugSwitchWithName(Type, Name, DebugSwitch) \
156 defineDebugSwitchWithName(Type, Name, DebugSwitch)
158 //- Define the debug information for templates, lookup as \a Name
159 # define defineTemplateDebugSwitchWithName(Type, Name, DebugSwitch) \
161 defineDebugSwitchWithName(Type, Name, DebugSwitch)
162 //- Define the debug information for templates sub-classes, lookup as \a Name
163 # define defineTemplate2DebugSwitchWithName(Type, Name, DebugSwitch) \
166 defineDebugSwitchWithName(Type, Name, DebugSwitch)
169 //- Define the debug information for templates
170 // Useful with typedefs
171 #define defineTemplateDebugSwitch(Type, DebugSwitch) \
172 defineTemplateDebugSwitchWithName(Type, #Type, DebugSwitch)
174 //- Define the debug information directly for templates
175 #define defineNamedTemplateDebugSwitch(Type, DebugSwitch) \
176 defineTemplateDebugSwitchWithName(Type, Type::typeName_(), DebugSwitch)
179 // for templated sub-classes
181 //- Define the debug information for templates
182 // Useful with typedefs
183 #define defineTemplate2DebugSwitch(Type, DebugSwitch) \
184 defineTemplate2DebugSwitchWithName(Type, #Type, DebugSwitch)
186 //- Define the debug information directly for templates
187 #define defineNamedTemplate2DebugSwitch(Type, DebugSwitch) \
188 defineTemplate2DebugSwitchWithName(Type, Type::typeName_(), DebugSwitch)
192 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
193 // definitions (with debug information)
194 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
197 //- Define the typeName and debug information
198 #define defineTypeNameAndDebug(Type, DebugSwitch) \
199 defineTypeName(Type); \
200 defineDebugSwitch(Type, DebugSwitch)
202 //- Define the typeName and debug information, lookup as \a Name
203 #define defineTemplateTypeNameAndDebugWithName(Type, Name, DebugSwitch) \
204 defineTemplateTypeNameWithName(Type, Name); \
205 defineTemplateDebugSwitchWithName(Type, Name, DebugSwitch)
207 //- Define the typeName and debug information for templates, useful
209 #define defineTemplateTypeNameAndDebug(Type, DebugSwitch) \
210 defineTemplateTypeNameAndDebugWithName(Type, #Type, DebugSwitch)
212 //- Define the typeName and debug information for templates
213 #define defineNamedTemplateTypeNameAndDebug(Type, DebugSwitch) \
214 defineNamedTemplateTypeName(Type); \
215 defineNamedTemplateDebugSwitch(Type, DebugSwitch)
217 // for templated sub-classes
219 //- Define the typeName and debug information, lookup as \a Name
220 #define defineTemplate2TypeNameAndDebugWithName(Type, Name, DebugSwitch) \
221 defineTemplate2TypeNameWithName(Type, Name); \
222 defineTemplate2DebugSwitchWithName(Type, Name, DebugSwitch)
224 //- Define the typeName and debug information for templates, useful
226 #define defineTemplate2TypeNameAndDebug(Type, DebugSwitch) \
227 defineTemplate2TypeNameAndDebugWithName(Type, #Type, DebugSwitch)
231 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
235 // ************************************************************************* //