messageStream Class Reference

Class to handle messaging in a simple, consistent stream-based manner. More...

Inheritance diagram for messageStream:
Collaboration diagram for messageStream:

Public Types

enum  errorSeverity { INFO , WARNING , SERIOUS , FATAL }
 Severity flags. More...
 

Public Member Functions

 messageStream (const string &title, const errorSeverity, const int maxErrors=0)
 Construct from components. More...
 
const stringtitle () const
 Return the title of this error type. More...
 
int maxErrors () const
 Return the maximum number of errors before program termination. More...
 
int & maxErrors ()
 Return non-const access to the maximum number of errors before. More...
 
OSstreamoperator() (const char *functionName, const char *sourceFileName, const int sourceFileLineNumber=0)
 Convert to OSstream. More...
 
OSstreamoperator() (const string &functionName, const char *sourceFileName, const int sourceFileLineNumber=0)
 Convert to OSstream. More...
 
OSstreamoperator() (const char *functionName, const char *sourceFileName, const int sourceFileLineNumber, const string &ioFileName, const label ioStartLineNumber=-1, const label ioEndLineNumber=-1)
 Convert to OSstream. More...
 
OSstreamoperator() (const char *functionName, const char *sourceFileName, const int sourceFileLineNumber, const IOstream &)
 Convert to OSstream. More...
 
OSstreamoperator() (const char *functionName, const char *sourceFileName, const int sourceFileLineNumber, const dictionary &)
 Convert to OSstream. More...
 
OSstreamoperator() (const label communicator=-1)
 Explicitly convert to OSstream for << operations. More...
 
 operator OSstream & ()
 Convert to OSstream for << operations. More...
 

Static Public Attributes

static int level
 

Protected Attributes

string title_
 
errorSeverity severity_
 
int maxErrors_
 
int errorCount_
 

Detailed Description

Class to handle messaging in a simple, consistent stream-based manner.

The messageStream class is globally instantiated with a title string a given severity, which controls the program termination, and a number of errors before termination. Errors, messages and other data are piped to the messageStream class in the standard manner.

Usage
<< "message1" << "message2" << FoamDataType << endl;
messageStream(const string &title, const errorSeverity, const int maxErrors=0)
Construct from components.
Definition: messageStream.C:37
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:257
Source files

Definition at line 68 of file messageStream.H.

Member Enumeration Documentation

◆ errorSeverity

Severity flags.

Enumerator
INFO 
WARNING 
SERIOUS 
FATAL 

Definition at line 74 of file messageStream.H.

Constructor & Destructor Documentation

◆ messageStream()

messageStream ( const string title,
const errorSeverity  sev,
const int  maxErrors = 0 
)

Construct from components.

Definition at line 36 of file messageStream.C.

Member Function Documentation

◆ title()

const string& title ( ) const
inline

Return the title of this error type.

Definition at line 114 of file messageStream.H.

References messageStream::title_.

Referenced by Foam::operator<<().

Here is the caller graph for this function:

◆ maxErrors() [1/2]

int maxErrors ( ) const
inline

Return the maximum number of errors before program termination.

Definition at line 120 of file messageStream.H.

References messageStream::maxErrors_.

◆ maxErrors() [2/2]

int& maxErrors ( )
inline

Return non-const access to the maximum number of errors before.

program termination to enable user to reset it

Definition at line 127 of file messageStream.H.

◆ operator()() [1/6]

Foam::OSstream & operator() ( const char *  functionName,
const char *  sourceFileName,
const int  sourceFileLineNumber = 0 
)

Convert to OSstream.

Prints basic message and returns OSstream for further info.

Definition at line 50 of file messageStream.C.

References Foam::endl().

Referenced by messageStream::operator OSstream &().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator()() [2/6]

Foam::OSstream & operator() ( const string functionName,
const char *  sourceFileName,
const int  sourceFileLineNumber = 0 
)

Convert to OSstream.

Prints basic message and returns OSstream for further info.

Definition at line 69 of file messageStream.C.

◆ operator()() [3/6]

Foam::OSstream & operator() ( const char *  functionName,
const char *  sourceFileName,
const int  sourceFileLineNumber,
const string ioFileName,
const label  ioStartLineNumber = -1,
const label  ioEndLineNumber = -1 
)

Convert to OSstream.

Prints basic message and returns OSstream for further info.

Definition at line 85 of file messageStream.C.

References Foam::endl().

Here is the call graph for this function:

◆ operator()() [4/6]

Foam::OSstream & operator() ( const char *  functionName,
const char *  sourceFileName,
const int  sourceFileLineNumber,
const IOstream ioStream 
)

Convert to OSstream.

Prints basic message and returns OSstream for further info.

Definition at line 119 of file messageStream.C.

◆ operator()() [5/6]

Foam::OSstream & operator() ( const char *  functionName,
const char *  sourceFileName,
const int  sourceFileLineNumber,
const dictionary dict 
)

Convert to OSstream.

Prints basic message and returns OSstream for further info.

Definition at line 139 of file messageStream.C.

References dict, dictionary::endLineNumber(), dictionaryName::name(), and dictionary::startLineNumber().

Here is the call graph for this function:

◆ operator()() [6/6]

Foam::OSstream & operator() ( const label  communicator = -1)

Explicitly convert to OSstream for << operations.

Definition at line 159 of file messageStream.C.

References Foam::abort(), Foam::endl(), Foam::FatalError, FatalErrorInFunction, UPstream::master(), UPstream::parRun(), Foam::Pout, error::printStack(), Foam::Snull, Foam::Sout, UPstream::warnComm, and UPstream::worldComm.

Here is the call graph for this function:

◆ operator OSstream &()

operator OSstream & ( )
inline

Convert to OSstream for << operations.

Definition at line 186 of file messageStream.H.

References messageStream::operator()().

Here is the call graph for this function:

Member Data Documentation

◆ title_

string title_
protected

Definition at line 87 of file messageStream.H.

Referenced by messageStream::title().

◆ severity_

errorSeverity severity_
protected

Definition at line 88 of file messageStream.H.

◆ maxErrors_

int maxErrors_
protected

Definition at line 89 of file messageStream.H.

Referenced by messageStream::maxErrors().

◆ errorCount_

int errorCount_
protected

Definition at line 90 of file messageStream.H.

◆ level

int level
static

Definition at line 97 of file messageStream.H.

Referenced by Foam::operator<<(), and IOobject::setBad().


The documentation for this class was generated from the following files: