MeVisLab Toolbox Reference
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 
43 ML_UTILS_START_NAMESPACE
44 
45 //---------------------------------------------------------------------------------------------
51 //---------------------------------------------------------------------------------------------
53 public:
54 
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 
71  inline ErrorOutputInfos(const ErrorOutputInfos &ei) { *this = ei; }
72 
75  {
76  messageType = ei.messageType;
77  errorCode = ei.errorCode;
78  libraryPrefix = ei.libraryPrefix;
79  fPrefix = ei.fPrefix;
80  functionName = ei.functionName;
81  reason = ei.reason;
82  handling = ei.handling;
83  file = ei.file;
84  time = ei.time;
85  line = ei.line;
86  return *this;
87  }
88 
90  inline MLMessageType getMessageType() const { return messageType; }
91 
93  inline MLErrorCode getErrorCode() const { return errorCode; }
94 
96  inline const char* getLibraryPrefix() const { return libraryPrefix.c_str(); }
97 
99  inline const char* getFunctionPrefix() const { return fPrefix.c_str(); }
100 
102  inline const char* getFunctionName() const { return functionName.c_str(); }
103 
105  inline const char* getReason() const { return reason.c_str(); }
106 
108  inline const char* getHandling() const { return handling.c_str(); }
109 
111  inline const char* getFile() const { return file.c_str(); }
112 
114  inline const DateTime& getTime() const { return time; }
115 
117  inline int getLine() const { return line; }
118 
119 protected:
120  // The following members are only set by the friend class \c ErrorOutput
121  // to avoid undesired modifications from outside.
122 
124  friend class ErrorOutput;
125 
128 
131 
134  std::string libraryPrefix;
135 
137  std::string fPrefix;
138 
140  std::string functionName;
141 
143  std::string reason;
144 
146  std::string handling;
147 
149  std::string file;
150 
153 
155  int line;
156 
157 
158 #if ML_DEPRECATED_SINCE(3,5,0)
159 
162 
163 public:
164 
167  inline ML_DEPRECATED const char* getFPrefix() const { return getFunctionPrefix(); }
168 
170 
171 #endif
172 
173 };
174 
175 ML_UTILS_END_NAMESPACE
176 
177 //-----------------------------------------------------------------------------------
178 // Stream output for std::ostream
179 //-----------------------------------------------------------------------------------
180 namespace std
181 {
182 
184  inline ostream& operator<<(ostream& s, const ML_UTILS_NAMESPACE::ErrorOutputInfos &eoi)
185  {
186  return s << "Message type :" << eoi.getMessageType() << endl <<
187  "Error Code :" << eoi.getErrorCode() << endl <<
188  "Library Prefix :" << eoi.getLibraryPrefix() << endl <<
189  "Function Prefix:" << eoi.getFunctionPrefix() << endl <<
190  "Function Name :" << eoi.getFunctionName() << endl <<
191  "Reason :" << eoi.getReason() << endl <<
192  "Handling :" << eoi.getHandling() << endl <<
193  "File Name :" << eoi.getFile() << endl <<
194  "Time Stamp :" << eoi.getTime() << endl <<
195  // Cast to MLint32 to avoid non unique << operators on 64 bit compilation.
196  "Line Number :" << eoi.getLine() << endl;
197  }
198 
199 }
200 
201 #endif // End of __mlErrorOutputInfos_H
#define ML_DEPRECATED
Definition: CSOGroup.h:371
Class for performing date/time arithmetic, comparisons and formatting.
Definition: mlDateTime.h:142
Struct which contains all information about errors, fatal errors, warnings, information or debug prin...
MLMessageType messageType
Which type of information is represented by this class.
const DateTime & getTime() const
Returns the time stamp when message arrived.
const char * getFile() const
Returns the name of the file which caused this error/debug/warning/information or tracing print.
const char * getHandling() const
Returns how the routine handled the error.
const char * getLibraryPrefix() const
Returns the prefix string to indicate the library from where the message comes (e....
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.
MLMessageType getMessageType() const
Returns which type of information is represented by this class.
ErrorOutputInfos()
Default constructor.
std::string handling
How the routine handled the error.
const char * getFunctionPrefix() const
Returns the prefix string to be printed before the function.
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.
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.
const char * getFunctionName() const
Returns the name of function which caused this error/debug/warning/information or tracing print.
std::string libraryPrefix
Library prefix to indicate the library from where the message comes.
const char * getReason() const
Returns the reason why the this error/debug/warning/information or tracing print occurs.
MLErrorCode errorCode
ErrorCode. If not set then ML_RESULT_OK is set.
std::string fPrefix
Prefix string to be printed before the function.
ErrorOutputInfos & operator=(const ErrorOutputInfos &ei)
Assignment operator to get identical copy.
int getLine() const
Returns the line number which caused this error/debug/warning/information or tracing print.
Class to handle all ML debug prints, errors, warnings, and information.
Definition: mlErrorOutput.h:93
#define ML_PREFIX
Library identification prefix for messages from the ML.
Definition: mlTypeDefs.h:86
MLint32 MLErrorCode
Type of an ML Error code.
Definition: mlTypeDefs.h:818
#define ML_RESULT_OK
No error. Everything seems to be okay.
Definition: mlTypeDefs.h:826
MLEXPORT std::ostream & operator<<(std::ostream &s, const ml::Field &v)
Overloads the operator "<<" for stream output of Field objects.
MLMessageType
Message types handled by the ErrorOutput class.
Definition: mlTypeDefs.h:798
@ ML_WARNING
Definition: mlTypeDefs.h:798
std::pair< Date, Time > DateTime
DateTime.
Definition: DCMTree_Lib.h:201