Commit e434b519 authored by Mark Olesen's avatar Mark Olesen
Browse files

Add namespace qualifier to WarningIn, FatalErrorIn, etc. macros.

- Previously had just 'Warning' instead of '::Foam::Warning', which
  meant that an identically named class method would inadvertently be
  used - resulting in a compile failure.
parent a5217d7b
......@@ -36,10 +36,6 @@ Description
#include "error.H"
#include "wchar.H"
// avoid confusion about which Warning is meant
#undef WarningIn
#define WarningIn(fn) Foam::Warning(fn, __FILE__, __LINE__)
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
......
......@@ -66,7 +66,7 @@ class calcEntry
public:
//- Runtime type information
ClassName("test");
ClassName("calc");
// Member Functions
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2008-2009 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -57,7 +57,9 @@ class StaticAssertionFailed<true>
template<unsigned Test>
class StaticAssertionTest {};
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
......
......@@ -62,7 +62,7 @@ Ostream& operator<<(Ostream&, const error&);
/*---------------------------------------------------------------------------*\
Class error Declaration
Class error Declaration
\*---------------------------------------------------------------------------*/
class error
......@@ -92,10 +92,10 @@ public:
error(const string& title);
//- Construct from dictionary
error(const dictionary& errDict);
error(const dictionary&);
//- Construct as copy
error(const error& err);
error(const error&);
// Destructor
......@@ -132,8 +132,8 @@ public:
throwExceptions_ = false;
}
//- Convert to Ostream
// Prints basic message and then returns Ostream for further info.
//- Convert to OSstream
// Prints basic message and returns OSstream for further info.
OSstream& operator()
(
const char* functionName,
......@@ -141,6 +141,8 @@ public:
const int sourceFileLineNumber = 0
);
//- Convert to OSstream
// Prints basic message and returns OSstream for further info.
OSstream& operator()
(
const string& functionName,
......@@ -148,11 +150,11 @@ public:
const int sourceFileLineNumber = 0
);
//- Convert to Ostream
// Prints basic message and then returns Ostream for further info.
//- Convert to OSstream
// Prints basic message and returns OSstream for further info.
operator OSstream&();
//- Explicitly convert to Ostream for << operations
//- Explicitly convert to OSstream for << operations
OSstream& operator()()
{
return operator OSstream&();
......@@ -163,14 +165,14 @@ public:
//- Helper function to print a stack
static void printStack(Ostream& os);
static void printStack(Ostream&);
//- Exit : can be called for any error to exit program. Prints stack
// before exiting.
//- Exit : can be called for any error to exit program.
// Prints stack before exiting.
void exit(const int errNo = 1);
//- Abort : used to stop code for fatal errors. Prints stack before
// exiting.
//- Abort : used to stop code for fatal errors.
// Prints stack before exiting.
void abort();
......@@ -181,9 +183,7 @@ public:
// Forward declaration of friend functions and operators
class IOerror;
Ostream& operator<<(Ostream&, const IOerror&);
......@@ -211,7 +211,7 @@ public:
IOerror(const string& title);
//- Construct from dictionary
IOerror(const dictionary& errDict);
IOerror(const dictionary&);
// Destructor
......@@ -236,8 +236,8 @@ public:
return ioEndLineNumber_;
}
//- Convert to Ostream
// Prints basic message and then returns Ostream for further info.
//- Convert to OSstream
// Prints basic message and returns OSstream for further info.
OSstream& operator()
(
const char* functionName,
......@@ -248,8 +248,8 @@ public:
const label ioEndLineNumber = -1
);
//- Convert to Ostream
// Prints basic message and then returns Ostream for further info.
//- Convert to OSstream
// Prints basic message and returns OSstream for further info.
OSstream& operator()
(
const char* functionName,
......@@ -258,8 +258,8 @@ public:
const IOstream&
);
//- Convert to Ostream
// Prints basic message and then returns Ostream for further info.
//- Convert to OSstream
// Prints basic message and returns OSstream for further info.
OSstream& operator()
(
const char* functionName,
......@@ -288,23 +288,46 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Global error declarations: defined in error.C
extern error FatalError;
extern error FatalError;
extern IOerror FatalIOError;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Convienient macros to add the file name and line number to the function name
#define FatalErrorIn(fn) FatalError(fn, __FILE__, __LINE__)
#define FatalIOErrorIn(fn, ios) FatalIOError(fn, __FILE__, __LINE__, ios)
// Call for functions which are not currently implemented.
// The functionName is printed and then abort is called.
#define notImplemented(fn) \
FatalErrorIn(fn) << "Not implemented" << Foam::abort(FatalError);
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// Convenience macros to add the file name and line number to the function name
/**
* @def FatalErrorIn(functionName)
* Report an error message using Foam::FatalError for functionName in
* file __FILE__ at line __LINE__
*/
#define FatalErrorIn(fn) \
::Foam::FatalError((fn), __FILE__, __LINE__)
/**
* @def FatalIOErrorIn(functionName, ios)
* Report an error message using Foam::FatalIOError for functionName in
* file __FILE__ at line __LINE__
* for a particular IOstream
*/
#define FatalIOErrorIn(fn, ios) \
::Foam::FatalIOError((fn), __FILE__, __LINE__, (ios))
/**
* @def notImplemented(functionName)
* Issue a FatalErrorIn for the functionName.
* This is used for functions that are not currently implemented.
* The functionName is printed and then abort is called.
*
* @note
* This macro can be particularly useful when methods must be defined to
* complete the interface of a derived class even if they should never be
* called for this derived class.
*/
#define notImplemented(fn) \
FatalErrorIn(fn) << "Not implemented" << ::Foam::abort(FatalError);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
......
......@@ -49,7 +49,6 @@ namespace Foam
{
// Forward declaration of friend functions and operators
template<class Err> class errorManip;
template<class Err> Ostream& operator<<(Ostream&, errorManip<Err>);
......@@ -59,7 +58,7 @@ Ostream& operator<<(Ostream&, errorManipArg<Err, T>);
/*---------------------------------------------------------------------------*\
Class errorManip Declaration
Class errorManip Declaration
\*---------------------------------------------------------------------------*/
template<class Err>
......@@ -89,7 +88,7 @@ inline Ostream& operator<<(Ostream& os, errorManip<Err> m)
/*---------------------------------------------------------------------------*\
Class errorManipArg Declaration
Class errorManipArg Declaration
\*---------------------------------------------------------------------------*/
//- errorManipArg
......@@ -123,23 +122,29 @@ inline Ostream& operator<<(Ostream& os, errorManipArg<Err, T> m)
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
inline errorManipArg<error, int> exit(error& err, const int errNo = 1)
inline errorManipArg<error, int>
exit(error& err, const int errNo = 1)
{
return errorManipArg<error, int>(&error::exit, err, errNo);
}
inline errorManip<error> abort(error& err)
inline errorManip<error>
abort(error& err)
{
return errorManip<error>(&error::abort, err);
}
inline errorManipArg<IOerror, int> exit(IOerror& err, const int errNo = 1)
inline errorManipArg<IOerror, int>
exit(IOerror& err, const int errNo = 1)
{
return errorManipArg<IOerror, int>(&IOerror::exit, err, errNo);
}
inline errorManip<IOerror> abort(IOerror& err)
inline errorManip<IOerror>
abort(IOerror& err)
{
return errorManip<IOerror>(&IOerror::abort, err);
}
......
......@@ -36,7 +36,8 @@ Description
Usage
@code
messageStream << "message1" << "message2" << FoamDataType << endl;
messageStream
<< "message1" << "message2" << FoamDataType << endl;
@endcode
SourceFiles
......@@ -55,6 +56,7 @@ SourceFiles
namespace Foam
{
// Forward declaration of classes
class IOstream;
class Ostream;
class OSstream;
......@@ -103,13 +105,13 @@ public:
messageStream
(
const string& title,
errorSeverity sev,
errorSeverity,
const int maxErrors = 0
);
//- Construct from dictionary
messageStream(const dictionary& dict);
messageStream(const dictionary&);
// Member functions
......@@ -133,8 +135,8 @@ public:
return maxErrors_;
}
//- Convert to Ostream
// Prints basic message and then returns Ostream for further info.
//- Convert to OSstream
// Prints basic message and returns OSstream for further info.
OSstream& operator()
(
const char* functionName,
......@@ -142,6 +144,8 @@ public:
const int sourceFileLineNumber = 0
);
//- Convert to OSstream
// Prints basic message and returns OSstream for further info.
OSstream& operator()
(
const string& functionName,
......@@ -149,8 +153,8 @@ public:
const int sourceFileLineNumber = 0
);
//- Convert to Ostream
// Prints basic message and then returns Ostream for further info.
//- Convert to OSstream
// Prints basic message and returns OSstream for further info.
OSstream& operator()
(
const char* functionName,
......@@ -161,8 +165,8 @@ public:
const label ioEndLineNumber = -1
);
//- Convert to Ostream
// Prints basic message and then returns Ostream for further info.
//- Convert to OSstream
// Prints basic message and returns OSstream for further info.
OSstream& operator()
(
const char* functionName,
......@@ -171,8 +175,8 @@ public:
const IOstream&
);
//- Convert to Ostream
// Prints basic message and then returns Ostream for further info.
//- Convert to OSstream
// Prints basic message and returns OSstream for further info.
OSstream& operator()
(
const char* functionName,
......@@ -181,10 +185,10 @@ public:
const dictionary&
);
//- Convert to Ostream for << operations
//- Convert to OSstream for << operations
operator OSstream&();
//- Explicitly convert to Ostream for << operations
//- Explicitly convert to OSstream for << operations
OSstream& operator()()
{
return operator OSstream&();
......@@ -199,18 +203,6 @@ extern messageStream SeriousError;
extern messageStream Warning;
extern messageStream Info;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Convienient macros to add the file name and line number to the function name
#define SeriousErrorIn(fn) SeriousError(fn, __FILE__, __LINE__)
#define SeriousIOErrorIn(fn, ios) SeriousError(fn, __FILE__, __LINE__, ios)
#define WarningIn(fn) Warning(fn, __FILE__, __LINE__)
#define IOWarningIn(fn, ios) Warning(fn, __FILE__, __LINE__, ios)
#define InfoIn(fn) Info(fn, __FILE__, __LINE__)
#define IOInfoIn(fn, ios) Info(fn, __FILE__, __LINE__, ios)
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
......@@ -219,6 +211,60 @@ extern messageStream Info;
#include "OSstream.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Convenience macros to add the file name and line number to the function name
/**
* @def SeriousErrorIn(functionName)
* Report an error message using Foam::SeriousError for functionName in
* file __FILE__ at line __LINE__
*/
#define SeriousErrorIn(fn) \
::Foam::SeriousError((fn), __FILE__, __LINE__)
/**
* @def SeriousIOErrorIn(functionName, ios)
* Report an IO error message using Foam::SeriousError for functionName in
* file __FILE__ at line __LINE__
* for a particular IOstream
*/
#define SeriousIOErrorIn(fn, ios) \
::Foam::SeriousError((fn), __FILE__, __LINE__, ios)
/**
* @def WarningIn(functionName)
* Report a warning using Foam::Warning for functionName in
* file __FILE__ at line __LINE__
*/
#define WarningIn(fn) \
::Foam::Warning((fn), __FILE__, __LINE__)
/**
* @def IOWarningIn(functionName, ios)
* Report an IO warning using Foam::Warning for functionName in
* file __FILE__ at line __LINE__
* for a particular IOstream
*/
#define IOWarningIn(fn, ios) \
::Foam::Warning((fn), __FILE__, __LINE__, (ios))
/**
* @def InfoIn(functionName)
* Report a information message using Foam::Info for functionName in
* file __FILE__ at line __LINE__
*/
#define InfoIn(fn) \
::Foam::Info((fn), __FILE__, __LINE__)
/**
* @def IOInfoIn(functionName, ios)
* Report an IO information message using Foam::Info for functionName in
* file __FILE__ at line __LINE__
* for a particular IOstream
*/
#define IOInfoIn(fn, ios) \
::Foam::Info((fn), __FILE__, __LINE__, (ios))
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment