OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

className.H

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software; you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by the
00013     Free Software Foundation; either version 2 of the License, or (at your
00014     option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM; if not, write to the Free Software Foundation,
00023     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00024 
00025 Description
00026     Macro definitions for declaring ClassName(), NamespaceName(), etc.
00027 
00028 \*---------------------------------------------------------------------------*/
00029 
00030 #ifndef className_H
00031 #define className_H
00032 
00033 #include "word.H"
00034 #include "debug.H"
00035 
00036 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00037 
00038 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00039 // declarations (without debug information)
00040 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00041 
00042 
00043 //- Add typeName information from argument @a TypeNameString to a class.
00044 //  Without debug information
00045 #define ClassNameNoDebug(TypeNameString)                                      \
00046     static const char* typeName_() { return TypeNameString; }                 \
00047     static const ::Foam::word typeName
00048 
00049 //- Add typeName information from argument @a TypeNameString to a namespace.
00050 //  Without debug information.
00051 #define NamespaceNameNoDebug(TypeNameString)                                  \
00052     inline const char* typeName_() { return TypeNameString; }                 \
00053     extern const ::Foam::word typeName
00054 
00055 //- Add typeName information from argument @a TemplateNameString to a template class.
00056 //  Without debug information.
00057 #define TemplateNameNoDebug(TemplateNameString)                               \
00058 class TemplateNameString##Name                                                \
00059 {                                                                             \
00060 public:                                                                       \
00061     TemplateNameString##Name() {}                                             \
00062     ClassNameNoDebug(#TemplateNameString);                                    \
00063 }
00064 
00065 
00066 
00067 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00068 // declarations (with debug information)
00069 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00070 
00071 
00072 //- Add typeName information from argument @a TypeNameString to a class.
00073 //  Also declares debug information.
00074 #define ClassName(TypeNameString)                                             \
00075     ClassNameNoDebug(TypeNameString);                                         \
00076     static int debug
00077 
00078 //- Add typeName information from argument @a TypeNameString to a namespace.
00079 //  Also declares debug information.
00080 #define NamespaceName(TypeNameString)                                         \
00081     NamespaceNameNoDebug(TypeNameString);                                     \
00082     extern int debug
00083 
00084 //- Add typeName information from argument @a TypeNameString to a template class.
00085 //  Also declares debug information.
00086 #define TemplateName(TemplateNameString)                                      \
00087 class TemplateNameString##Name                                                \
00088 {                                                                             \
00089 public:                                                                       \
00090     TemplateNameString##Name() {}                                             \
00091     ClassName(#TemplateNameString);                                           \
00092 }
00093 
00094 
00095 
00096 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00097 // definitions (without debug information)
00098 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00099 
00100 
00101 //- Define the typeName, with alternative lookup as @a Name
00102 #define defineTypeNameWithName(Type, Name)                                    \
00103     const ::Foam::word Type::typeName(Name)
00104 
00105 //- Define the typeName
00106 #define defineTypeName(Type)                                                  \
00107     defineTypeNameWithName(Type, Type::typeName_())
00108 
00109 #ifdef __INTEL_COMPILER
00110 //- Define the typeName as @a Name for template classes
00111 # define defineTemplateTypeNameWithName(Type, Name)                           \
00112     defineTypeNameWithName(Type, Name)
00113 #else
00114 //- Define the typeName as @a Name for template classes
00115 # define defineTemplateTypeNameWithName(Type, Name)                           \
00116     template<>                                                                \
00117     defineTypeNameWithName(Type, Name)
00118 #endif
00119 
00120 //- Define the typeName for template classes, useful with typedefs
00121 #define defineTemplateTypeName(Type)                                          \
00122     defineTemplateTypeNameWithName(Type, #Type)
00123 
00124 //- Define the typeName directly for template classes
00125 #define defineNamedTemplateTypeName(Type)                                     \
00126     defineTemplateTypeNameWithName(Type, Type::typeName_())
00127 
00128 
00129 
00130 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00131 // definitions (debug information only)
00132 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00133 
00134 
00135 //- Define the debug information, lookup as @a Name
00136 #define defineDebugSwitchWithName(Type, Name, DebugSwitch)                    \
00137     int Type::debug(::Foam::debug::debugSwitch(Name, DebugSwitch))
00138 
00139 //- Define the debug information
00140 #define defineDebugSwitch(Type, DebugSwitch)                                  \
00141     defineDebugSwitchWithName(Type, Type::typeName_(), DebugSwitch)
00142 
00143 #ifdef __INTEL_COMPILER
00144 //- Define the debug information for templates, lookup as @a Name
00145 # define defineTemplateDebugSwitchWithName(Type, Name, DebugSwitch)           \
00146     defineDebugSwitchWithName(Type, Name, DebugSwitch)
00147 #else
00148 //- Define the debug information for templates, lookup as @a Name
00149 # define defineTemplateDebugSwitchWithName(Type, Name, DebugSwitch)           \
00150     template<>                                                                \
00151     defineDebugSwitchWithName(Type, Name, DebugSwitch)
00152 #endif
00153 
00154 //- Define the debug information for templates
00155 //  Useful with typedefs
00156 #define defineTemplateDebugSwitch(Type, DebugSwitch)                          \
00157     defineTemplateDebugSwitchWithName(Type, #Type, DebugSwitch)
00158 
00159 //- Define the debug information directly for templates
00160 #define defineNamedTemplateDebugSwitch(Type, DebugSwitch)                     \
00161     defineTemplateDebugSwitchWithName(Type, Type::typeName_(), DebugSwitch)
00162 
00163 
00164 
00165 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00166 // definitions (with debug information)
00167 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00168 
00169 
00170 //- Define the typeName and debug information
00171 #define defineTypeNameAndDebug(Type, DebugSwitch)                             \
00172     defineTypeName(Type);                                                     \
00173     defineDebugSwitch(Type, DebugSwitch)
00174 
00175 //- Define the typeName and debug information, lookup as @a Name
00176 #define defineTemplateTypeNameAndDebugWithName(Type, Name, DebugSwitch)       \
00177     defineTemplateTypeNameWithName(Type, Name);                               \
00178     defineTemplateDebugSwitchWithName(Type, Name, DebugSwitch)
00179 
00180 //- Define the typeName and debug information for templates, useful with typedefs
00181 #define defineTemplateTypeNameAndDebug(Type, DebugSwitch)                     \
00182     defineTemplateTypeNameAndDebugWithName(Type, #Type, DebugSwitch)
00183 
00184 //- Define the typeName and debug information for templates
00185 #define defineNamedTemplateTypeNameAndDebug(Type, DebugSwitch)                \
00186     defineNamedTemplateTypeName(Type);                                        \
00187     defineNamedTemplateDebugSwitch(Type, DebugSwitch)
00188 
00189 
00190 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00191 
00192 #endif
00193 
00194 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd