From af66eb78a644cb80438ea84317e2443307351da1 Mon Sep 17 00:00:00 2001 From: Henry Weller Date: Sun, 11 Jun 2017 23:18:34 +0100 Subject: [PATCH] listSwitches: moved from argList to debug Initially the listSwitches functions depended directly on argList functionality but this has now been factored out so that the listSwitches functions are more general and require only debug functionality. --- src/OpenFOAM/global/argList/argList.C | 86 ------------------------- src/OpenFOAM/global/argList/argList.H | 15 ----- src/OpenFOAM/global/debug/debug.C | 91 ++++++++++++++++++++++++++- src/OpenFOAM/global/debug/debug.H | 7 ++- src/OpenFOAM/include/listOutput.H | 4 +- 5 files changed, 98 insertions(+), 105 deletions(-) diff --git a/src/OpenFOAM/global/argList/argList.C b/src/OpenFOAM/global/argList/argList.C index 2c8fba02f..c28814f59 100644 --- a/src/OpenFOAM/global/argList/argList.C +++ b/src/OpenFOAM/global/argList/argList.C @@ -34,10 +34,6 @@ License #include "regIOobject.H" #include "dynamicCode.H" -#include "simpleObjectRegistry.H" -#include "HashSet.H" -#include "etcFiles.H" - #include // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -1211,88 +1207,6 @@ void Foam::argList::displayDoc(bool source) const } -void Foam::argList::listSwitches -( - const wordList& debugSwitches, - const wordList& infoSwitches, - const wordList& optSwitches, - const bool unset -) -{ - if (unset) - { - fileNameList controlDictFiles = findEtcFiles("controlDict", true); - dictionary controlDict; - forAllReverse(controlDictFiles, cdfi) - { - controlDict.merge(dictionary(IFstream(controlDictFiles[cdfi])())); - } - - wordHashSet controlDictDebug - ( - controlDict.subDict("DebugSwitches").sortedToc() - ); - - wordHashSet controlDictInfo - ( - controlDict.subDict("InfoSwitches").sortedToc() - ); - - wordHashSet controlDictOpt - ( - controlDict.subDict("OptimisationSwitches").sortedToc() - ); - - - IOobject::writeDivider(Info); - - wordHashSet hashset; - hashset = debugSwitches; - hashset -= controlDictDebug; - Info<< "Unset DebugSwitches" << hashset.sortedToc() << endl; - - hashset = infoSwitches; - hashset -= controlDictInfo; - Info<< "Unset InfoSwitches" << hashset.sortedToc() << endl; - - hashset = optSwitches; - hashset -= controlDictOpt; - Info<< "Unset OptimisationSwitches" << hashset.sortedToc() << endl; - } - else - { - IOobject::writeDivider(Info); - Info<< "DebugSwitches" << debugSwitches << endl; - Info<< "InfoSwitches" << infoSwitches << endl; - Info<< "OptimisationSwitches" << optSwitches << endl; - } -} - - -void Foam::argList::listSwitches(const bool unset) const -{ - listSwitches - ( - debug::debugSwitches().sortedToc(), - debug::infoSwitches().sortedToc(), - debug::optimisationSwitches().sortedToc(), - unset - ); -} - - -void Foam::argList::listRegisteredSwitches(const bool unset) const -{ - listSwitches - ( - debug::debugObjects().sortedToc(), - debug::infoObjects().sortedToc(), - debug::optimisationObjects().sortedToc(), - unset - ); -} - - bool Foam::argList::check(bool checkArgs, bool checkOpts) const { bool ok = true; diff --git a/src/OpenFOAM/global/argList/argList.H b/src/OpenFOAM/global/argList/argList.H index ba1e27109..2e6bbfd62 100644 --- a/src/OpenFOAM/global/argList/argList.H +++ b/src/OpenFOAM/global/argList/argList.H @@ -146,15 +146,6 @@ class argList // return true if any "(" ... ")" sequences were captured bool regroupArgv(int& argc, char**& argv); - //- List debug switches - static void listSwitches - ( - const wordList& debugSwitches, - const wordList& infoSwitches, - const wordList& optSwitches, - const bool unset - ); - public: @@ -399,12 +390,6 @@ public: // Optionally display the application source code void displayDoc(bool source=false) const; - //- List debug switches - void listSwitches(const bool unset) const; - - //- List registered debug switches - void listRegisteredSwitches(const bool unset) const; - // Check diff --git a/src/OpenFOAM/global/debug/debug.C b/src/OpenFOAM/global/debug/debug.C index bdf1698d0..bf5b90582 100644 --- a/src/OpenFOAM/global/debug/debug.C +++ b/src/OpenFOAM/global/debug/debug.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -33,6 +33,8 @@ Description #include "Ostream.H" #include "demandDrivenData.H" #include "simpleObjectRegistry.H" +#include "IOobject.H" +#include "HashSet.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -378,4 +380,91 @@ Foam::simpleObjectRegistry& Foam::debug::dimensionedConstantObjects() } +namespace Foam +{ + +void listSwitches +( + const wordList& debugSwitches, + const wordList& infoSwitches, + const wordList& optSwitches, + const bool unset +) +{ + if (unset) + { + fileNameList controlDictFiles = findEtcFiles("controlDict", true); + dictionary controlDict; + forAllReverse(controlDictFiles, cdfi) + { + controlDict.merge(dictionary(IFstream(controlDictFiles[cdfi])())); + } + + wordHashSet controlDictDebug + ( + controlDict.subDict("DebugSwitches").sortedToc() + ); + + wordHashSet controlDictInfo + ( + controlDict.subDict("InfoSwitches").sortedToc() + ); + + wordHashSet controlDictOpt + ( + controlDict.subDict("OptimisationSwitches").sortedToc() + ); + + + IOobject::writeDivider(Info); + + wordHashSet hashset; + hashset = debugSwitches; + hashset -= controlDictDebug; + Info<< "Unset DebugSwitches" << hashset.sortedToc() << endl; + + hashset = infoSwitches; + hashset -= controlDictInfo; + Info<< "Unset InfoSwitches" << hashset.sortedToc() << endl; + + hashset = optSwitches; + hashset -= controlDictOpt; + Info<< "Unset OptimisationSwitches" << hashset.sortedToc() << endl; + } + else + { + IOobject::writeDivider(Info); + Info<< "DebugSwitches" << debugSwitches << endl; + Info<< "InfoSwitches" << infoSwitches << endl; + Info<< "OptimisationSwitches" << optSwitches << endl; + } +} + +} + + +void Foam::debug::listSwitches(const bool unset) +{ + listSwitches + ( + debug::debugSwitches().sortedToc(), + debug::infoSwitches().sortedToc(), + debug::optimisationSwitches().sortedToc(), + unset + ); +} + + +void Foam::debug::listRegisteredSwitches(const bool unset) +{ + listSwitches + ( + debug::debugObjects().sortedToc(), + debug::infoObjects().sortedToc(), + debug::optimisationObjects().sortedToc(), + unset + ); +} + + // ************************************************************************* // diff --git a/src/OpenFOAM/global/debug/debug.H b/src/OpenFOAM/global/debug/debug.H index 190f73be3..468415140 100644 --- a/src/OpenFOAM/global/debug/debug.H +++ b/src/OpenFOAM/global/debug/debug.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -84,6 +84,8 @@ namespace debug //- Internal function to lookup a sub-dictionary from controlDict. dictionary& switchSet(const char* subDictName, dictionary*& subDictPtr); + //- List debug switches + void listSwitches(const bool unset); // Registered debug switches @@ -119,6 +121,9 @@ namespace debug //- Get access to registered dimensionedConstant switch objects simpleObjectRegistry& dimensionedConstantObjects(); + //- List registered debug switches + void listRegisteredSwitches(const bool unset); + } // End namespace debug diff --git a/src/OpenFOAM/include/listOutput.H b/src/OpenFOAM/include/listOutput.H index ca852a6b6..876a52f67 100644 --- a/src/OpenFOAM/include/listOutput.H +++ b/src/OpenFOAM/include/listOutput.H @@ -5,7 +5,7 @@ if args.optionFound("listSwitches") ) { - args.listSwitches(args.optionFound("includeUnsetSwitches")); + debug::listSwitches(args.optionFound("includeUnsetSwitches")); listOptions = true; } @@ -14,7 +14,7 @@ if args.optionFound("listRegisteredSwitches") ) { - args.listRegisteredSwitches(args.optionFound("includeUnsetSwitches")); + debug::listRegisteredSwitches(args.optionFound("includeUnsetSwitches")); listOptions = true; }