1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
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 the
13 Free Software Foundation; either version 2 of the License, or (at your
14 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, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
26 Class for handling debugging switches.
28 \*---------------------------------------------------------------------------*/
31 #include "dictionary.H"
33 #include "OSspecific.H"
35 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
42 //! @cond ignoreDocumentation - local scope
43 dictionary* controlDictPtr_(NULL);
44 dictionary* debugSwitchesPtr_(NULL);
45 dictionary* infoSwitchesPtr_(NULL);
46 dictionary* optimisationSwitchesPtr_(NULL);
48 // to ensure controlDictPtr_ is deleted at the end of the run
49 class deleteControlDictPtr
53 deleteControlDictPtr()
56 ~deleteControlDictPtr()
60 delete controlDictPtr_;
66 deleteControlDictPtr deleteControlDictPtr_;
67 //! @endcond ignoreDocumentation
70 } // End namespace debug
71 } // End namespace Foam
73 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
75 Foam::dictionary& Foam::debug::controlDict()
79 controlDictPtr_ = new dictionary
81 IFstream(findEtcFile("controlDict", true))()
85 return *controlDictPtr_;
89 Foam::dictionary& Foam::debug::switchSet
91 const char* subDictName,
92 dictionary*& subDictPtr
97 entry* ePtr = controlDict().lookupEntryPtr
99 subDictName, false, false
102 if (!ePtr || !ePtr->isDict())
104 cerr<< "debug::switchSet(const char*, dictionary*&):\n"
105 << " Cannot find " << subDictName << " in dictionary "
106 << controlDict().name().c_str()
107 << std::endl << std::endl;
112 subDictPtr = &ePtr->dict();
119 Foam::dictionary& Foam::debug::debugSwitches()
121 return switchSet("DebugSwitches", debugSwitchesPtr_);
125 Foam::dictionary& Foam::debug::infoSwitches()
127 return switchSet("InfoSwitches", infoSwitchesPtr_);
131 Foam::dictionary& Foam::debug::optimisationSwitches()
133 return switchSet("OptimisationSwitches", optimisationSwitchesPtr_);
137 int Foam::debug::debugSwitch(const char* name, const int defaultValue)
139 return debugSwitches().lookupOrAddDefault
141 name, defaultValue, false, false
146 int Foam::debug::infoSwitch(const char* name, const int defaultValue)
148 return infoSwitches().lookupOrAddDefault
150 name, defaultValue, false, false
155 int Foam::debug::optimisationSwitch(const char* name, const int defaultValue)
157 return optimisationSwitches().lookupOrAddDefault
159 name, defaultValue, false, false
164 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
167 // ************************************************************************* //