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.
This commit is contained in:
Henry Weller
2017-06-11 23:18:34 +01:00
parent a4e755c0dc
commit af66eb78a6
5 changed files with 98 additions and 105 deletions

View File

@ -34,10 +34,6 @@ License
#include "regIOobject.H"
#include "dynamicCode.H"
#include "simpleObjectRegistry.H"
#include "HashSet.H"
#include "etcFiles.H"
#include <cctype>
// * * * * * * * * * * * * * * 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;

View File

@ -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

View File

@ -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
);
}
// ************************************************************************* //

View File

@ -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

View File

@ -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;
}