Open Inventor Release 2024.2.1
 
Loading...
Searching...
No Matches
SoError.h
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-2024 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>
54#include <Inventor/SoTypedObject.h>
55
56class SoError;
57class SoBase;
58class SoEngine;
59class SoNode;
60class SoPath;
61
69typedef void SoErrorCB(const SoError *error, void *data);
70
109class SoError: public SoTypedObject {
110
111 public:
115 static void setHandlerCallback(SoErrorCB *cb, void *data);
125 static void* getHandlerData();
126
130 const SbString& getDebugString() const { return debugString; }
131
136
140 virtual SoType getTypeId() const;
141
145 virtual ~SoError() {}
146
151 SoPRINTF static void post(const char *formatString ...);
152
153 private:
154 // Initializes SoError class
155 static void initClass();
156 static void exitClass();
157
158 static SoErrorCB* getDefaultHandlerCB() { return defaultHandlerCB; }
159
160 private:
161 // The default error handler callback - it just prints to stderr
162 static void defaultHandlerCB(const SoError *error, void *data);
163
164 // Returns handler callback (and data) to use for a given instance
165 virtual SoErrorCB * getHandler(void *&data) const;
166 virtual bool isInit() const;
167
168 // Sets/appends to the debug string
169 void setDebugString(const SbString& string)
170 { debugString = string; }
171 void appendToDebugString(const SbString& string)
172 { debugString += string; }
173
174 // Calls appropriate handler for an error instance. Application
175 // writers can set breakpoints at this when debugging.
176 void handleError();
177
182 virtual void setDebugStringCapacity( int capacity );
183
184 private:
185 // Type id of SoError class
186 static SoType classTypeId;
187 // Handler callback for SoError class
188 static SoErrorCB *handlerCB;
189 // User data for callback
190 static void *cbData;
191 // TRUE if handler initialized
192 static SbBool wasInitted;
193 // Detailed error message string
194 SbString debugString;
195 // The getString() methods use this one
196 static SbString getBaseString(const SoBase *base, const char *what);
197 // allow to disable user error handler and keep everything in stderr.
198 // see SoPreferences env var OIV_FORCE_DEFAULT_ERROR_HANDLER
199 static SbBool s_forceDefaultHandler;
200};
201
202#endif /* _SO_ERROR */
203
204
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:109
void SoErrorCB(const SoError *error, void *data)
Error handling callbacks are of this type.
Definition SoError.h:69
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:145
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:130
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