00001 #ifndef __J2K__ErrorHandler_HPP__ 00002 #define __J2K__ErrorHandler_HPP__ 00003 00004 /* 00005 We can't use JString or any other J2K classes, since we are not sure, 00006 where the error occured and so, we can only rely on ourself ! 00007 Hoping that this class works well... =) 00008 00009 We are using a single forward link-list of " void function( ARG ) ", 00010 the function must be public and static inside or outside a class, 00011 even if an object of that class was not build anywhere. 00012 It might look "weird" but it's VERY convenient! =] 00013 */ 00014 00015 #include <j2k/Fred/Standard.hpp> 00016 #include <j2k/Fred/Error/JError.hpp> 00017 00018 #define MC_JErrorHandlerArg \ 00019 JErrorLevel level, \ 00020 JErrorNo no, \ 00021 const char* errmsg, \ 00022 int line, \ 00023 const char* file 00024 00025 00026 typedef void ( *JErrorHandlerCallback_t )( MC_JErrorHandlerArg ); 00027 00028 __J2K__EXTERN_C 00029 00030 static void defaultErrorHandler( MC_JErrorHandlerArg ); 00031 static void cheapError( int line, const char* file, const char* errmsg ); 00032 00033 __J2K__END_C 00034 00035 class JErrorHandler; 00036 00037 class JErrorHandler { 00038 public: 00039 short id; 00040 00041 // The "next" pointer for the link-list of Handler 00042 JErrorHandler* next; 00043 00044 // The " void function() " element 00045 // Simply assign: 00046 // elem = newHandler 00047 00048 JErrorHandlerCallback_t elem; 00049 00050 00051 // void (*elem)( MC_JErrorHandlerArg ); 00052 00053 public: 00054 inline JErrorHandler( const JErrorHandler& h ); 00055 inline JErrorHandler(); 00056 00057 inline JErrorHandler( JErrorHandlerCallback_t newHandler ); 00058 inline JErrorHandler( JErrorHandlerCallback_t newHandler, JErrorHandler* Next ); 00059 inline JErrorHandler( JErrorHandlerCallback_t newHandler, JErrorHandler* Next, short i ); 00060 00061 virtual ~JErrorHandler(); 00062 00063 }; 00064 00065 #include <j2k/Fred/Error/JErrorHandler.inl> 00066 00067 #endif