HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
UT_PerfMonEvent.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: UT_PerfMonEvent.h (UT Library, C++)
7  *
8  * COMMENTS:
9  *
10  * Performance monitor generic event.
11  */
12 
13 #ifndef __UT_PerfMonEvent__
14 #define __UT_PerfMonEvent__
15 
16 #include "UT_API.h"
17 
18 #include <SYS/SYS_Time.h>
19 #include "UT_Assert.h"
20 #include "UT_PerfMonTypes.h"
21 #include "UT_ValArray.h"
22 #include "UT_String.h"
23 #include "UT_StringHolder.h"
24 #include "UT_PerfMonUtils.h"
25 #include "UT_UniversalLogEntry.h"
26 
29 
31 {
32 public:
34  int id,
35  const UT_StringHolder &name,
36  const UT_StringHolder &object,
37  bool auto_nest_events,
38  UT_PerfMonCategory category,
40  UT_PerfMonObjectType object_type,
43  int frame_num = UT_PERFORMANCE_INVALID_FRAME);
44  virtual ~UT_PerfMonEvent();
45 
46  UT_PerfMonEvent(const UT_PerfMonEvent &) = delete;
47  UT_PerfMonEvent &operator=(const UT_PerfMonEvent &) = delete;
48 
49  /// Return the unique id assigned by the performance monitor.
50  int id() const;
51 
52  /// Return the frame number in which the event occured.
53  int frameNum() const;
54 
55  /// Return the event name.
56  const char *name() const;
57 
58  /// Return the object that the event applies to.
59  const char *object() const;
60 
61  /// Set the object that the event applies to.
62  void setObject(const UT_StringHolder &object);
63 
64  /// Return the icon used for the object.
65  /// Return NULL if the object has no associated icon.
66  const char *objectIcon() const;
67 
68  /// Return extra information about the event.
69  /// Return NULL if there is no extra information.
70  const char *extraInfo() const;
71 
72  /// Set extra information that will be displayed with the event
73  /// in profile statistics and in the event log.
74  void setExtraInfo(
75  const UT_StringHolder &extra_info);
76 
77  /// Return the event type.
78  UT_PerfMonEventType type() const;
79 
80  /// Return the event object type.
81  UT_PerfMonObjectType objectType() const;
82 
83  /// Return true if this event has automatic child event nesting enabled.
84  bool isAutoNestEnabled() const;
85 
86  /// Return the category.
87  UT_PerfMonCategory category() const;
88 
89  /// Return true if the event is a timed event.
90  virtual bool isTimedEvent() const
91  {
92  UT_ASSERT(
93  myType != UT_PERFMON_TIMED_EVENT
94  );
95  return false;
96  }
97 
98  /// Start the event. This puts the event in a running state.
99  /// Real work is performed in subclassStart_().
100  void start();
101 
102  /// Stop the event. This removes the event from a running state.
103  /// Real work is performed in subclassStop_().
104  void stop();
105 
106  /// Return true if the event is in the running state.
107  /// Return false otherwise.
108  bool isRunning() const;
109 
110  /// Return the event value.
111  /// If no value has been set, then return 0.
112  fpreal value() const;
113 
114  /// Return the event value minus the value of any of the descendant events.
115  /// If no self value has been calculated, then return 0.
116  fpreal selfValue() const;
117 
118  /// Set the event value.
119  void setValue(fpreal val);
120 
121  /// Override the event's value.
122  /// Handy when you know the event's value and not its starting
123  /// or stopping values.
124  void overrideValue(fpreal value);
125 
126  /// Calculate the event's self value.
127  /// Do nothing if the event's main value has not been set.
128  /// This can be an expensive call since the values of the event's
129  /// descendants must be examined.
130  void calculateSelfValue();
131 
132  /// Add a child event.
133  void appendChild(UT_PerfMonEvent *event);
134 
135  /// Remove the given child event. Do nothing if the given event
136  /// is not actually a child of this event.
137  void removeChild(UT_PerfMonEvent *event);
138 
139  /// Remove all child events.
140  void removeChildren();
141 
142  /// Return the number of child events.
143  int numChildren() const;
144 
145  /// Return the child at the given index.
146  const UT_PerfMonEvent *getChild(int index) const;
147  UT_PerfMonEvent *getChild(int index);
148 
149  /// Add a parent event.
150  void appendParent(UT_PerfMonEvent *event);
151 
152  /// Remove the given parent event. Do nothing if the given event
153  /// is not actually a parent of this event.
154  void removeParent(UT_PerfMonEvent *event);
155 
156  /// Remove all parent events.
157  void removeParents();
158 
159  /// Return the number of parent events.
160  int numParents() const;
161 
162  /// Return the parent at the given index.
163  const UT_PerfMonEvent *getParent(int index) const;
165 
166  /// Format the event into a pretty string that can be outputted in a log.
167  virtual void getFormattedString(
168  UT_PerfMonLogTimeFormat time_format,
169  UT_String &str_event) const;
170  /// Format the event for the universal logging system
171  virtual void getUniversalLogEntry(
172  UT_UniversalLogEntry &logentry) const;
173 
174 protected:
175 
176  /// Return true if the value has been overridden.
177  bool isValueOverridden_() const;
178 
179  /// Perform work when the event is started.
180  virtual void subclassStart_();
181 
182  /// Perform work when the event is stopped.
183  virtual void subclassStop_();
184 
185  /// Perform work when the event's value has been overridden.
186  virtual void subclassOverrideValue_();
187 
188  /// Perform work to calculate the event's self value.
189  /// Return the calculated self value.
190  virtual fpreal subclassCalculateSelfValue_();
191 
192  /// Collect the data from the given child event and merge it into this
193  /// event's children data.
194  virtual void subclassCollectDataFromChild_(
195  const UT_PerfMonEvent *child);
196 
197  /// Pass back a formatted string of this event's object path and extra info.
198  void getFormattedObjectPathAndExtraInfo_(
199  bool enclose_obj_path_in_parens,
200  UT_String &object_path,
201  UT_String &extra_info) const;
202 
203 private:
204 
205  /// Collect the data from the given child event and merge it into this
206  /// event's children data.
207  void collectDataFromChild_(
208  const UT_PerfMonEvent *child);
209 
210  int myId;
211  UT_StringHolder myName;
212  UT_StringHolder myObject;
213  UT_StringHolder myObjectIcon;
214  UT_StringHolder myExtraInfo;
215  bool myIsAutoNestEnabled;
216  int myFrameNum;
217  fpreal myValue;
218  fpreal mySelfValue;
219  bool myIsValueSet;
220  bool myIsSelfValueSet;
221  bool myIsValueOverridden;
222  UT_PerfMonCategory myCategory;
223  UT_PerfMonEventList myChildren;
224  UT_PerfMonEventList myParents;
225  UT_PerfMonEventType myType;
226  UT_PerfMonObjectType myObjectType;
227 
228  bool myIsRunning;
229 };
230 
231 #endif
232 
UT_PerfMonLogTimeFormat
UT_PerfMonEventType
Event types.
GLuint start
Definition: glcorearb.h:475
GLsizei const GLfloat * value
Definition: glcorearb.h:824
virtual bool isTimedEvent() const
Return true if the event is a timed event.
#define UT_API
Definition: UT_API.h:14
__hostdev__ void setValue(uint32_t offset, bool v)
Definition: NanoVDB.h:5750
UT_ValArray< UT_PerfMonEvent * > UT_PerfMonEventList
GU_API GA_Offset getParent(const GU_Detail *gdp, const GA_Offset &node)
struct _cl_event * event
Definition: glcorearb.h:2961
UT_PerfMonObjectType
Object types.
static const UT_StringHolder theEmptyString
UT_PerfMonCategory
Categories.
GLuint id
Definition: glcorearb.h:655
GLuint const GLchar * name
Definition: glcorearb.h:786
fpreal64 fpreal
Definition: SYS_Types.h:277
LeafData & operator=(const LeafData &)=delete
GLuint index
Definition: glcorearb.h:786
GLuint GLfloat * val
Definition: glcorearb.h:1608
#define UT_ASSERT(ZZ)
Definition: UT_Assert.h:156
Definition: core.h:1131
Simple object to hold the data associated with a single log entry event.
type
Definition: core.h:1059