From 02ba39d93ca03824438dfc60de969237eb9aba9c Mon Sep 17 00:00:00 2001 From: Henry Date: Thu, 5 Feb 2015 10:43:10 +0000 Subject: [PATCH] Rationalized handling of debug, info and opt switches --- src/OpenFOAM/db/IOstreams/Pstreams/UPstream.C | 3 +- src/OpenFOAM/db/regIOobject/regIOobject.C | 3 +- src/OpenFOAM/db/typeInfo/className.H | 14 +--- .../debug/defineDebugSwitch.H} | 73 +++---------------- .../global/debug/registerInfoSwitch.H | 65 +++++++++++++++++ src/OpenFOAM/global/debug/registerOptSwitch.H | 65 +++++++++++++++++ .../global/debug/simpleObjectRegistry.H | 3 +- 7 files changed, 148 insertions(+), 78 deletions(-) rename src/OpenFOAM/{db/typeInfo/debugName.H => global/debug/defineDebugSwitch.H} (62%) create mode 100644 src/OpenFOAM/global/debug/registerInfoSwitch.H create mode 100644 src/OpenFOAM/global/debug/registerOptSwitch.H diff --git a/src/OpenFOAM/db/IOstreams/Pstreams/UPstream.C b/src/OpenFOAM/db/IOstreams/Pstreams/UPstream.C index affb9e92b..9e3f0cb76 100644 --- a/src/OpenFOAM/db/IOstreams/Pstreams/UPstream.C +++ b/src/OpenFOAM/db/IOstreams/Pstreams/UPstream.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -25,6 +25,7 @@ License #include "UPstream.H" #include "debug.H" +#include "registerOptSwitch.H" #include "dictionary.H" #include "IOstreams.H" diff --git a/src/OpenFOAM/db/regIOobject/regIOobject.C b/src/OpenFOAM/db/regIOobject/regIOobject.C index d44b38fd6..fe52fe787 100644 --- a/src/OpenFOAM/db/regIOobject/regIOobject.C +++ b/src/OpenFOAM/db/regIOobject/regIOobject.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -26,6 +26,7 @@ License #include "regIOobject.H" #include "Time.H" #include "polyMesh.H" +#include "registerOptSwitch.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // diff --git a/src/OpenFOAM/db/typeInfo/className.H b/src/OpenFOAM/db/typeInfo/className.H index cc0342e15..364d7ecb8 100644 --- a/src/OpenFOAM/db/typeInfo/className.H +++ b/src/OpenFOAM/db/typeInfo/className.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -29,9 +29,7 @@ Description #ifndef className_H #define className_H -#include "word.H" -#include "debug.H" -#include "debugName.H" +#include "defineDebugSwitch.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -39,7 +37,6 @@ Description // declarations (without debug information) // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - //- Add typeName information from argument \a TypeNameString to a class. // Without debug information #define ClassNameNoDebug(TypeNameString) \ @@ -63,12 +60,10 @@ public: \ } - // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // declarations (with debug information) // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - //- Add typeName information from argument \a TypeNameString to a class. // Also declares debug information. #define ClassName(TypeNameString) \ @@ -92,12 +87,10 @@ public: \ } - // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // definitions (without debug information) // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - //- Define the typeName, with alternative lookup as \a Name #define defineTypeNameWithName(Type, Name) \ const ::Foam::word Type::typeName(Name) @@ -133,12 +126,10 @@ public: \ defineTemplateTypeNameWithName(Type, Type::typeName_()) - // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // definitions (with debug information) // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - //- Define the typeName and debug information #define defineTypeNameAndDebug(Type, DebugSwitch) \ defineTypeName(Type); \ @@ -172,7 +163,6 @@ public: \ defineTemplate2TypeNameAndDebugWithName(Type, #Type, DebugSwitch) - // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // #endif diff --git a/src/OpenFOAM/db/typeInfo/debugName.H b/src/OpenFOAM/global/debug/defineDebugSwitch.H similarity index 62% rename from src/OpenFOAM/db/typeInfo/debugName.H rename to src/OpenFOAM/global/debug/defineDebugSwitch.H index 86c3d6693..830c71fb3 100644 --- a/src/OpenFOAM/db/typeInfo/debugName.H +++ b/src/OpenFOAM/global/debug/defineDebugSwitch.H @@ -22,15 +22,14 @@ License along with OpenFOAM. If not, see . Description - Macro definitions for debug symbols etc. + Macro definitions for debug switches. \*---------------------------------------------------------------------------*/ -#ifndef debugName_H -#define debugName_H +#ifndef defineDebugSwitch_H +#define defineDebugSwitch_H #include "simpleRegIOobject.H" -#include "word.H" #include "debug.H" #include "label.H" @@ -45,21 +44,21 @@ namespace Foam //- Define the debug information, lookup as \a Name template -class AddToDebug +class RegisterDebugSwitch : public ::Foam::simpleRegIOobject { public: - //- The unique AddToDebug object - static const AddToDebug addToDebug; + //- The unique RegisterDebugSwitch object + static const RegisterDebugSwitch registerDebugSwitch; - AddToDebug(const char* name) + RegisterDebugSwitch(const char* name) : ::Foam::simpleRegIOobject(Foam::debug::addDebugObject, name) {} - virtual ~AddToDebug() + virtual ~RegisterDebugSwitch() {} virtual void readData(Foam::Istream& is) @@ -77,7 +76,8 @@ public: #define registerTemplateDebugSwitchWithName(Type,Name) \ template<> \ - const Foam::AddToDebug Foam::AddToDebug::addToDebug(Name) + const Foam::RegisterDebugSwitch \ + Foam::RegisterDebugSwitch::registerDebugSwitch(Name) //- Define the debug information, lookup as \a Name @@ -105,56 +105,6 @@ public: add##Tag##ToDebug add##Tag##ToDebug_(Name) -//- Register info switch (if int), lookup as \a Name -#define registerInfoSwitchWithName(Switch,Tag,Name) \ - class add##Tag##ToInfo \ - : \ - public ::Foam::simpleRegIOobject \ - { \ - public: \ - add##Tag##ToInfo(const char* name) \ - : \ - ::Foam::simpleRegIOobject(Foam::debug::addInfoObject, name) \ - {} \ - virtual ~add##Tag##ToInfo() \ - {} \ - virtual void readData(Foam::Istream& is) \ - { \ - Switch = readLabel(is); \ - } \ - virtual void writeData(Foam::Ostream& os) const \ - { \ - os << Switch; \ - } \ - }; \ - add##Tag##ToInfo add##Tag##ToInfo_(Name) - - -//- Register optimisation switch (if int), lookup as \a Name -#define registerOptSwitchWithName(Switch,Tag,Name) \ - class add##Tag##ToOpt \ - : \ - public ::Foam::simpleRegIOobject \ - { \ - public: \ - add##Tag##ToOpt(const char* name) \ - : \ - ::Foam::simpleRegIOobject(Foam::debug::addOptimisationObject,name)\ - {} \ - virtual ~add##Tag##ToOpt() \ - {} \ - virtual void readData(Foam::Istream& is) \ - { \ - Switch = readLabel(is); \ - } \ - virtual void writeData(Foam::Ostream& os) const \ - { \ - os << Switch; \ - } \ - }; \ - add##Tag##ToOpt add##Tag##ToOpt_(Name) - - //- Define the debug information, lookup as \a Name #define defineDebugSwitchWithName(Type, Name, DebugSwitch) \ int Type::debug(::Foam::debug::debugSwitch(Name, DebugSwitch)) @@ -194,7 +144,7 @@ public: defineTemplateDebugSwitchWithName(Type, Type::typeName_(), DebugSwitch) -// for templated sub-classes +// For templated sub-classes //- Define the debug information for templates // Useful with typedefs @@ -206,7 +156,6 @@ public: defineTemplate2DebugSwitchWithName(Type, Type::typeName_(), DebugSwitch) - // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // #endif diff --git a/src/OpenFOAM/global/debug/registerInfoSwitch.H b/src/OpenFOAM/global/debug/registerInfoSwitch.H new file mode 100644 index 000000000..54598d2c3 --- /dev/null +++ b/src/OpenFOAM/global/debug/registerInfoSwitch.H @@ -0,0 +1,65 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2012-2015 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +Description + Macro definitions for info switches. + +\*---------------------------------------------------------------------------*/ + +#ifndef registerInfoSwitch_H +#define registerInfoSwitch_H + +#include "simpleRegIOobject.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +//- Register info switch (if int), lookup as \a Name +#define registerInfoSwitchWithName(Switch,Tag,Name) \ + class add##Tag##ToInfo \ + : \ + public ::Foam::simpleRegIOobject \ + { \ + public: \ + add##Tag##ToInfo(const char* name) \ + : \ + ::Foam::simpleRegIOobject(Foam::debug::addInfoObject, name) \ + {} \ + virtual ~add##Tag##ToInfo() \ + {} \ + virtual void readData(Foam::Istream& is) \ + { \ + Switch = readLabel(is); \ + } \ + virtual void writeData(Foam::Ostream& os) const \ + { \ + os << Switch; \ + } \ + }; \ + add##Tag##ToInfo add##Tag##ToInfo_(Name) + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/OpenFOAM/global/debug/registerOptSwitch.H b/src/OpenFOAM/global/debug/registerOptSwitch.H new file mode 100644 index 000000000..ccd282d96 --- /dev/null +++ b/src/OpenFOAM/global/debug/registerOptSwitch.H @@ -0,0 +1,65 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2012-2015 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +Description + Macro definitions for optimization switches. + +\*---------------------------------------------------------------------------*/ + +#ifndef registerOptSwitch_H +#define registerOptSwitch_H + +#include "simpleRegIOobject.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +//- Register optimisation switch (if int), lookup as \a Name +#define registerOptSwitchWithName(Switch,Tag,Name) \ + class add##Tag##ToOpt \ + : \ + public ::Foam::simpleRegIOobject \ + { \ + public: \ + add##Tag##ToOpt(const char* name) \ + : \ + ::Foam::simpleRegIOobject(Foam::debug::addOptimisationObject,name)\ + {} \ + virtual ~add##Tag##ToOpt() \ + {} \ + virtual void readData(Foam::Istream& is) \ + { \ + Switch = readLabel(is); \ + } \ + virtual void writeData(Foam::Ostream& os) const \ + { \ + os << Switch; \ + } \ + }; \ + add##Tag##ToOpt add##Tag##ToOpt_(Name) + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/OpenFOAM/global/debug/simpleObjectRegistry.H b/src/OpenFOAM/global/debug/simpleObjectRegistry.H index 91475b8b5..ecf9a5844 100644 --- a/src/OpenFOAM/global/debug/simpleObjectRegistry.H +++ b/src/OpenFOAM/global/debug/simpleObjectRegistry.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2012-2015 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -34,7 +34,6 @@ SourceFiles #ifndef simpleObjectRegistry_H #define simpleObjectRegistry_H -//#include "UPtrDictionary.H" #include "Dictionary.H" #include "simpleRegIOobject.H"