00001
00002
00003
00004
00005 #ifndef RC_RESULT_H
00006 #define RC_RESULT_H
00007
00008
00009 static const char RC_RES_OK[] = "Everything is fine";
00010
00011 static const char RC_RES_WRN[] = "Undefined warning";
00012
00013 static const char RC_RES_ERR[] = "Undefined error";
00014
00015 static const char RC_RES_ERR_ASSERT[] = "Assert failed";
00016 static const char RC_RES_ERR_ARG[] = "Invalid argument";
00017 static const char RC_RES_ERR_MEM[] = "Out of memory";
00018
00020 typedef enum {
00021 RESULT_SUCCESS = 0x0000,
00022 RESULT_NEUTRAL,
00023 RESULT_WARNING,
00024 RESULT_ERROR,
00025 RESULT_FILE,
00026 RESULT_ASSERT
00027 } ResultType_t;
00028
00029 class Result {
00030
00031 public:
00032
00033 static void init();
00034
00035 static void release();
00036
00037
00038 static FILE *logfile;
00039
00040 };
00041
00042 #define SUCCESS(r) ((r) == RESULT_SUCCESS)
00043
00044 #define FAILURE(r) (!SUCCESS(r))
00045
00046
00047
00048
00049
00051 void ResultInit();
00052
00054 void ResultRelease();
00055
00056 void ResultSetOutputFunc(
00057 void (* textout)(i32, char *)
00058 );
00059
00061 void ResultReport(
00062 const char *file,
00063 const char *function,
00064 i32 line,
00065 ResultType_t type,
00066
00067 const char *str,
00068 ...
00069 );
00070
00071
00072
00074 void ResultUpdateMessage(
00075 u32 width
00076 );
00077
00078 #define REPORT(m, ...) ResultReport(__FILE__, __FUNCTION__, __LINE__, RESULT_NEUTRAL, (char *) (m), __VA_ARGS__)
00079 #define REPORT_WARNING(m, ...) ResultReport(__FILE__, __FUNCTION__, __LINE__, RESULT_WARNING, (char *) (m), __VA_ARGS__)
00080 #define REPORT_ERROR(m, ...) ResultReport(__FILE__, __FUNCTION__, __LINE__, RESULT_ERROR, (char *) (m), __VA_ARGS__)
00081 #define REPORT_FILE(m, ...) ResultReport(__FILE__, __FUNCTION__, __LINE__, RESULT_FILE, (char *) (m), __VA_ARGS__)
00082
00083
00084 #ifdef RC_ENABLE_ASSERT
00085
00086 #define ASSERT(m) if (!((u32) (m))) ResultReport(__FILE__, __FUNCTION__, __LINE__, RESULT_ASSERT, RC_RES_ERR_ASSERT)
00087
00088 #else
00089
00090 #define ASSERT(a)
00091
00092 #endif
00093
00094
00095
00096 #endif