1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright held by original author
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
29 Class to handle messaging in a simple, consistent stream-based
32 The messageStream class is globaly instantiated with a title string a
33 given severity, which controls the program termination, and a number of
34 errors before termination. Errors, messages and other data are piped to
35 the messageStream class in the standard manner.
39 messageStream << "message1" << "message2" << FoamDataType << endl;
45 \*---------------------------------------------------------------------------*/
47 #ifndef messageStream_H
48 #define messageStream_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_;
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 // ************************************************************************* //