00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00037 #ifndef RC_REPORT_H_
00038 #define RC_REPORT_H_
00039
00040 #include <cstring>
00041 #include <sstream>
00042
00043 #include <systemc.h>
00044
00045 #if !defined(RC_DISABLE_COUT)
00046
00053 #define RC_COUT(msg) std::cout << msg; (void)0
00054
00061 #define RC_COUTL(msg) std::cout << msg << std::endl; (void)0
00062 #else
00063 #define RC_COUT(msg) (void)0
00064 #define RC_COUTL(msg) (void)0
00065 #endif // !defined(RC_DISABLE_COUT)
00066
00069 #define RC_REPORT_MSG_TYPE "/ReChannel"
00070
00073 #define RC_REPORT_INFO(msg_type, msg) \
00074 if (true) { \
00075 std::stringstream sstream; \
00076 sstream << msg; \
00077 SC_REPORT_INFO(msg_type, sstream.str().c_str()); \
00078 } else (void)0
00079
00082 #define RC_REPORT_WARNING(msg_type, msg) \
00083 if (true) { \
00084 std::stringstream sstream; \
00085 sstream << msg; \
00086 SC_REPORT_WARNING(msg_type, sstream.str().c_str()); \
00087 } else (void)0
00088
00091 #define RC_REPORT_ERROR(msg_type, msg) \
00092 if (true) { \
00093 std::stringstream sstream; \
00094 sstream << msg; \
00095 SC_REPORT_ERROR(msg_type, sstream.str().c_str()); throw 0; \
00096 } else (void)0
00097
00100 #define RC_REPORT_FATAL(msg_type, msg) \
00101 if (true) { \
00102 std::stringstream sstream; \
00103 sstream << msg; \
00104 sc_report_handler::force(SC_ABORT); \
00105 SC_REPORT_FATAL(msg_type, sstream.str().c_str()); throw 0; \
00106 } else (void)0
00107
00108 #ifdef RC_DEBUG
00109
00111 #define rc_assert(expr) \
00112 ((void)((expr) \
00113 ? 0 : (SC_REPORT_FATAL(RC_ID_ASSERTION_FAILED_, #expr), 0)))
00114 #else
00115 #define rc_assert(expr) \
00116 (void)0
00117 #endif
00118
00119 #ifndef RC_DEBUG_LEVEL
00120
00124 #define RC_DEBUG_LEVEL 3
00125 #endif
00126
00127 #ifdef RC_DEBUG
00128
00129 #define RC_REPORT_DEBUG(msg) RC_REPORT_INFO(RC_ID_DEBUG_MSG_, msg)
00130 #else
00131 #define RC_REPORT_DEBUG(msg) (void)0
00132 #endif
00133
00134 #if defined(RC_DEBUG) && RC_DEBUG_LEVEL >= 1
00135
00136 #define RC_REPORT_DEBUG_1(msg) RC_REPORT_INFO(RC_ID_DEBUG_MSG_LVL_1_, msg)
00137 #else
00138 #define RC_REPORT_DEBUG_1(msg) (void)0
00139 #endif
00140
00141 #if defined(RC_DEBUG) && RC_DEBUG_LEVEL >= 2
00142
00143 #define RC_REPORT_DEBUG_2(msg) RC_REPORT_INFO(RC_ID_DEBUG_MSG_LVL_2_, msg)
00144 #else
00145 #define RC_REPORT_DEBUG_2(msg) (void)0
00146 #endif
00147
00148 #if defined(RC_DEBUG) && RC_DEBUG_LEVEL >= 3
00149
00150 #define RC_REPORT_DEBUG_3(msg) RC_REPORT_INFO(RC_ID_DEBUG_MSG_LVL_3_, msg)
00151 #else
00152 #define RC_REPORT_DEBUG_3(msg) (void)0
00153 #endif
00154
00155 #if defined(RC_DEBUG) && RC_DEBUG_LEVEL >= 4
00156
00157 #define RC_REPORT_DEBUG_4(msg) RC_REPORT_INFO(RC_ID_DEBUG_MSG_LVL_4_, msg)
00158 #else
00159 #define RC_REPORT_DEBUG_4(msg) (void)0
00160 #endif
00161
00162 #if defined(RC_DEBUG) && RC_DEBUG_LEVEL >= 5
00163
00164 #define RC_REPORT_DEBUG_5(msg) RC_REPORT_INFO(RC_ID_DEBUG_MSG_LVL_5_, msg)
00165 #else
00166 #define RC_REPORT_DEBUG_5(msg) (void)0
00167 #endif
00168
00169 namespace ReChannel {
00170
00171
00173 extern const char RC_ID_INTERNAL_ERROR_[];
00175 extern const char RC_ID_UNKNOWN_ERROR_[];
00177 extern const char RC_ID_NOT_IMPLEMENTED_[];
00179 extern const char RC_ID_OUT_OF_BOUNDS_[];
00181 extern const char RC_ID_NULL_POINTER_[];
00183 extern const char RC_ID_INVALID_USAGE_[];
00185 extern const char RC_ID_DUPLICATE_ENTRY_[];
00187 extern const char RC_ID_ASSERTION_FAILED_[];
00188
00190 extern const char RC_ID_DEBUG_MSG_[];
00192 extern const char RC_ID_DEBUG_MSG_LVL_1_[];
00194 extern const char RC_ID_DEBUG_MSG_LVL_2_[];
00196 extern const char RC_ID_DEBUG_MSG_LVL_3_[];
00198 extern const char RC_ID_DEBUG_MSG_LVL_4_[];
00200 extern const char RC_ID_DEBUG_MSG_LVL_5_[];
00201
00205 template<bool Assertion>
00206 class rc_static_assertion;
00207
00212 template<>
00213 class rc_static_assertion<true>
00214 { public: typedef bool fulfilled; };
00215
00220 template<>
00221 class rc_static_assertion<false>
00222 { public: typedef bool failed; };
00223
00224 }
00225
00230 #define RC_STATIC_ASSERT(name_, assertion_) \
00231 typedef ::ReChannel::rc_static_assertion< \
00232 (bool)(assertion_) \
00233 >::fulfilled RC_STATIC_ASSERT_##name_
00234
00239 #define RC_STATIC_ASSERT_T(name_, assertion_) \
00240 typedef typename ::ReChannel::template rc_static_assertion< \
00241 (bool)(assertion_) \
00242 >::fulfilled RC_STATIC_ASSERT_##name_
00243
00244 #endif // RC_REPORT_H_
00245
00246
00247
00248
00249