1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
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) \
123 defineTypeNameWithName(Type, Name)
126 //- Define the typeName for template classes, useful with typedefs
127 #define defineTemplateTypeName(Type) \
128 defineTemplateTypeNameWithName(Type, #Type)
130 //- Define the typeName directly for template classes
131 #define defineNamedTemplateTypeName(Type) \
132 defineTemplateTypeNameWithName(Type, Type::typeName_())
136 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
137 // definitions (debug information only)
138 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
141 //- Define the debug information, lookup as \a Name
142 #define defineDebugSwitchWithName(Type, Name, DebugSwitch) \
143 int Type::debug(::Foam::debug::debugSwitch(Name, DebugSwitch))
145 //- Define the debug information
146 #define defineDebugSwitch(Type, DebugSwitch) \
147 defineDebugSwitchWithName(Type, Type::typeName_(), DebugSwitch)
149 #ifdef __INTEL_COMPILER
150 //- Define the debug information for templates, lookup as \a Name
151 # define defineTemplateDebugSwitchWithName(Type, Name, DebugSwitch) \
152 defineDebugSwitchWithName(Type, Name, DebugSwitch)
153 //- Define the debug information for templates sub-classes, lookup as \a Name
154 # define defineTemplate2DebugSwitchWithName(Type, Name, DebugSwitch) \
155 defineDebugSwitchWithName(Type, Name, DebugSwitch)
157 //- Define the debug information for templates, lookup as \a Name
158 # define defineTemplateDebugSwitchWithName(Type, Name, DebugSwitch) \
160 defineDebugSwitchWithName(Type, Name, DebugSwitch)
161 //- Define the debug information for templates sub-classes, lookup as \a Name
162 # define defineTemplate2DebugSwitchWithName(Type, Name, DebugSwitch) \
164 defineDebugSwitchWithName(Type, Name, DebugSwitch)
167 //- Define the debug information for templates
168 // Useful with typedefs
169 #define defineTemplateDebugSwitch(Type, DebugSwitch) \
170 defineTemplateDebugSwitchWithName(Type, #Type, DebugSwitch)
172 //- Define the debug information directly for templates
173 #define defineNamedTemplateDebugSwitch(Type, DebugSwitch) \
174 defineTemplateDebugSwitchWithName(Type, Type::typeName_(), DebugSwitch)
177 // for templated sub-classes
179 //- Define the debug information for templates
180 // Useful with typedefs
181 #define defineTemplate2DebugSwitch(Type, DebugSwitch) \
182 defineTemplate2DebugSwitchWithName(Type, #Type, DebugSwitch)
184 //- Define the debug information directly for templates
185 #define defineNamedTemplate2DebugSwitch(Type, DebugSwitch) \
186 defineTemplate2DebugSwitchWithName(Type, Type::typeName_(), DebugSwitch)
190 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
191 // definitions (with debug information)
192 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
195 //- Define the typeName and debug information
196 #define defineTypeNameAndDebug(Type, DebugSwitch) \
197 defineTypeName(Type); \
198 defineDebugSwitch(Type, DebugSwitch)
200 //- Define the typeName and debug information, lookup as \a Name
201 #define defineTemplateTypeNameAndDebugWithName(Type, Name, DebugSwitch) \
202 defineTemplateTypeNameWithName(Type, Name); \
203 defineTemplateDebugSwitchWithName(Type, Name, DebugSwitch)
205 //- Define the typeName and debug information for templates, useful
207 #define defineTemplateTypeNameAndDebug(Type, DebugSwitch) \
208 defineTemplateTypeNameAndDebugWithName(Type, #Type, DebugSwitch)
210 //- Define the typeName and debug information for templates
211 #define defineNamedTemplateTypeNameAndDebug(Type, DebugSwitch) \
212 defineNamedTemplateTypeName(Type); \
213 defineNamedTemplateDebugSwitch(Type, DebugSwitch)
215 // for templated sub-classes
217 //- Define the typeName and debug information, lookup as \a Name
218 #define defineTemplate2TypeNameAndDebugWithName(Type, Name, DebugSwitch) \
219 defineTemplate2TypeNameWithName(Type, Name); \
220 defineTemplate2DebugSwitchWithName(Type, Name, DebugSwitch)
222 //- Define the typeName and debug information for templates, useful
224 #define defineTemplate2TypeNameAndDebug(Type, DebugSwitch) \
225 defineTemplate2TypeNameAndDebugWithName(Type, #Type, DebugSwitch)
229 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
233 // ************************************************************************* //