1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | foam-extend: Open Source CFD
4 \\ / O peration | Version: 3.2
5 \\ / A nd | Web: http://www.foam-extend.org
6 \\/ M anipulation | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
9 This file is part of foam-extend.
11 foam-extend 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 3 of the License, or (at your
14 option) any later version.
16 foam-extend is distributed in the hope that it will be useful, but
17 WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
28 Class to handle messaging in a simple, consistent stream-based
31 The messageStream class is globaly instantiated with a title string a
32 given severity, which controls the program termination, and a number of
33 errors before termination. Errors, messages and other data are piped to
34 the messageStream class in the standard manner.
38 messageStream << "message1" << "message2" << FoamDataType << endl;
44 \*---------------------------------------------------------------------------*/
46 #ifndef messageStream_H
47 #define messageStream_H
50 #include "foamString.H"
51 #include "debugSwitch.H"
53 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
64 /*---------------------------------------------------------------------------*\
65 Class messageStream Declaration
66 \*---------------------------------------------------------------------------*/
76 INFO, // Debugging information in event of error
77 WARNING, // Warning of possible problem
78 SERIOUS, // A serious problem (data corruption?)
88 errorSeverity severity_;
97 static debug::debugSwitch level;
102 //- Construct from components
107 const int maxErrors = 0
111 //- Construct from dictionary
112 messageStream(const dictionary& dict);
117 //- Return the title of this error type
118 const string& title() const
123 //- Return the maximum number of errors before program termination
124 int maxErrors() const
129 //- Return non-const access to the maximum number of errors before
130 // program termination to enable user to reset it
136 //- Convert to Ostream
137 // Prints basic message and then returns Ostream for further info.
140 const char* functionName,
141 const char* sourceFileName,
142 const int sourceFileLineNumber = 0
147 const string& functionName,
148 const char* sourceFileName,
149 const int sourceFileLineNumber = 0
152 //- Convert to Ostream
153 // Prints basic message and then returns Ostream for further info.
156 const char* functionName,
157 const char* sourceFileName,
158 const int sourceFileLineNumber,
159 const string& ioFileName,
160 const label ioStartLineNumber = -1,
161 const label ioEndLineNumber = -1
164 //- Convert to Ostream
165 // Prints basic message and then returns Ostream for further info.
168 const char* functionName,
169 const char* sourceFileName,
170 const int sourceFileLineNumber,
174 //- Convert to Ostream
175 // Prints basic message and then returns Ostream for further info.
178 const char* functionName,
179 const char* sourceFileName,
180 const int sourceFileLineNumber,
184 //- Convert to Ostream for << operations
185 operator OSstream&();
187 //- Explicitly convert to Ostream for << operations
188 OSstream& operator()()
190 return operator OSstream&();
195 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
196 // Global error declarations: defined in messageStream.C
198 extern messageStream SeriousError;
199 extern messageStream Warning;
200 extern messageStream Info;
202 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
203 // Convienient macros to add the file name and line number to the function name
205 #define SeriousErrorIn(fn) SeriousError(fn, __FILE__, __LINE__)
206 #define SeriousIOErrorIn(fn, ios) SeriousError(fn, __FILE__, __LINE__, ios)
208 #define WarningIn(fn) Warning(fn, __FILE__, __LINE__)
209 #define IOWarningIn(fn, ios) Warning(fn, __FILE__, __LINE__, ios)
211 #define InfoIn(fn) Info(fn, __FILE__, __LINE__)
212 #define IOInfoIn(fn, ios) Info(fn, __FILE__, __LINE__, ios)
214 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
216 } // End namespace Foam
218 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
220 #include "OSstream.H"
222 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
226 // ************************************************************************* //