debug.C
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #include "debug.H"
00031 #include "dictionary.H"
00032 #include "IFstream.H"
00033 #include "OSspecific.H"
00034
00035
00036
00037 namespace Foam
00038 {
00039 namespace debug
00040 {
00041
00043 dictionary* controlDictPtr_(NULL);
00044 dictionary* debugSwitchesPtr_(NULL);
00045 dictionary* infoSwitchesPtr_(NULL);
00046 dictionary* optimisationSwitchesPtr_(NULL);
00047
00048
00049 class deleteControlDictPtr
00050 {
00051 public:
00052
00053 deleteControlDictPtr()
00054 {}
00055
00056 ~deleteControlDictPtr()
00057 {
00058 if (controlDictPtr_)
00059 {
00060 delete controlDictPtr_;
00061 controlDictPtr_ = 0;
00062 }
00063 }
00064 };
00065
00066 deleteControlDictPtr deleteControlDictPtr_;
00068
00069
00070 }
00071 }
00072
00073
00074
00075 Foam::dictionary& Foam::debug::controlDict()
00076 {
00077 if (!controlDictPtr_)
00078 {
00079 controlDictPtr_ = new dictionary
00080 (
00081 IFstream(findEtcFile("controlDict", true))()
00082 );
00083 }
00084
00085 return *controlDictPtr_;
00086 }
00087
00088
00089 Foam::dictionary& Foam::debug::switchSet
00090 (
00091 const char* subDictName,
00092 dictionary*& subDictPtr
00093 )
00094 {
00095 if (!subDictPtr)
00096 {
00097 entry* ePtr = controlDict().lookupEntryPtr
00098 (
00099 subDictName, false, false
00100 );
00101
00102 if (!ePtr || !ePtr->isDict())
00103 {
00104 cerr<< "debug::switchSet(const char*, dictionary*&):\n"
00105 << " Cannot find " << subDictName << " in dictionary "
00106 << controlDict().name().c_str()
00107 << std::endl << std::endl;
00108
00109 ::exit(1);
00110 }
00111
00112 subDictPtr = &ePtr->dict();
00113 }
00114
00115 return *subDictPtr;
00116 }
00117
00118
00119 Foam::dictionary& Foam::debug::debugSwitches()
00120 {
00121 return switchSet("DebugSwitches", debugSwitchesPtr_);
00122 }
00123
00124
00125 Foam::dictionary& Foam::debug::infoSwitches()
00126 {
00127 return switchSet("InfoSwitches", infoSwitchesPtr_);
00128 }
00129
00130
00131 Foam::dictionary& Foam::debug::optimisationSwitches()
00132 {
00133 return switchSet("OptimisationSwitches", optimisationSwitchesPtr_);
00134 }
00135
00136
00137 int Foam::debug::debugSwitch(const char* name, const int defaultValue)
00138 {
00139 return debugSwitches().lookupOrAddDefault
00140 (
00141 name, defaultValue, false, false
00142 );
00143 }
00144
00145
00146 int Foam::debug::infoSwitch(const char* name, const int defaultValue)
00147 {
00148 return infoSwitches().lookupOrAddDefault
00149 (
00150 name, defaultValue, false, false
00151 );
00152 }
00153
00154
00155 int Foam::debug::optimisationSwitch(const char* name, const int defaultValue)
00156 {
00157 return optimisationSwitches().lookupOrAddDefault
00158 (
00159 name, defaultValue, false, false
00160 );
00161 }
00162
00163
00164
00165
00166
00167
Copyright © 2000-2009 OpenCFD Ltd