HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GR_ErrorManager.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: GR_ErrorManager.h ( GR Library, C++)
7  *
8  * COMMENTS:
9  * Class for managing viewport messages, warnings and errors.
10  */
11 #ifndef GR_ErrorManager_h
12 #define GR_ErrorManager_h
13 
14 #include <UT/UT_Array.h>
15 #include <UT/UT_Lock.h>
16 #include <UT/UT_Pair.h>
17 #include <UT/UT_StringHolder.h>
18 #include <UT/UT_StringMap.h>
19 #include <UI/UI_Value.h>
20 
21 #include "GR_API.h"
22 #include "GR_Error.h"
23 
25 {
26 public:
28 
29  enum Source
30  {
31  GEOMETRY=0,
36 
37  NUM_SOURCES
38  };
39 
40  enum Severity
41  {
42  MESSAGE = 1,
45  FATAL_ERROR
46  };
47 
48  enum Scope
49  {
53  SESSION
54  };
55 
56  int64 logMessage(Source src,
57  UT_StringHolder src_name,
58  Severity sev,
59  Scope scope,
60  GR_ErrorCode gr_code,
62 
63  void clearMessages(Source src,
64  UT_StringHolder src_name,
65  Scope scope);
66 
67  void clearMessages(Source src,
68  UT_StringHolder src_name);
69  void clearMessages(Scope scope);
70  bool clearMessage(int64 tag);
71  void clearAllMessages();
72 
73  UI_Value &getSeverityValue() { return mySeverity; }
74  UI_Value &getChangedValue() { return myChanged; }
75 
76 
77  // return the total number of messages, including suppressions.
78  int getMessages(UT_Array< UT_Pair<UT_StringHolder,Severity> > &msgs,
79  int max_errors = -1);
80 
81 private:
82  UI_Value mySeverity;
83  UI_Value myChanged;
84  UT_Lock myLock;
85  int64 myTagSerial;
86 
87  class gr_Error
88  {
89  public:
90  gr_Error(Source src, Scope sc, Severity sev, GR_ErrorCode c,
92  : source(src), scope(sc), severity(sev), code(c), extra_text(txt),
93  source_name(sname), tag(t)
94  {}
95  gr_Error()
96  : source(GEOMETRY), scope(REDRAW), severity(WARNING),
97  code(GR_NO_MESSAGE)
98  {}
99  Source source;
100  Scope scope;
102  GR_ErrorCode code;
103  UT_StringHolder extra_text;
104  UT_StringHolder source_name;
105  int64 tag;
106  };
107  typedef UT_StringMap< UT_Array<gr_Error> *> gr_ErrorMap;
108 
109  gr_ErrorMap myErrors[NUM_SOURCES];
110 
111 
112  void recomputeSeverity();
113  void processMessages(UT_Array<UT_Pair<UT_StringHolder,Severity> > &msgs,
114  const UT_Array<gr_Error *> &errors,
115  int max_errors);
116 
117 };
118 
119 #endif
UI_Value & getChangedValue()
GR_ErrorCode
Definition: GR_Error.h:16
long long int64
Definition: SYS_Types.h:107
GLsizei GLsizei GLchar * source
Definition: glcorearb.h:802
#define GR_API
Definition: GR_API.h:10
GLenum GLenum severity
Definition: glcorearb.h:2538
UI_Value & getSeverityValue()
GLenum src
Definition: glcorearb.h:1792