Commit 5403e977 authored by Henry Weller's avatar Henry Weller Committed by Andrew Heather
Browse files

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.
parent 02e33f49
......@@ -39,10 +39,6 @@ License
#include "sigSegv.H"
#include "foamVersion.H"
#include "simpleObjectRegistry.H"
#include "HashSet.H"
#include "etcFiles.H"
#include <cctype>
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
......@@ -1298,88 +1294,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;
......
......@@ -160,15 +160,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:
......@@ -430,12 +421,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
......
......@@ -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
);
}
// ************************************************************************* //
......@@ -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
......
......@@ -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;
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment