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 
27 class UT_PerfMonEvent;
30 
32 {
33 public:
35  int id,
36  const UT_StringHolder &name,
37  const UT_StringHolder &object,
38  bool auto_nest_events,
39  UT_PerfMonCategory category,
41  UT_PerfMonObjectType object_type,
44  int frame_num = UT_PERFORMANCE_INVALID_FRAME);
45  virtual ~UT_PerfMonEvent();
46 
47  UT_PerfMonEvent(const UT_PerfMonEvent &) = delete;
48  UT_PerfMonEvent &operator=(const UT_PerfMonEvent &) = delete;
49 
50  /// Return the unique id assigned by the performance monitor.
51  int id() const;
52 
53  /// Return the frame number in which the event occured.
54  int frameNum() const;
55 
56  /// Return the event name.
57  const char *name() const;
58 
59  /// Return the object that the event applies to.
60  const char *object() const;
61 
62  /// Set the object that the event applies to.
63  void setObject(const UT_StringHolder &object);
64 
65  /// Return the icon used for the object.
66  /// Return NULL if the object has no associated icon.
67  const char *objectIcon() const;
68 
69  /// Return extra information about the event.
70  /// Return NULL if there is no extra information.
71  const char *extraInfo() const;
72 
73  /// Set extra information that will be displayed with the event
74  /// in profile statistics and in the event log.
75  void setExtraInfo(
76  const UT_StringHolder &extra_info);
77 
78  /// Return the event type.
79  UT_PerfMonEventType type() const;
80 
81  /// Return the event object type.
82  UT_PerfMonObjectType objectType() const;
83 
84  /// Return true if this event has automatic child event nesting enabled.
85  bool isAutoNestEnabled() const;
86 
87  /// Return the category.
88  UT_PerfMonCategory category() const;
89 
90  /// Return true if the event is a timed event.
91  virtual bool isTimedEvent() const
92  {
93  UT_ASSERT(
94  myType != UT_PERFMON_TIMED_EVENT
95  );
96  return false;
97  }
98 
99  /// Start the event. This puts the event in a running state.
100  /// Real work is performed in subclassStart_().
101  void start();
102 
103  /// Stop the event. This removes the event from a running state.
104  /// Real work is performed in subclassStop_().
105  void stop();
106 
107  /// Return true if the event is in the running state.
108  /// Return false otherwise.
109  bool isRunning() const;
110 
111  /// Return the event value.
112  /// If no value has been set, then return 0.
113  fpreal value() const;
114 
115  /// Return the event value minus the value of any of the descendant events.
116  /// If no self value has been calculated, then return 0.
117  fpreal selfValue() const;
118 
119  /// Set the event value.
120  void setValue(fpreal val);
121 
122  /// Override the event's value.
123  /// Handy when you know the event's value and not its starting
124  /// or stopping values.
125  void overrideValue(fpreal value);
126 
127  /// Calculate the event's self value.
128  /// Do nothing if the event's main value has not been set.
129  /// This can be an expensive call since the values of the event's
130  /// descendants must be examined.
131  void calculateSelfValue();
132 
133  /// Add a child event.
134  void appendChild(UT_PerfMonEvent *event);
135 
136  /// Remove the given child event. Do nothing if the given event
137  /// is not actually a child of this event.
138  void removeChild(UT_PerfMonEvent *event);
139 
140  /// Remove all child events.
141  void removeChildren();
142 
143  /// Return the number of child events.
144  int numChildren() const;
145 
146  /// Return the child at the given index.
147  const UT_PerfMonEvent *getChild(int index) const;
148  UT_PerfMonEvent *getChild(int index);
149 
150  /// Add a parent event.
151  void appendParent(UT_PerfMonEvent *event);
152 
153  /// Remove the given parent event. Do nothing if the given event
154  /// is not actually a parent of this event.
155  void removeParent(UT_PerfMonEvent *event);
156 
157  /// Remove all parent events.
158  void removeParents();
159 
160  /// Return the number of parent events.
161  int numParents() const;
162 
163  /// Return the parent at the given index.
164  const UT_PerfMonEvent *getParent(int index) const;
166 
167  /// Return the task scope that originally started this event.
168  const UT_TaskScope *taskScope() const;
169 
170  /// Record the task scope that originally started this event.
171  void setTaskScope(const UT_TaskScope *task);
172 
173  /// Format the event into a pretty string that can be outputted in a log.
174  virtual void getFormattedString(
175  UT_PerfMonLogTimeFormat time_format,
176  UT_String &str_event) const;
177  /// Format the event for the universal logging system
178  virtual void getUniversalLogEntry(
179  UT_UniversalLogEntry &logentry) const;
180 
181 protected:
182 
183  /// Return true if the value has been overridden.
184  bool isValueOverridden_() const;
185 
186  /// Perform work when the event is started.
187  virtual void subclassStart_();
188 
189  /// Perform work when the event is stopped.
190  virtual void subclassStop_();
191 
192  /// Perform work when the event's value has been overridden.
193  virtual void subclassOverrideValue_();
194 
195  /// Perform work to calculate the event's self value.
196  /// Return the calculated self value.
197  virtual fpreal subclassCalculateSelfValue_();
198 
199  /// Collect the data from the given child event and merge it into this
200  /// event's children data.
201  virtual void subclassCollectDataFromChild_(
202  const UT_PerfMonEvent *child);
203 
204  /// Pass back a formatted string of this event's object path and extra info.
205  void getFormattedObjectPathAndExtraInfo_(
206  bool enclose_obj_path_in_parens,
207  UT_String &object_path,
208  UT_String &extra_info) const;
209 
210 private:
211 
212  /// Collect the data from the given child event and merge it into this
213  /// event's children data.
214  void collectDataFromChild_(
215  const UT_PerfMonEvent *child);
216 
217  int myId;
218  UT_StringHolder myName;
219  UT_StringHolder myObject;
220  UT_StringHolder myObjectIcon;
221  UT_StringHolder myExtraInfo;
222  bool myIsAutoNestEnabled;
223  int myFrameNum;
224  fpreal myValue;
225  fpreal mySelfValue;
226  bool myIsValueSet;
227  bool myIsSelfValueSet;
228  bool myIsValueOverridden;
229  UT_PerfMonCategory myCategory;
230  UT_PerfMonEventList myChildren;
231  UT_PerfMonEventList myParents;
232  const UT_TaskScope *myTaskScope;
233  UT_PerfMonEventType myType;
234  UT_PerfMonObjectType myObjectType;
235 
236  bool myIsRunning;
237 };
238 
239 #endif
type
Definition: core.h:556
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
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
GLint GLint GLsizei GLint GLenum GLenum type
Definition: glcorearb.h:108
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:283
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:165
Simple object to hold the data associated with a single log entry event.