Point Cloud Library (PCL)  1.8.1
opennurbs_error.h
1 /* $NoKeywords: $ */
2 /*
3 //
4 // Copyright (c) 1993-2012 Robert McNeel & Associates. All rights reserved.
5 // OpenNURBS, Rhinoceros, and Rhino3D are registered trademarks of Robert
6 // McNeel & Associates.
7 //
8 // THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
9 // ALL IMPLIED WARRANTIES OF FITNESS FOR ANY PARTICULAR PURPOSE AND OF
10 // MERCHANTABILITY ARE HEREBY DISCLAIMED.
11 //
12 // For complete openNURBS copyright information see <http://www.opennurbs.org>.
13 //
14 ////////////////////////////////////////////////////////////////
15 */
16 
17 #if !defined(OPENNURBS_ERROR_INC_)
18 #define OPENNURBS_ERROR_INC_
19 
20 /*
21 // Macros used to log errors and warnings. The ON_Warning() and ON_Error()
22 // functions are defined in opennurbs_error.cpp.
23 */
24 
25 #if defined(__FUNCTION__)
26 // __FUNCTION__ macro exists
27 #define ON_ERROR(msg) ON_ErrorEx(__FILE__,__LINE__,__FUNCTION__,msg)
28 #define ON_WARNING(msg) ON_WarningEx(__FILE__,__LINE__,__FUNCTION__,msg)
29 #define ON_ASSERT(cond) ON_AssertEx(cond,__FILE__,__LINE__,__FUNCTION__, #cond " is false")
30 #define ON_ASSERT_OR_RETURN(cond,returncode) do{if (!(cond)) {ON_AssertEx(false,__FILE__,__LINE__,__FUNCTION__, #cond " is false");return(returncode);}}while(0)
31 #else
32 // __FUNCTION__ macro does not exist
33 #define ON_ERROR(msg) ON_Error(__FILE__,__LINE__,msg)
34 #define ON_WARNING(msg) ON_Warning(__FILE__,__LINE__,msg)
35 #define ON_ASSERT(cond) ON_Assert(cond,__FILE__,__LINE__, #cond " is false")
36 #define ON_ASSERT_OR_RETURN(cond,returncode) do{if (!(cond)) {ON_Assert(false,__FILE__,__LINE__, #cond " is false");return(returncode);}}while(0)
37 #endif
38 
39 
40 ON_BEGIN_EXTERNC
41 
42 /*
43 // All error/warning messages are sent to ON_ErrorMessage(). Replace the
44 // default handler (defined in opennurbs_error_message.cpp) with something
45 // that is appropriate for debugging your application.
46 */
47 ON_DECL
48 void ON_ErrorMessage(
49  int, /* 0 = warning message, 1 = serious error message, 2 = assert failure */
50  const char*
51  );
52 
53 /*
54 Returns:
55  Number of opennurbs errors since program started.
56 */
57 ON_DECL
58 int ON_GetErrorCount(void);
59 
60 /*
61 Returns:
62  Number of opennurbs warnings since program started.
63 */
64 ON_DECL
65 int ON_GetWarningCount(void);
66 
67 /*
68 Returns:
69  Number of math library or floating point errors that have
70  been handled since program started.
71 */
72 ON_DECL
73 int ON_GetMathErrorCount(void);
74 
75 ON_DECL
76 int ON_GetDebugErrorMessage(void);
77 
78 ON_DECL
79 void ON_EnableDebugErrorMessage( int bEnableDebugErrorMessage );
80 
81 
82 ON_DECL
83 void ON_Error( const char*, /* sFileName: __FILE__ will do fine */
84  int, /* line number: __LINE__ will do fine */
85  const char*, /* printf() style format string */
86  ... /* printf() style ags */
87  );
88 
89 ON_DECL
90 void ON_ErrorEx( const char*, // sFileName: __FILE__ will do fine
91  int, // line number: __LINE__ will do fine
92  const char*, // sFunctionName: __FUNCTION__ will do fine
93  const char*, // printf() style format string
94  ... // printf() style ags
95  );
96 ON_DECL
97 void ON_Warning( const char*, /* sFileName: __FILE__ will do fine */
98  int, /* line number: __LINE__ will do fine */
99  const char*, /* printf() style format string */
100  ... /* printf() style ags */
101  );
102 ON_DECL
103 void ON_WarningEx( const char*, // sFileName: __FILE__ will do fine
104  int, // line number: __LINE__ will do fine
105  const char*, // sFunctionName: __FUNCTION__ will do fine
106  const char*, // printf() style format string
107  ... // printf() style ags
108  );
109 
110 // Ideally - these "assert" functions will be deleted when the SDK can be changed.
111 ON_DECL
112 void ON_Assert( int, /* if false, error is flagged */
113  const char*, /* sFileName: __FILE__ will do fine */
114  int, /* line number: __LINE__ will do fine */
115  const char*, /* printf() style format string */
116  ... /* printf() style ags */
117  );
118 
119 ON_DECL
120 void ON_AssertEx( int, // if false, error is flagged
121  const char*, // sFileName: __FILE__ will do fine
122  int, // line number: __LINE__ will do fine
123  const char*, // sFunctionName: __FUNCTION__ will do fine
124  const char*, // printf() style format string
125  ... // printf() style ags
126  );
127 
128 ON_DECL
129 void ON_MathError(
130  const char*, /* sModuleName */
131  const char*, /* sErrorType */
132  const char* /* sFunctionName */
133  );
134 
135 ON_END_EXTERNC
136 
137 #endif