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 "GR_API.h"
15 #include "GR_Error.h"
16 
17 #include <UI/UI_Value.h>
18 
19 #include <UT/UT_Array.h>
20 #include <UT/UT_Lock.h>
21 #include <UT/UT_StringHolder.h>
22 #include <UT/UT_StringMap.h>
23 
24 #include <utility>
25 
27 {
28 public:
30 
31  enum Source
32  {
33  GEOMETRY=0,
38 
39  NUM_SOURCES
40  };
41 
42  enum Severity
43  {
44  MESSAGE = 1,
47  FATAL_ERROR
48  };
49 
50  enum Scope
51  {
55  SESSION
56  };
57 
58  int64 logMessage(Source src,
59  UT_StringHolder src_name,
60  Severity sev,
61  Scope scope,
62  GR_ErrorCode gr_code,
64 
65  void clearMessages(Source src,
66  UT_StringHolder src_name,
67  Scope scope);
68 
69  void clearMessages(Source src,
70  UT_StringHolder src_name);
71  void clearMessages(Scope scope);
72  bool clearMessage(int64 tag);
73  void clearAllMessages();
74 
75  UI_Value &getSeverityValue() { return mySeverity; }
76  UI_Value &getChangedValue() { return myChanged; }
77 
78 
79  // return the total number of messages, including suppressions.
80  int getMessages(UT_Array<std::pair<UT_StringHolder,Severity>> &msgs,
81  int max_errors = -1);
82 
83 private:
84  UI_Value mySeverity;
85  UI_Value myChanged;
86  UT_Lock myLock;
87  int64 myTagSerial;
88 
89  class gr_Error
90  {
91  public:
92  gr_Error(Source src, Scope sc, Severity sev, GR_ErrorCode c,
94  : source(src), scope(sc), severity(sev), code(c), extra_text(txt),
95  source_name(sname), tag(t)
96  {}
97  gr_Error()
98  : source(GEOMETRY), scope(REDRAW), severity(WARNING),
99  code(GR_NO_MESSAGE)
100  {}
101  Source source;
102  Scope scope;
104  GR_ErrorCode code;
105  UT_StringHolder extra_text;
106  UT_StringHolder source_name;
107  int64 tag;
108  };
109  typedef UT_StringMap< UT_Array<gr_Error> *> gr_ErrorMap;
110 
111  gr_ErrorMap myErrors[NUM_SOURCES];
112 
113 
114  void recomputeSeverity();
115  void processMessages(UT_Array<std::pair<UT_StringHolder,Severity>> &msgs,
116  const UT_Array<gr_Error *> &errors,
117  int max_errors);
118 
119 };
120 
121 #endif
UI_Value & getChangedValue()
GR_ErrorCode
Definition: GR_Error.h:16
GLsizei GLsizei GLchar * source
Definition: glcorearb.h:803
#define GR_API
Definition: GR_API.h:10
long long int64
Definition: SYS_Types.h:116
GLenum GLenum severity
Definition: glcorearb.h:2539
GLdouble t
Definition: glad.h:2397
UI_Value & getSeverityValue()
GLenum src
Definition: glcorearb.h:1793