All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
debug.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
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.
15 
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
19  for more details.
20 
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/>.
23 
24 Namespace
25  Foam::debug
26 
27 Description
28  Namespace for handling debugging switches.
29 
30 SourceFiles
31  debug.C
32 
33 \*---------------------------------------------------------------------------*/
34 
35 #ifndef debug_H
36 #define debug_H
37 
38 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
39 
40 namespace Foam
41 {
42 
43 // Forward declaration of classes
44 class dictionary;
45 class Istream;
46 class Ostream;
47 class word;
48 template<class Enum, unsigned int nEnum> class NamedEnum;
49 
50 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
51 
52 namespace debug
53 {
54  //- The central control dictionary.
55  // Located in ~/.OpenFOAM/VERSION or $WM_PROJECT_DIR/etc
56  // \sa Foam::findEtcFile()
57  dictionary& controlDict();
58 
59  //- The DebugSwitches sub-dictionary in the central controlDict.
60  dictionary& debugSwitches();
61 
62  //- The InfoSwitches sub-dictionary in the central controlDict.
63  dictionary& infoSwitches();
64 
65  //- The OptimisationSwitches sub-dictionary in the central controlDict.
66  dictionary& optimisationSwitches();
67 
68  //- Lookup debug switch or add default value.
69  int debugSwitch(const char* name, const int defaultValue=0);
70 
71  //- Lookup info switch or add default value.
72  int infoSwitch(const char* name, const int defaultValue=0);
73 
74  //- Lookup optimisation switch or add default value.
75  int optimisationSwitch(const char* name, const int defaultValue=0);
76 
77  //- Lookup optimisation switch or add default value.
79  (
80  const char* name,
81  const float defaultValue=0
82  );
83 
84  //- Lookup optimisation switch or add default value.
85  const word wordOptimisationSwitch
86  (
87  const char* name,
88  const word& defaultValue
89  );
90 
91  //- Lookup optimisation switch or add default value.
92  template<class Enum, unsigned int nEnum>
94  (
95  const char* name,
96  const NamedEnum<Enum, nEnum>& enumNames,
97  const Enum defaultValue
98  )
99  {
100  return enumNames
101  [
103  (
104  name,
105  enumNames[defaultValue]
106  )
107  ];
108  }
109 
110  //- Internal function to lookup a sub-dictionary from controlDict.
111  dictionary& switchSet(const char* subDictName, dictionary*& subDictPtr);
112 
113  //- List debug switches
114  void listSwitches();
115 
116 } // End namespace debug
117 
118 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
119 
120 } // End namespace Foam
121 
122 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
123 
124 #endif
125 
126 // ************************************************************************* //
float floatOptimisationSwitch(const char *name, const float defaultValue=0)
Lookup optimisation switch or add default value.
Definition: debug.C:278
dictionary & switchSet(const char *subDictName, dictionary *&subDictPtr)
Internal function to lookup a sub-dictionary from controlDict.
Definition: debug.C:164
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:156
int optimisationSwitch(const char *name, const int defaultValue=0)
Lookup optimisation switch or add default value.
Definition: debug.C:255
void listSwitches()
List debug switches.
Definition: debug.C:467
Initialise the NamedEnum HashTable from the static list of names.
Definition: NamedEnum.H:51
int infoSwitch(const char *name, const int defaultValue=0)
Lookup info switch or add default value.
Definition: debug.C:233
dictionary & infoSwitches()
The InfoSwitches sub-dictionary in the central controlDict.
Definition: debug.C:199
int debugSwitch(const char *name, const int defaultValue=0)
Lookup debug switch or add default value.
Definition: debug.C:211
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47
dictionary & optimisationSwitches()
The OptimisationSwitches sub-dictionary in the central controlDict.
Definition: debug.C:205
Enum namedEnumOptimisationSwitch(const char *name, const NamedEnum< Enum, nEnum > &enumNames, const Enum defaultValue)
Lookup optimisation switch or add default value.
Definition: debug.H:94
const word wordOptimisationSwitch(const char *name, const word &defaultValue)
Lookup optimisation switch or add default value.
Definition: debug.C:303
dictionary & debugSwitches()
The DebugSwitches sub-dictionary in the central controlDict.
Definition: debug.C:193
dictionary & controlDict()
The central control dictionary.
Definition: debug.C:120
Namespace for OpenFOAM.