# SoError.h

    00001 #ifndef COIN_SOERROR_H
    00002 #define COIN_SOERROR_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/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