1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | foam-extend: Open Source CFD
4 \\ / O peration | Version: 3.2
5 \\ / A nd | Web: http://www.foam-extend.org
6 \\/ M anipulation | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
9 This file is part of foam-extend.
11 foam-extend is free software: you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by the
13 Free Software Foundation, either version 3 of the License, or (at your
14 option) any later version.
16 foam-extend is distributed in the hope that it will be useful, but
17 WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
25 Macro definitions for declaring ClassName(), NamespaceName(), etc.
27 \*---------------------------------------------------------------------------*/
34 #include "debugSwitch.H"
36 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
38 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
39 // declarations (without debug information)
40 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
43 //- Add typeName information from argument @a TypeNameString to a class.
44 // Without debug information
45 #define ClassNameNoDebug(TypeNameString) \
46 static const char* typeName_() { return TypeNameString; } \
47 static const ::Foam::word typeName
49 //- Add typeName information from argument @a TypeNameString to a namespace.
50 // Without debug information.
51 #define NamespaceNameNoDebug(TypeNameString) \
52 inline const char* typeName_() { return TypeNameString; } \
53 extern const ::Foam::word typeName
55 //- Add typeName information from argument @a TemplateNameString to a template class.
56 // Without debug information.
57 #define TemplateNameNoDebug(TemplateNameString) \
58 class TemplateNameString##Name \
61 TemplateNameString##Name() {} \
62 ClassNameNoDebug(#TemplateNameString); \
67 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
68 // declarations (with debug information)
69 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
72 //- Add typeName information from argument @a TypeNameString to a class.
73 // Also declares debug information.
74 #define ClassName(TypeNameString) \
75 ClassNameNoDebug(TypeNameString); \
76 static Foam::debug::debugSwitch debug;
78 //- Add typeName information from argument @a TypeNameString to a namespace.
79 // Also declares debug information.
80 #define NamespaceName(TypeNameString) \
81 NamespaceNameNoDebug(TypeNameString); \
82 extern Foam::debug::debugSwitch debug;
84 //- Add typeName information from argument @a TypeNameString to a template class.
85 // Also declares debug information.
86 #define TemplateName(TemplateNameString) \
87 class TemplateNameString##Name \
90 TemplateNameString##Name() {} \
91 ClassName(#TemplateNameString); \
96 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
97 // definitions (without debug information)
98 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
101 //- Define the typeName, with alternative lookup as @a Name
102 #define defineTypeNameWithName(Type, Name) \
103 const ::Foam::word Type::typeName(Name)
105 //- Define the typeName
106 #define defineTypeName(Type) \
107 defineTypeNameWithName(Type, Type::typeName_())
109 #ifdef __INTEL_COMPILER
110 //- Define the typeName as @a Name for template classes
111 # define defineTemplateTypeNameWithName(Type, Name) \
112 defineTypeNameWithName(Type, Name)
114 //- Define the typeName as @a Name for template classes
115 # define defineTemplateTypeNameWithName(Type, Name) \
117 defineTypeNameWithName(Type, Name)
120 //- Define the typeName for template classes, useful with typedefs
121 #define defineTemplateTypeName(Type) \
122 defineTemplateTypeNameWithName(Type, #Type)
124 //- Define the typeName directly for template classes
125 #define defineNamedTemplateTypeName(Type) \
126 defineTemplateTypeNameWithName(Type, Type::typeName_())
130 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
131 // definitions (debug information only)
132 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
135 //- Define the debug information, lookup as @a Name
136 #define defineDebugSwitchWithName(Type, Name, DebugSwitch, SwitchDescr) \
137 ::Foam::debug::debugSwitch \
138 Type::debug(std::string(Name), DebugSwitch, SwitchDescr)
140 //- Define the debug information
141 #define defineDebugSwitch(Type, DebugSwitch, SwitchDescr) \
142 defineDebugSwitchWithName(Type, Type::typeName_(), DebugSwitch, SwitchDescr);
144 #ifdef __INTEL_COMPILER
145 //- Define the debug information for templates, lookup as @a Name
146 # define defineTemplateDebugSwitchWithName(Type, Name, DebugSwitch) \
147 defineDebugSwitchWithName(Type, Name, DebugSwitch, "");
150 //- Define the debug information for templates, lookup as @a Name
151 # define defineTemplateDebugSwitchWithName(Type, Name, DebugSwitch) \
153 defineDebugSwitchWithName(Type, Name, DebugSwitch, "");
156 //- Define the debug information for templates
157 // Useful with typedefs
158 #define defineTemplateDebugSwitch(Type, DebugSwitch) \
159 defineTemplateDebugSwitchWithName(Type, #Type, DebugSwitch)
161 //- Define the debug information directly for templates
162 #define defineNamedTemplateDebugSwitch(Type, DebugSwitch) \
163 defineTemplateDebugSwitchWithName(Type, Type::typeName_(), DebugSwitch)
167 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
168 // definitions (with debug information)
169 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
172 //- Define the typeName and debug information
173 #define defineTypeNameAndDebug(Type, DebugSwitch) \
174 defineTypeName(Type); \
175 defineDebugSwitch(Type, DebugSwitch, "")
177 //- Define the typeName and debug information + description
178 #define defineTypeNameAndDebugWithDescription(Type, DebugSwitch, SwitchDescr) \
179 defineTypeName(Type); \
180 defineDebugSwitch(Type, DebugSwitch, SwitchDescr)
182 //- Define the typeName and debug information, lookup as @a Name
183 #define defineTemplateTypeNameAndDebugWithName(Type, Name, DebugSwitch) \
184 defineTemplateTypeNameWithName(Type, Name); \
185 defineTemplateDebugSwitchWithName(Type, Name, DebugSwitch)
187 //- Define the typeName and debug information for templates, useful with typedefs
188 #define defineTemplateTypeNameAndDebug(Type, DebugSwitch) \
189 defineTemplateTypeNameAndDebugWithName(Type, #Type, DebugSwitch)
191 //- Define the typeName and debug information for templates
192 #define defineNamedTemplateTypeNameAndDebug(Type, DebugSwitch) \
193 defineNamedTemplateTypeName(Type); \
194 defineNamedTemplateDebugSwitch(Type, DebugSwitch)
197 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
201 // ************************************************************************* //