00001 #ifndef COIN_SOERROR_H
00002 #define COIN_SOERROR_H
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 #include <Inventor/SbBasic.h>
00028 #include <Inventor/SbString.h>
00029 #include <Inventor/C/errors/error.h>
00030 #include <Inventor/SoType.h>
00031
00032 class SoBase;
00033 class SoNode;
00034 class SoPath;
00035 class SoEngine;
00036
00037 typedef void SoErrorCB(const class SoError * error, void * data);
00038
00039
00040 class COIN_DLL_API SoError {
00041 public:
00042 SoError(void) { cc_error_init(&this->err); }
00043 virtual ~SoError() { cc_error_clean(&this->err); }
00044
00045 static void setHandlerCallback(SoErrorCB * const func, void * const data);
00046 static SoErrorCB * getHandlerCallback(void);
00047 static void * getHandlerData(void);
00048
00049 const SbString & getDebugString(void) const;
00050
00051 static SoType getClassTypeId(void);
00052 virtual SoType getTypeId(void) const;
00053 SbBool isOfType(const SoType type) const;
00054
00055 static void post(const char * const format, ...);
00056
00057 static SbString getString(const SoNode * const node);
00058 static SbString getString(const SoPath * const path);
00059 static SbString getString(const SoEngine * const engine);
00060
00061 static void initClass(void);
00062 static void initClasses(void);
00063
00064 protected:
00065 static void defaultHandlerCB(const SoError * error, void * userdata);
00066 virtual SoErrorCB * getHandler(void * & data) const;
00067
00068 void setDebugString(const char * const str);
00069 void appendToDebugString(const char * const str);
00070
00071 void handleError(void);
00072
00073 private:
00074 SoError(const cc_error * error);
00075 static void generateBaseString(SbString & str, const SoBase * const base,
00076 const char * const what);
00077
00078 static void callbackForwarder(const cc_error * err, void * data);
00079
00080 static SoType classTypeId;
00081 static SoErrorCB * callback;
00082 static void * callbackData;
00083 SbString debugstring;
00084
00085 cc_error err;
00086 };
00087
00088 #endif // !COIN_SOERROR_H