Home
Downloads
Documentation
Installation
User Guide
man-pages
API Documentation
README
Release Notes
Changes
License
Support
SourceForge Project
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
src
OpenFOAM
db
error
messageStream.H
Go to the documentation of this file.
1
/*---------------------------------------------------------------------------*\
2
========= |
3
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4
\\ / O peration |
5
\\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
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
Class
25
Foam::messageStream
26
27
Description
28
Class to handle messaging in a simple, consistent stream-based
29
manner.
30
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.
35
36
Usage
37
@code
38
messageStream << "message1" << "message2" << FoamDataType << endl;
39
@endcode
40
41
SourceFiles
42
messageStream.C
43
44
\*---------------------------------------------------------------------------*/
45
46
#ifndef messageStream_H
47
#define messageStream_H
48
49
#include <
OpenFOAM/label.H
>
50
#include <
OpenFOAM/string.H
>
51
52
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
53
54
namespace
Foam
55
{
56
57
class
IOstream;
58
class
Ostream;
59
class
OSstream;
60
class
OStringStream;
61
class
dictionary;
62
63
/*---------------------------------------------------------------------------*\
64
Class messageStream Declaration
65
\*---------------------------------------------------------------------------*/
66
67
class
messageStream
68
{
69
70
public
:
71
72
//- Severity flags
73
enum
errorSeverity
74
{
75
INFO
,
// Debugging information in event of error
76
WARNING
,
// Warning of possible problem
77
SERIOUS
,
// A serious problem (data corruption?)
78
FATAL
// Oh bugger!
79
};
80
81
82
protected
:
83
84
// Private data
85
86
string
title_
;
87
errorSeverity
severity_
;
88
int
maxErrors_
;
89
int
errorCount_
;
90
91
92
public
:
93
94
// Debug switches
95
96
static
int
level
;
97
98
99
// Constructors
100
101
//- Construct from components
102
messageStream
103
(
104
const
string
&
title
,
105
errorSeverity
sev,
106
const
int
maxErrors
= 0
107
);
108
109
110
//- Construct from dictionary
111
messageStream
(
const
dictionary
& dict);
112
113
114
// Member functions
115
116
//- Return the title of this error type
117
const
string
&
title
()
const
118
{
119
return
title_
;
120
}
121
122
//- Return the maximum number of errors before program termination
123
int
maxErrors
()
const
124
{
125
return
maxErrors_
;
126
}
127
128
//- Return non-const access to the maximum number of errors before
129
// program termination to enable user to reset it
130
int
&
maxErrors
()
131
{
132
return
maxErrors_
;
133
}
134
135
//- Convert to Ostream
136
// Prints basic message and then returns Ostream for further info.
137
OSstream
& operator()
138
(
139
const
char
* functionName,
140
const
char
* sourceFileName,
141
const
int
sourceFileLineNumber = 0
142
);
143
144
OSstream
& operator()
145
(
146
const
string
& functionName,
147
const
char
* sourceFileName,
148
const
int
sourceFileLineNumber = 0
149
);
150
151
//- Convert to Ostream
152
// Prints basic message and then returns Ostream for further info.
153
OSstream
& operator()
154
(
155
const
char
* functionName,
156
const
char
* sourceFileName,
157
const
int
sourceFileLineNumber,
158
const
string
& ioFileName,
159
const
label ioStartLineNumber = -1,
160
const
label ioEndLineNumber = -1
161
);
162
163
//- Convert to Ostream
164
// Prints basic message and then returns Ostream for further info.
165
OSstream
& operator()
166
(
167
const
char
* functionName,
168
const
char
* sourceFileName,
169
const
int
sourceFileLineNumber,
170
const
IOstream
&
171
);
172
173
//- Convert to Ostream
174
// Prints basic message and then returns Ostream for further info.
175
OSstream
& operator()
176
(
177
const
char
* functionName,
178
const
char
* sourceFileName,
179
const
int
sourceFileLineNumber,
180
const
dictionary
&
181
);
182
183
//- Convert to Ostream for << operations
184
operator
OSstream
&();
185
186
//- Explicitly convert to Ostream for << operations
187
OSstream
&
operator()
()
188
{
189
return
operator
OSstream
&();
190
}
191
};
192
193
194
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
195
// Global error declarations: defined in messageStream.C
196
197
extern
messageStream
SeriousError
;
198
extern
messageStream
Warning
;
199
extern
messageStream
Info
;
200
201
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
202
// Convienient macros to add the file name and line number to the function name
203
204
#define SeriousErrorIn(fn) SeriousError(fn, __FILE__, __LINE__)
205
#define SeriousIOErrorIn(fn, ios) SeriousError(fn, __FILE__, __LINE__, ios)
206
207
#define WarningIn(fn) Warning(fn, __FILE__, __LINE__)
208
#define IOWarningIn(fn, ios) Warning(fn, __FILE__, __LINE__, ios)
209
210
#define InfoIn(fn) Info(fn, __FILE__, __LINE__)
211
#define IOInfoIn(fn, ios) Info(fn, __FILE__, __LINE__, ios)
212
213
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
214
215
}
// End namespace Foam
216
217
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
218
219
#include <
OpenFOAM/OSstream.H
>
220
221
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
222
223
#endif
224
225
// ************************ vim: set sw=4 sts=4 et: ************************ //