1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2009 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 the
13 Free Software Foundation; either version 2 of the License, or (at your
14 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, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
26 Macro definitions for declaring ClassName(), NamespaceName(), etc.
28 \*---------------------------------------------------------------------------*/
33 #include <OpenFOAM/word.H>
34 #include <OpenFOAM/debug.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); \
78 //- Add typeName information from argument @a TypeNameString to a namespace.
79 // Also declares debug information.
80 #define NamespaceName(TypeNameString) \
81 NamespaceNameNoDebug(TypeNameString); \
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) \
137 int Type::debug(::Foam::debug::debugSwitch(Name, DebugSwitch))
139 //- Define the debug information
140 #define defineDebugSwitch(Type, DebugSwitch) \
141 defineDebugSwitchWithName(Type, Type::typeName_(), DebugSwitch)
143 #ifdef __INTEL_COMPILER
144 //- Define the debug information for templates, lookup as @a Name
145 # define defineTemplateDebugSwitchWithName(Type, Name, DebugSwitch) \
146 defineDebugSwitchWithName(Type, Name, DebugSwitch)
148 //- Define the debug information for templates, lookup as @a Name
149 # define defineTemplateDebugSwitchWithName(Type, Name, DebugSwitch) \
151 defineDebugSwitchWithName(Type, Name, DebugSwitch)
154 //- Define the debug information for templates
155 // Useful with typedefs
156 #define defineTemplateDebugSwitch(Type, DebugSwitch) \
157 defineTemplateDebugSwitchWithName(Type, #Type, DebugSwitch)
159 //- Define the debug information directly for templates
160 #define defineNamedTemplateDebugSwitch(Type, DebugSwitch) \
161 defineTemplateDebugSwitchWithName(Type, Type::typeName_(), DebugSwitch)
165 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
166 // definitions (with debug information)
167 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
170 //- Define the typeName and debug information
171 #define defineTypeNameAndDebug(Type, DebugSwitch) \
172 defineTypeName(Type); \
173 defineDebugSwitch(Type, DebugSwitch)
175 //- Define the typeName and debug information, lookup as @a Name
176 #define defineTemplateTypeNameAndDebugWithName(Type, Name, DebugSwitch) \
177 defineTemplateTypeNameWithName(Type, Name); \
178 defineTemplateDebugSwitchWithName(Type, Name, DebugSwitch)
180 //- Define the typeName and debug information for templates, useful with typedefs
181 #define defineTemplateTypeNameAndDebug(Type, DebugSwitch) \
182 defineTemplateTypeNameAndDebugWithName(Type, #Type, DebugSwitch)
184 //- Define the typeName and debug information for templates
185 #define defineNamedTemplateTypeNameAndDebug(Type, DebugSwitch) \
186 defineNamedTemplateTypeName(Type); \
187 defineNamedTemplateDebugSwitch(Type, DebugSwitch)
190 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
194 // ************************ vim: set sw=4 sts=4 et: ************************ //