className.H
Go to the documentation of this file.
1/*---------------------------------------------------------------------------*\
2 ========= |
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4 \\ / O peration |
5 \\ / A nd | www.openfoam.com
6 \\/ M anipulation |
7-------------------------------------------------------------------------------
8 Copyright (C) 2011-2016 OpenFOAM Foundation
9-------------------------------------------------------------------------------
10License
11 This file is part of OpenFOAM.
12
13 OpenFOAM is free software: you can redistribute it and/or modify it
14 under the terms of the GNU General Public License as published by
15 the Free Software Foundation, either version 3 of the License, or
16 (at your option) any later version.
17
18 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 for more details.
22
23 You should have received a copy of the GNU General Public License
24 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25
26Description
27 Macro definitions for declaring ClassName(), NamespaceName(), etc.
28
29\*---------------------------------------------------------------------------*/
30
31#ifndef className_H
32#define className_H
33
34#include "defineDebugSwitch.H"
35
36// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
37// Declarations (without debug information)
38
39//- Add typeName information from argument \a TypeNameString to a class.
40// Without debug information
41#define ClassNameNoDebug(TypeNameString) \
42 static const char* typeName_() { return TypeNameString; } \
43 static const ::Foam::word typeName
44
45//- Add typeName information from argument \a TypeNameString to a namespace.
46// Without debug information.
47#define NamespaceNameNoDebug(TypeNameString) \
48 inline const char* typeName_() { return TypeNameString; } \
49 extern const ::Foam::word typeName
50
51//- Add typeName information from argument \a TemplateNameString to a
52// template class. Without debug information.
53#define TemplateNameNoDebug(TemplateNameString) \
54class TemplateNameString##Name \
55{ \
56public: \
57 TemplateNameString##Name() {} \
58 ClassNameNoDebug(#TemplateNameString); \
59}
60
61
62// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
63// Declarations (with debug information)
64
65//- Add typeName information from argument \a TypeNameString to a class.
66// Also declares debug information.
67#define ClassName(TypeNameString) \
68 ClassNameNoDebug(TypeNameString); \
69 static int debug
70
71//- Add typeName information from argument \a TypeNameString to a namespace.
72// Also declares debug information.
73#define NamespaceName(TypeNameString) \
74 NamespaceNameNoDebug(TypeNameString); \
75 extern int debug
76
77//- Add typeName information from argument \a TypeNameString to a
78// template class. Also declares debug information.
79#define TemplateName(TemplateNameString) \
80class TemplateNameString##Name \
81{ \
82public: \
83 TemplateNameString##Name() {} \
84 ClassName(#TemplateNameString); \
85}
86
87
88// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
89// Definitions (without debug information)
90
91//- Define the typeName, with alternative lookup as \a Name
92#define defineTypeNameWithName(Type, Name) \
93 const ::Foam::word Type::typeName(Name)
94
95//- Define the typeName
96#define defineTypeName(Type) \
97 defineTypeNameWithName(Type, Type::typeName_())
98
99//- Define the typeName as \a Name for template classes
100#define defineTemplateTypeNameWithName(Type, Name) \
101 template<> \
102 defineTypeNameWithName(Type, Name)
103//- Define the typeName as \a Name for template sub-classes
104#define defineTemplate2TypeNameWithName(Type, Name) \
105 template<> \
106 defineTypeNameWithName(Type, Name)
107
108//- Define the typeName for template classes, useful with typedefs
109#define defineTemplateTypeName(Type) \
110 defineTemplateTypeNameWithName(Type, #Type)
111
112//- Define the typeName directly for template classes
113#define defineNamedTemplateTypeName(Type) \
114 defineTemplateTypeNameWithName(Type, Type::typeName_())
115
116
117// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
118// Definitions (with debug information)
119
120//- Define the typeName and debug information
121#define defineTypeNameAndDebug(Type, DebugSwitch) \
122 defineTypeName(Type); \
123 defineDebugSwitch(Type, DebugSwitch)
124
125//- Define the typeName and debug information, lookup as \a Name
126#define defineTemplateTypeNameAndDebugWithName(Type, Name, DebugSwitch) \
127 defineTemplateTypeNameWithName(Type, Name); \
128 defineTemplateDebugSwitchWithName(Type, Name, DebugSwitch)
129
130//- Define the typeName and debug information for templates, useful
131// with typedefs
132#define defineTemplateTypeNameAndDebug(Type, DebugSwitch) \
133 defineTemplateTypeNameAndDebugWithName(Type, #Type, DebugSwitch)
134
135//- Define the typeName and debug information for templates
136#define defineNamedTemplateTypeNameAndDebug(Type, DebugSwitch) \
137 defineNamedTemplateTypeName(Type); \
138 defineNamedTemplateDebugSwitch(Type, DebugSwitch)
139
140
141// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
142// For templated sub-classes
143
144//- Define the typeName and debug information, lookup as \a Name
145#define defineTemplate2TypeNameAndDebugWithName(Type, Name, DebugSwitch) \
146 defineTemplate2TypeNameWithName(Type, Name); \
147 defineTemplate2DebugSwitchWithName(Type, Name, DebugSwitch)
148
149//- Define the typeName and debug information for templates, useful
150// with typedefs
151#define defineTemplate2TypeNameAndDebug(Type, DebugSwitch) \
152 defineTemplate2TypeNameAndDebugWithName(Type, #Type, DebugSwitch)
153
154
155// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
156
157#endif
158
159// ************************************************************************* //
#define TemplateName(TemplateNameString)
Add typeName information from argument TypeNameString to a.
Definition: className.H:79
#define ClassNameNoDebug(TypeNameString)
Add typeName information from argument TypeNameString to a class.
Definition: className.H:41
#define NamespaceNameNoDebug(TypeNameString)
Add typeName information from argument TypeNameString to a namespace.
Definition: className.H:47
#define NamespaceName(TypeNameString)
Add typeName information from argument TypeNameString to a namespace.
Definition: className.H:73
#define TemplateNameNoDebug(TemplateNameString)
Add typeName information from argument TemplateNameString to a.
Definition: className.H:53
#define defineTemplateTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information for templates, useful.
Definition: className.H:132
#define ClassName(TypeNameString)
Add typeName information from argument TypeNameString to a class.
Definition: className.H:67
#define defineTemplate2TypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information for templates, useful.
Definition: className.H:151
Macro definitions for debug switches.
int debug
Static debugging option.