1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
11 OpenFOAM is free software: you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by
13 the Free Software Foundation, either version 3 of the License, or
14 (at your option) any later version.
16 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 Class for handling debugging switches.
27 \*---------------------------------------------------------------------------*/
30 #include "dictionary.H"
32 #include "OSspecific.H"
34 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
41 //! \cond ignoreDocumentation - local scope
42 dictionary* controlDictPtr_(NULL);
43 dictionary* debugSwitchesPtr_(NULL);
44 dictionary* infoSwitchesPtr_(NULL);
45 dictionary* optimisationSwitchesPtr_(NULL);
47 // to ensure controlDictPtr_ is deleted at the end of the run
48 class deleteControlDictPtr
52 deleteControlDictPtr()
55 ~deleteControlDictPtr()
59 delete controlDictPtr_;
65 deleteControlDictPtr deleteControlDictPtr_;
69 } // End namespace debug
70 } // End namespace Foam
72 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
74 Foam::dictionary& Foam::debug::controlDict()
78 fileNameList controlDictFiles = findEtcFiles("controlDict", true);
79 controlDictPtr_ = new dictionary();
80 forAllReverse(controlDictFiles, cdfi)
82 controlDictPtr_->merge
84 dictionary(IFstream(controlDictFiles[cdfi])())
89 return *controlDictPtr_;
93 Foam::dictionary& Foam::debug::switchSet
95 const char* subDictName,
96 dictionary*& subDictPtr
101 entry* ePtr = controlDict().lookupEntryPtr
103 subDictName, false, false
106 if (!ePtr || !ePtr->isDict())
108 cerr<< "debug::switchSet(const char*, dictionary*&):\n"
109 << " Cannot find " << subDictName << " in dictionary "
110 << controlDict().name().c_str()
111 << std::endl << std::endl;
116 subDictPtr = &ePtr->dict();
123 Foam::dictionary& Foam::debug::debugSwitches()
125 return switchSet("DebugSwitches", debugSwitchesPtr_);
129 Foam::dictionary& Foam::debug::infoSwitches()
131 return switchSet("InfoSwitches", infoSwitchesPtr_);
135 Foam::dictionary& Foam::debug::optimisationSwitches()
137 return switchSet("OptimisationSwitches", optimisationSwitchesPtr_);
141 int Foam::debug::debugSwitch(const char* name, const int defaultValue)
143 return debugSwitches().lookupOrAddDefault
145 name, defaultValue, false, false
150 int Foam::debug::infoSwitch(const char* name, const int defaultValue)
152 return infoSwitches().lookupOrAddDefault
154 name, defaultValue, false, false
159 int Foam::debug::optimisationSwitch(const char* name, const int defaultValue)
161 return optimisationSwitches().lookupOrAddDefault
163 name, defaultValue, false, false
168 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
171 // ************************************************************************* //