Coin Logo Coin3D is Free Software,
published under the BSD 3-clause license.
https://coin3d.github.io
https://www.kongsberg.com/en/kogt/
SoDebugError.h
1 #ifndef COIN_SODEBUGERROR_H
2 #define COIN_SODEBUGERROR_H
3 
4 /**************************************************************************\
5  * Copyright (c) Kongsberg Oil & Gas Technologies AS
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions are
10  * met:
11  *
12  * Redistributions of source code must retain the above copyright notice,
13  * this list of conditions and the following disclaimer.
14  *
15  * Redistributions in binary form must reproduce the above copyright
16  * notice, this list of conditions and the following disclaimer in the
17  * documentation and/or other materials provided with the distribution.
18  *
19  * Neither the name of the copyright holder nor the names of its
20  * contributors may be used to endorse or promote products derived from
21  * this software without specific prior written permission.
22  *
23  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
26  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
27  * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
29  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
30  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 \**************************************************************************/
35 
36 #include <Inventor/errors/SoError.h>
37 #include <Inventor/C/errors/debugerror.h>
38 
39 // Avoid problem with Microsoft Win32 API headers (yes, they actually
40 // #define ERROR -- in wingdi.h).
41 #if defined(ERROR)
42 #define SODEBUGERROR_STORE_ERROR_DEF
43 #pragma push_macro("ERROR")
44 #undef ERROR
45 #endif /* ERROR */
46 
47 
48 class COIN_DLL_API SoDebugError : public SoError {
49  typedef SoError inherited;
50 
51 public:
52  enum Severity { ERROR, WARNING, INFO };
53 
54  static void setHandlerCallback(SoErrorCB * const function,
55  void * const data);
56  static SoErrorCB * getHandlerCallback(void);
57  static void * getHandlerData(void);
58 
59  static SoType getClassTypeId(void);
60  virtual SoType getTypeId(void) const;
61 
62  SoDebugError::Severity getSeverity(void) const;
63 
64  static void post(const char * const source, const char * const format, ...);
65  static void postWarning(const char * const source, const char * const format, ...);
66  static void postInfo(const char * const source, const char * const format, ...);
67 
68  static void initClass(void);
69 
70 protected:
71  virtual SoErrorCBPtr getHandler(void * & data) const;
72 
73 private:
74  static void callbackForwarder(const struct cc_debugerror * error, void * data);
75  static void commonPostHandling(Severity severity, const char * type,
76  const char * source, const SbString & s);
77 
78  static SoType classTypeId;
79  static SoErrorCB * callback;
80  static void * callbackData;
81  Severity severity;
82 };
83 
84 // Avoid problem with Microsoft Win32 API headers (see above).
85 #if defined(SODEBUGERROR_STORE_ERROR_DEF)
86 #pragma pop_macro("ERROR")
87 #undef SODEBUGERROR_STORE_ERROR_DEF
88 #endif /* SODEBUGERROR_STORE_ERROR_DEF */
89 
90 #endif // !COIN_SODEBUGERROR_H
static void setHandlerCallback(SoErrorCB *const func, void *const data)
Definition: SoError.cpp:181
static void * getHandlerData(void)
Definition: SoError.cpp:213
virtual SoType getTypeId(void) const
Definition: SoError.cpp:154
Definition: debugerror.h:53
Definition: SoDebugError.h:52
virtual SoErrorCBPtr getHandler(void *&data) const
Definition: SoError.cpp:297
static void post(const char *const format,...)
Definition: SoError.cpp:236
static SoType getClassTypeId(void)
Definition: SoError.cpp:141
Severity
Definition: SoDebugError.h:52
The SoDebugError class is the internal debugging message passing mechanism.
Definition: SoDebugError.h:48
static SoErrorCB * getHandlerCallback(void)
Definition: SoError.cpp:203
The SoError class is the base class for all the error handling classes.
Definition: SoError.h:50
static void initClass(void)
Definition: SoError.cpp:115
The SbString class is a string class with convenience functions for string operations.
Definition: SbString.h:52
The SoType class is the basis for the runtime type system in Coin.
Definition: SoType.h:59