FreeFOAM The Cross-Platform CFD Toolkit
Hosted by SourceForge:
Get FreeFOAM at SourceForge.net.
            Fast, secure and Free Open Source software downloads

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-2010 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
00013     the Free Software Foundation, either version 3 of the License, or
00014     (at your 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, see <http://www.gnu.org/licenses/>.
00023 
00024 Description
00025     Macro definitions for declaring ClassName(), NamespaceName(), etc.
00026 
00027 \*---------------------------------------------------------------------------*/
00028 
00029 #ifndef className_H
00030 #define className_H
00031 
00032 #include <OpenFOAM/word.H>
00033 #include <OpenFOAM/debug.H>
00034 
00035 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00036 
00037 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00038 // declarations (without debug information)
00039 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00040 
00041 
00042 //- Add typeName information from argument @a TypeNameString to a class.
00043 //  Without debug information
00044 #define ClassNameNoDebug(TypeNameString)                                      \
00045     static const char* typeName_() { return TypeNameString; }                 \
00046     static const ::Foam::word typeName
00047 
00048 //- Add typeName information from argument @a TypeNameString to a namespace.
00049 //  Without debug information.
00050 #define NamespaceNameNoDebug(TypeNameString)                                  \
00051     inline const char* typeName_() { return TypeNameString; }                 \
00052     extern const ::Foam::word typeName
00053 
00054 //- Add typeName information from argument @a TemplateNameString to a template class.
00055 //  Without debug information.
00056 #define TemplateNameNoDebug(TemplateNameString)                               \
00057 class TemplateNameString##Name                                                \
00058 {                                                                             \
00059 public:                                                                       \
00060     TemplateNameString##Name() {}                                             \
00061     ClassNameNoDebug(#TemplateNameString);                                    \
00062 }
00063 
00064 
00065 
00066 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00067 // declarations (with debug information)
00068 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00069 
00070 
00071 //- Add typeName information from argument @a TypeNameString to a class.
00072 //  Also declares debug information.
00073 #define ClassName(TypeNameString)                                             \
00074     ClassNameNoDebug(TypeNameString);                                         \
00075     static int debug
00076 
00077 //- Add typeName information from argument @a TypeNameString to a namespace.
00078 //  Also declares debug information.
00079 #define NamespaceName(TypeNameString)                                         \
00080     NamespaceNameNoDebug(TypeNameString);                                     \
00081     extern int debug
00082 
00083 //- Add typeName information from argument @a TypeNameString to a template class.
00084 //  Also declares debug information.
00085 #define TemplateName(TemplateNameString)                                      \
00086 class TemplateNameString##Name                                                \
00087 {                                                                             \
00088 public:                                                                       \
00089     TemplateNameString##Name() {}                                             \
00090     ClassName(#TemplateNameString);                                           \
00091 }
00092 
00093 
00094 
00095 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00096 // definitions (without debug information)
00097 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00098 
00099 
00100 //- Define the typeName, with alternative lookup as @a Name
00101 #define defineTypeNameWithName(Type, Name)                                    \
00102     const ::Foam::word Type::typeName(Name)
00103 
00104 //- Define the typeName
00105 #define defineTypeName(Type)                                                  \
00106     defineTypeNameWithName(Type, Type::typeName_())
00107 
00108 #ifdef __INTEL_COMPILER
00109 //- Define the typeName as @a Name for template classes
00110 # define defineTemplateTypeNameWithName(Type, Name)                           \
00111     defineTypeNameWithName(Type, Name)
00112 #else
00113 //- Define the typeName as @a Name for template classes
00114 # define defineTemplateTypeNameWithName(Type, Name)                           \
00115     template<>                                                                \
00116     defineTypeNameWithName(Type, Name)
00117 #endif
00118 
00119 //- Define the typeName for template classes, useful with typedefs
00120 #define defineTemplateTypeName(Type)                                          \
00121     defineTemplateTypeNameWithName(Type, #Type)
00122 
00123 //- Define the typeName directly for template classes
00124 #define defineNamedTemplateTypeName(Type)                                     \
00125     defineTemplateTypeNameWithName(Type, Type::typeName_())
00126 
00127 
00128 
00129 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00130 // definitions (debug information only)
00131 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00132 
00133 
00134 //- Define the debug information, lookup as @a Name
00135 #define defineDebugSwitchWithName(Type, Name, DebugSwitch)                    \
00136     int Type::debug(::Foam::debug::debugSwitch(Name, DebugSwitch))
00137 
00138 //- Define the debug information
00139 #define defineDebugSwitch(Type, DebugSwitch)                                  \
00140     defineDebugSwitchWithName(Type, Type::typeName_(), DebugSwitch)
00141 
00142 #ifdef __INTEL_COMPILER
00143 //- Define the debug information for templates, lookup as @a Name
00144 # define defineTemplateDebugSwitchWithName(Type, Name, DebugSwitch)           \
00145     defineDebugSwitchWithName(Type, Name, DebugSwitch)
00146 #else
00147 //- Define the debug information for templates, lookup as @a Name
00148 # define defineTemplateDebugSwitchWithName(Type, Name, DebugSwitch)           \
00149     template<>                                                                \
00150     defineDebugSwitchWithName(Type, Name, DebugSwitch)
00151 #endif
00152 
00153 //- Define the debug information for templates
00154 //  Useful with typedefs
00155 #define defineTemplateDebugSwitch(Type, DebugSwitch)                          \
00156     defineTemplateDebugSwitchWithName(Type, #Type, DebugSwitch)
00157 
00158 //- Define the debug information directly for templates
00159 #define defineNamedTemplateDebugSwitch(Type, DebugSwitch)                     \
00160     defineTemplateDebugSwitchWithName(Type, Type::typeName_(), DebugSwitch)
00161 
00162 
00163 
00164 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00165 // definitions (with debug information)
00166 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00167 
00168 
00169 //- Define the typeName and debug information
00170 #define defineTypeNameAndDebug(Type, DebugSwitch)                             \
00171     defineTypeName(Type);                                                     \
00172     defineDebugSwitch(Type, DebugSwitch)
00173 
00174 //- Define the typeName and debug information, lookup as @a Name
00175 #define defineTemplateTypeNameAndDebugWithName(Type, Name, DebugSwitch)       \
00176     defineTemplateTypeNameWithName(Type, Name);                               \
00177     defineTemplateDebugSwitchWithName(Type, Name, DebugSwitch)
00178 
00179 //- Define the typeName and debug information for templates, useful with typedefs
00180 #define defineTemplateTypeNameAndDebug(Type, DebugSwitch)                     \
00181     defineTemplateTypeNameAndDebugWithName(Type, #Type, DebugSwitch)
00182 
00183 //- Define the typeName and debug information for templates
00184 #define defineNamedTemplateTypeNameAndDebug(Type, DebugSwitch)                \
00185     defineNamedTemplateTypeName(Type);                                        \
00186     defineNamedTemplateDebugSwitch(Type, DebugSwitch)
00187 
00188 
00189 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00190 
00191 #endif
00192 
00193 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines