00001 #ifndef SC_REPORT_H
00002 #define SC_REPORT_H 1
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053 #include <exception>
00054 #include <string>
00055
00056 namespace sc_core {
00057
00058
00059
00060
00061
00062
00063
00064 enum sc_severity {
00065 SC_INFO = 0,
00066 SC_WARNING,
00067 SC_ERROR,
00068 SC_FATAL,
00069 SC_MAX_SEVERITY
00070 };
00071
00072 typedef unsigned sc_actions;
00073
00074
00075
00076
00077
00078
00079
00080 enum {
00081 SC_UNSPECIFIED = 0x0000,
00082 SC_DO_NOTHING = 0x0001,
00083 SC_THROW = 0x0002,
00084 SC_LOG = 0x0004,
00085 SC_DISPLAY = 0x0008,
00086 SC_CACHE_REPORT = 0x0010,
00087 SC_INTERRUPT = 0x0020,
00088 SC_STOP = 0x0040,
00089 SC_ABORT = 0x0080
00090 };
00091
00092 class sc_object;
00093 class sc_time;
00094 struct sc_msg_def;
00095 class sc_report;
00096 const std::string sc_report_compose_message( const sc_report& );
00097
00098
00099
00100
00101
00102
00103
00104 class sc_report : public std::exception
00105 {
00106 public:
00107
00108 sc_report();
00109
00110 sc_report(const sc_report&);
00111
00112 sc_report & operator=(const sc_report&);
00113
00114 virtual ~sc_report() throw();
00115
00116 const char * get_msg_type() const;
00117
00118 const char * get_msg() const
00119 { return msg; }
00120
00121 sc_severity get_severity() const
00122 { return severity; }
00123
00124 const char * get_file_name() const
00125 { return file; }
00126
00127 int get_line_number() const
00128 { return line; }
00129
00130 const sc_time & get_time() const
00131 { return *timestamp; }
00132
00133 const char* get_process_name() const;
00134
00135 bool valid () const
00136 {
00137 return process != 0;
00138 }
00139
00140 virtual const char* what() const throw()
00141 {
00142 return m_what;
00143 }
00144
00145 protected:
00146
00147 friend class sc_report_handler;
00148
00149
00150 sc_report(sc_severity,
00151 const sc_msg_def*,
00152 const char* msg,
00153 const char* file,
00154 int line);
00155
00156
00157
00158 sc_severity severity;
00159 const sc_msg_def* md;
00160 char* msg;
00161 char* file;
00162 int line;
00163 sc_time* timestamp;
00164 sc_object* process;
00165 char* m_what;
00166
00167 public:
00168
00169 static const char* get_message(int id);
00170 static bool is_suppressed(int id);
00171 static void make_warnings_errors(bool);
00172 static void register_id(int id, const char* msg);
00173 static void suppress_id(int id, bool);
00174 static void suppress_infos(bool);
00175 static void suppress_warnings(bool);
00176
00177 int get_id() const;
00178 };
00179 typedef std::exception sc_exception;
00180
00181 #define SC_DEFAULT_INFO_ACTIONS (SC_LOG | SC_DISPLAY)
00182 #define SC_DEFAULT_WARNING_ACTIONS (SC_LOG | SC_DISPLAY)
00183 #define SC_DEFAULT_ERROR_ACTIONS (SC_LOG | SC_CACHE_REPORT | SC_THROW)
00184 #define SC_DEFAULT_FATAL_ACTIONS \
00185 (SC_LOG | SC_DISPLAY | SC_CACHE_REPORT | SC_ABORT)
00186
00187
00188
00189
00190
00191
00192
00193
00194 #define SC_REPORT_INFO(id,msg) \
00195 sc_core::sc_report_handler::report( \
00196 sc_core::SC_INFO, id, msg, __FILE__, __LINE__ )
00197
00198 #define SC_REPORT_WARNING(id,msg) \
00199 sc_core::sc_report_handler::report(\
00200 sc_core::SC_WARNING, id, msg, __FILE__, __LINE__)
00201
00202 #define SC_REPORT_ERROR(id,msg) \
00203 sc_core::sc_report_handler::report( \
00204 sc_core::SC_ERROR, id, msg, __FILE__, __LINE__ )
00205
00206 #define SC_REPORT_FATAL(id,msg) \
00207 sc_core::sc_report_handler::report( \
00208 sc_core::SC_FATAL, id, msg, __FILE__, __LINE__ )
00209
00210
00211
00212
00213
00214
00215
00216
00217 #ifdef NDEBUG
00218
00219 #define sc_assert(expr) \
00220 ((void) 0)
00221
00222 #else
00223
00224 #define sc_assert(expr) \
00225 ((void) ((expr) ? 0 : (SC_REPORT_FATAL( SC_ID_ASSERTION_FAILED_ , #expr ), 0)))
00226
00227 #endif
00228
00229 extern const char SC_ID_UNKNOWN_ERROR_[];
00230 extern const char SC_ID_WITHOUT_MESSAGE_[];
00231 extern const char SC_ID_NOT_IMPLEMENTED_[];
00232 extern const char SC_ID_INTERNAL_ERROR_[];
00233 extern const char SC_ID_ASSERTION_FAILED_[];
00234 extern const char SC_ID_OUT_OF_BOUNDS_[];
00235
00236
00237 extern const char SC_ID_REGISTER_ID_FAILED_[];
00238
00239 }
00240
00241 #include "sysc/utils/sc_report_handler.h"
00242
00243 #endif // SC_REPORT_H