MeVisLab Toolbox Reference
Loading...
Searching...
No Matches
mlErrorOutputInfos.h
Go to the documentation of this file.
1/*************************************************************************************
2**
3** Copyright 2007, MeVis Medical Solutions AG
4**
5** The user may use this file in accordance with the license agreement provided with
6** the Software or, alternatively, in accordance with the terms contained in a
7** written agreement between the user and MeVis Medical Solutions AG.
8**
9** For further information use the contact form at https://www.mevislab.de/contact
10**
11**************************************************************************************/
12
13#ifndef ML_ERROR_OUTPUT_INFOS_H
14#define ML_ERROR_OUTPUT_INFOS_H
15
17
38#include "mlDateTime.h"
39#include "mlErrorMacros.h"
40#include "mlErrorOutput.h"
41#include "mlUtilsSystem.h"
42
44
45//---------------------------------------------------------------------------------------------
51//---------------------------------------------------------------------------------------------
53{
54public:
57 {
58 messageType = ML_WARNING;
59 errorCode = ML_RESULT_OK;
60 libraryPrefix = ML_PREFIX;
61 fPrefix = "";
62 functionName = "";
63 reason = "";
64 handling = "";
65 file = "";
66 time = DateTime().now();
67 line = 0;
68 }
69
72 {
73 *this = ei;
74 }
75
78 {
79 messageType = ei.messageType;
80 errorCode = ei.errorCode;
81 libraryPrefix = ei.libraryPrefix;
82 fPrefix = ei.fPrefix;
83 functionName = ei.functionName;
84 reason = ei.reason;
85 handling = ei.handling;
86 file = ei.file;
87 time = ei.time;
88 line = ei.line;
89 return *this;
90 }
91
94 {
95 return messageType;
96 }
97
100 {
101 return errorCode;
102 }
103
105 inline const char* getLibraryPrefix() const
106 {
107 return libraryPrefix.c_str();
108 }
109
111 inline const char* getFunctionPrefix() const
112 {
113 return fPrefix.c_str();
114 }
115
117 inline const char* getFunctionName() const
118 {
119 return functionName.c_str();
120 }
121
123 inline const char* getReason() const
124 {
125 return reason.c_str();
126 }
127
129 inline const char* getHandling() const
130 {
131 return handling.c_str();
132 }
133
135 inline const char* getFile() const
136 {
137 return file.c_str();
138 }
139
141 inline const DateTime& getTime() const
142 {
143 return time;
144 }
145
147 inline int getLine() const
148 {
149 return line;
150 }
151
152protected:
153 // The following members are only set by the friend class \c ErrorOutput
154 // to avoid undesired modifications from outside.
155
157 friend class ErrorOutput;
158
161
164
167 std::string libraryPrefix;
168
170 std::string fPrefix;
171
173 std::string functionName;
174
176 std::string reason;
177
179 std::string handling;
180
182 std::string file;
183
186
188 int line;
189};
190
192
193//-----------------------------------------------------------------------------------
194// Stream output for std::ostream
195//-----------------------------------------------------------------------------------
196namespace std
197{
198
200 inline ostream& operator<<(ostream& s, const ML_UTILS_NAMESPACE::ErrorOutputInfos& eoi)
201 {
202 return s << "Message type :" << eoi.getMessageType() << endl
203 << "Error Code :" << eoi.getErrorCode() << endl
204 << "Library Prefix :" << eoi.getLibraryPrefix() << endl
205 << "Function Prefix:" << eoi.getFunctionPrefix() << endl
206 << "Function Name :" << eoi.getFunctionName() << endl
207 << "Reason :" << eoi.getReason() << endl
208 << "Handling :" << eoi.getHandling() << endl
209 << "File Name :" << eoi.getFile() << endl
210 << "Time Stamp :" << eoi.getTime() << endl
211 <<
212 // Cast to MLint32 to avoid non unique << operators on 64-bit compilation.
213 "Line Number :" << eoi.getLine() << endl;
214 }
215
216} // namespace std
217
218#endif // End of __mlErrorOutputInfos_H
Class for performing date/time arithmetic, comparisons and formatting.
Definition mlDateTime.h:142
DateTime & now()
Struct that contains all information about errors, fatal errors, warnings, information,...
const char * getFunctionName() const
Returns the name of function which caused this error/debug/warning/information or tracing print.
MLMessageType messageType
The type of information represented by this class.
const char * getFile() const
Returns the name of the file which caused this error/debug/warning/information or tracing print.
int line
Line number which caused this error/debug/warning/information or tracing print.
std::string file
File which caused this error/debug/warning/information or tracing print.
ErrorOutputInfos & operator=(const ErrorOutputInfos &ei)
Assignment operator to get identical copy.
MLMessageType getMessageType() const
Returns the type of information represented by this class.
const char * getLibraryPrefix() const
Returns the prefix string to indicate the library from where the message comes (e....
ErrorOutputInfos()
Default constructor.
std::string handling
How the routine handled the error.
std::string reason
Reason why the this error/debug/warning/information or tracing occurs.
MLErrorCode getErrorCode() const
ErrorCode. If not set, ML_RESULT_OK is set.
const DateTime & getTime() const
Returns the time stamp when message arrived.
const char * getHandling() const
Returns how the routine handled the error.
std::string functionName
Name of function which caused this error/debug/warning/information or tracing print.
DateTime time
Time stamp when message arrived.
ErrorOutputInfos(const ErrorOutputInfos &ei)
Copy constructor.
std::string libraryPrefix
Library prefix to indicate the library from where the message comes.
const char * getFunctionPrefix() const
Returns the prefix string to be printed before the function.
MLErrorCode errorCode
ErrorCode. If not set then ML_RESULT_OK is set.
std::string fPrefix
Prefix string to be printed before the function.
int getLine() const
Returns the line number which caused this error/debug/warning/information or tracing print.
const char * getReason() const
Returns the reason why the this error/debug/warning/information or tracing print occurs.
Class to handle all ML debug prints, errors, warnings, and information.
#define ML_PREFIX
Library identification prefix for messages from the ML.
Definition mlTypeDefs.h:81
MLint32 MLErrorCode
Type of an ML Error code.
Definition mlTypeDefs.h:772
#define ML_RESULT_OK
No error. Everything seems to be okay.
Definition mlTypeDefs.h:780
Target mlrange_cast(Source arg)
Generic version of checked ML casts.
MLMessageType
Message types handled by the ErrorOutput class.
Definition mlTypeDefs.h:750
@ ML_WARNING
Definition mlTypeDefs.h:751
STL namespace.
MLEXPORT std::ostream & operator<<(std::ostream &s, const ml::Field &v)
Overloads the operator '<<' for stream output of Field objects.