Open Inventor Release 2023.2.3
 
Loading...
Searching...
No Matches
SoError.h
Go to the documentation of this file.
1/*=======================================================================
2 * Copyright 1991-1996, Silicon Graphics, Inc.
3 * ALL RIGHTS RESERVED
4 *
5 * UNPUBLISHED -- Rights reserved under the copyright laws of the United
6 * States. Use of a copyright notice is precautionary only and does not
7 * imply publication or disclosure.
8 *
9 * U.S. GOVERNMENT RESTRICTED RIGHTS LEGEND:
10 * Use, duplication or disclosure by the Government is subject to restrictions
11 * as set forth in FAR 52.227.19(c)(2) or subparagraph (c)(1)(ii) of the Rights
12 * in Technical Data and Computer Software clause at DFARS 252.227-7013 and/or
13 * in similar or successor clauses in the FAR, or the DOD or NASA FAR
14 * Supplement. Contractor/manufacturer is Silicon Graphics, Inc.,
15 * 2011 N. Shoreline Blvd. Mountain View, CA 94039-7311.
16 *
17 * THE CONTENT OF THIS WORK CONTAINS CONFIDENTIAL AND PROPRIETARY
18 * INFORMATION OF SILICON GRAPHICS, INC. ANY DUPLICATION, MODIFICATION,
19 * DISTRIBUTION, OR DISCLOSURE IN ANY FORM, IN WHOLE, OR IN PART, IS STRICTLY
20 * PROHIBITED WITHOUT THE PRIOR EXPRESS WRITTEN PERMISSION OF SILICON
21 * GRAPHICS, INC.
22**=======================================================================*/
23/*=======================================================================
24** Author : Paul S. Strauss (MMM yyyy)
25**=======================================================================*/
26/*=======================================================================
27 *** THE CONTENT OF THIS WORK IS PROPRIETARY TO FEI S.A.S, (FEI S.A.S.), ***
28 *** AND IS DISTRIBUTED UNDER A LICENSE AGREEMENT. ***
29 *** ***
30 *** REPRODUCTION, DISCLOSURE, OR USE, IN WHOLE OR IN PART, OTHER THAN AS ***
31 *** SPECIFIED IN THE LICENSE ARE NOT TO BE UNDERTAKEN EXCEPT WITH PRIOR ***
32 *** WRITTEN AUTHORIZATION OF FEI S.A.S. ***
33 *** ***
34 *** RESTRICTED RIGHTS LEGEND ***
35 *** USE, DUPLICATION, OR DISCLOSURE BY THE GOVERNMENT OF THE CONTENT OF THIS ***
36 *** WORK OR RELATED DOCUMENTATION IS SUBJECT TO RESTRICTIONS AS SET FORTH IN ***
37 *** SUBPARAGRAPH (C)(1) OF THE COMMERCIAL COMPUTER SOFTWARE RESTRICTED RIGHT ***
38 *** CLAUSE AT FAR 52.227-19 OR SUBPARAGRAPH (C)(1)(II) OF THE RIGHTS IN ***
39 *** TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 52.227-7013. ***
40 *** ***
41 *** COPYRIGHT (C) 1996-2014 BY FEI S.A.S, ***
42 *** BORDEAUX, FRANCE ***
43 *** ALL RIGHTS RESERVED ***
44**=======================================================================*/
45/*=======================================================================
46** Modified by : VSG (Feb 2010)
47**=======================================================================*/
48
49#ifndef _SO_ERROR
50#define _SO_ERROR
51
52#include <Inventor/SbBase.h>
53#include <Inventor/SbString.h>
55
56class SoError;
57class SoBase;
58class SoEngine;
59class SoNode;
60class SoPath;
61
66typedef void SoErrorCB(const SoError *error, void *data);
67
106class SoError: public SoTypedObject {
107
108 public:
112 static void setHandlerCallback(SoErrorCB *cb, void *data);
122 static void* getHandlerData();
123
127 const SbString& getDebugString() const { return debugString; }
128
133
137 virtual SoType getTypeId() const;
138
142 virtual ~SoError() {}
143
148 SoPRINTF static void post(const char *formatString ...);
149
150 private:
151 // Initializes SoError class
152 static void initClass();
153 static void exitClass();
154
155 static SoErrorCB* getDefaultHandlerCB() { return defaultHandlerCB; }
156
157 private:
158 // The default error handler callback - it just prints to stderr
159 static void defaultHandlerCB(const SoError *error, void *data);
160
161 // Returns handler callback (and data) to use for a given instance
162 virtual SoErrorCB * getHandler(void *&data) const;
163 virtual bool isInit() const;
164
165 // Sets/appends to the debug string
166 void setDebugString(const SbString& string)
167 { debugString = string; }
168 void appendToDebugString(const SbString& string)
169 { debugString += string; }
170
171 // Calls appropriate handler for an error instance. Application
172 // writers can set breakpoints at this when debugging.
173 void handleError();
174
179 virtual void setDebugStringCapacity( int capacity );
180
181 private:
182 // Type id of SoError class
183 static SoType classTypeId;
184 // Handler callback for SoError class
185 static SoErrorCB *handlerCB;
186 // User data for callback
187 static void *cbData;
188 // TRUE if handler initialized
189 static SbBool wasInitted;
190 // Detailed error message string
191 SbString debugString;
192 // The getString() methods use this one
193 static SbString getBaseString(const SoBase *base, const char *what);
194 // allow to disable user error handler and keep everything in stderr.
195 // see SoPreferences env var OIV_FORCE_DEFAULT_ERROR_HANDLER
196 static SbBool s_forceDefaultHandler;
197};
198
199#endif /* _SO_ERROR */
200
201
void SoErrorCB(const SoError *error, void *data)
Error handling callbacks are of this type.
Definition SoError.h:66
Class for smart character strings.
Definition SbString.h:202
Base class for all nodes, paths, and engines.
Definition SoBase.h:111
Base class for all engines.
Definition SoEngine.h:133
Error handling base class.
Definition SoError.h:106
static SoType getClassTypeId()
Returns type identifier for SoError class.
virtual SoType getTypeId() const
Returns type identifier for error instance.
virtual ~SoError()
Destructor.
Definition SoError.h:142
static SoPRINTF void post(const char *formatString ...)
Posts an error.
static void * getHandlerData()
Returns handler data for SoError class.
static void setHandlerCallback(SoErrorCB *cb, void *data)
Sets handler callback for SoError class.
static SoErrorCB * getHandlerCallback()
Returns handler callback for SoError class.
const SbString & getDebugString() const
Returns debug string containing full error information from instance.
Definition SoError.h:127
Abstract base class for all database nodes.
Definition SoNode.h:145
Path that points to a list of hierarchical nodes.
Definition SoPath.h:187
Stores runtime type information.
Definition SoType.h:98
Base class for object storing runtime type information.
int SbBool
Boolean type.
Definition SbBase.h:87