# SoDebugError.h

    00001 #ifndef COIN_SODEBUGERROR_H
    00002 #define COIN_SODEBUGERROR_H
    00003
    00004 /**************************************************************************\
    00005  *
    00006  *  This file is part of the Coin 3D visualization library.
    00007  *  Copyright (C) 1998-2003 by Systems in Motion.  All rights reserved.
    00008  *
    00009  *  This library is free software; you can redistribute it and/or
    00010  *  modify it under the terms of the GNU General Public License
    00011  *  ("GPL") version 2 as published by the Free Software Foundation.
    00012  *  See the file LICENSE.GPL at the root directory of this source
    00013  *  distribution for additional information about the GNU GPL.
    00014  *
    00015  *  For using Coin with software that can not be combined with the GNU
    00016  *  GPL, and for taking advantage of the additional benefits of our
    00017  *  support services, please contact Systems in Motion about acquiring
    00018  *  a Coin Professional Edition License.
    00019  *
    00020  *  See <URL:http://www.coin3d.org> for  more information.
    00021  *
    00022  *  Systems in Motion, Teknobyen, Abels Gate 5, 7030 Trondheim, NORWAY.
    00023  *  <URL:http://www.sim.no>.
    00024  *
    00025 \**************************************************************************/
    00026
    00027 #include <Inventor/errors/SoError.h>
    00028
    00029 // Avoid problem with Microsoft Win32 API headers (yes, they actually
    00030 // #define ERROR -- in wingdi.h).
    00031 #if defined(ERROR)
    00032 #define SODEBUGERROR_STORE_ERROR_DEF ERROR
    00033 #undef ERROR
    00034 #endif /* ERROR */
    00035
    00036
    00037 class COIN_DLL_API SoDebugError : public SoError {
    00038   typedef SoError inherited;
    00039
    00040 public:
    00041   enum Severity { ERROR, WARNING, INFO };
    00042
    00043   static void setHandlerCallback(SoErrorCB * const function,
    00044                                  void * const data);
    00045   static SoErrorCB * getHandlerCallback(void);
    00046   static void * getHandlerData(void);
    00047
    00048   static SoType getClassTypeId(void);
    00049   virtual SoType getTypeId(void) const;
    00050
    00051   SoDebugError::Severity getSeverity(void) const;
    00052
    00053   static void post(const char * const source, const char * const format, ...);
    00054   static void postWarning(const char * const source, const char * const format, ...);
    00055   static void postInfo(const char * const source, const char * const format, ...);
    00056
    00057   static void initClass(void);
    00058
    00059 protected:
    00060   virtual SoErrorCB * getHandler(void * & data) const;
    00061
    00062 private:
    00063   static void callbackForwarder(const struct cc_debugerror * error, void * data);
    00064   static void commonPostHandling(Severity severity, const char * type,
    00065                                  const char * source, const SbString & s);
    00066
    00067   static SoType classTypeId;
    00068   static SoErrorCB * callback;
    00069   static void * callbackData;
    00070   Severity severity;
    00071 };
    00072
    00073 // Avoid problem with Microsoft Win32 API headers (see above).
    00074 #if defined(SODEBUGERROR_STORE_ERROR_DEF)
    00075 #define ERROR SODEBUGERROR_STORE_ERROR_DEF
    00076 #undef SODEBUGERROR_STORE_ERROR_DEF
    00077 #endif /* SODEBUGERROR_STORE_ERROR_DEF */
    00078
    00079 #endif // !COIN_SODEBUGERROR_H