HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PDG_Event.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  * COMMENTS:
7  */
8 
9 #ifndef __PDG_EVENT_H__
10 #define __PDG_EVENT_H__
11 
12 #include "PDG_API.h"
13 
14 #include "PDG_AttributeTypes.h"
15 #include "PDG_NodeTypes.h"
16 #include "PDG_WorkItem.h"
17 #include "PDG_WorkItemTypes.h"
18 
19 #include <UT/UT_StringHolder.h>
20 #include <SYS/SYS_Hash.h>
21 
22 class PDG_GraphContext;
23 class PDG_Node;
24 class PDG_Scheduler;
25 
26 /*
27  * Generic event that contains all of the fields needed for all PDG events
28  * types. To keep the event object small, string fields are stored in one
29  * of two string variables, which are reused depending on the event type.
30  */
32 {
33 public:
34  /// Empty, null-initialized event that can be used when clear constructing
35  /// event data structures, or passing a default value to an event reference
36  /// parameter
38 
39 public:
40  /// Constructs an event for node creation [node]
41  static PDG_Event NodeCreate(
42  PDG_GraphContext* context,
43  const PDG_Node* node);
44  /// Constructs an event for node deletion [node]
45  static PDG_Event NodeRemove(
46  PDG_GraphContext* context,
47  const PDG_Node* node);
48  /// Constructs an event that indicates that a node was renamed
49  /// [node, oldname, newname]
50  static PDG_Event NodeRename(
51  PDG_GraphContext * context,
52  const PDG_Node* node,
53  const UT_StringHolder& old_name,
54  const UT_StringHolder& new_name);
55  /// Constructs an event for two node being connected [node1, node2]
56  static PDG_Event NodeConnect(
57  PDG_GraphContext* context,
58  const PDG_Node* input,
59  const PDG_Node* output);
60  /// Constructs an event for two node being disconnected [node1, node2]
61  static PDG_Event NodeDisconnect(
62  PDG_GraphContext* context,
63  const PDG_Node* input,
64  const PDG_Node* output);
65  /// Constructs an event that indicates a node cooked for the first
66  /// time [node]
67  static PDG_Event NodeFirstCook(
68  PDG_GraphContext* context,
69  const PDG_Node* node);
70  /// Constructs an event that indicates a node finished generating work
71  /// items [node]
72  static PDG_Event NodeGenerated(
73  PDG_GraphContext* context,
74  const PDG_Node* node);
75  /// Constructs an event that indicates a node finished cooking work
76  /// items [node]
77  static PDG_Event NodeCooked(
78  PDG_GraphContext* context,
79  const PDG_Node* node);
80  /// Constructs an event that indicates a node has all of its work
81  /// items dirtied [node]
82  static PDG_Event NodeClear(
83  PDG_GraphContext* context,
84  const PDG_Node* node);
85  /// Constructs an event that indicates a node generated new work items,
86  /// but may still have more to generate in the future [node]
87  static PDG_Event NodeProgressUpdate(
88  PDG_GraphContext* context,
89  const PDG_Node* node);
90 
91 
92  /// Constructs an event that indicates a node began dirtying work
93  /// items [node]
94  static PDG_Event DirtyStart(
95  PDG_GraphContext* context,
96  const PDG_Node* node);
97  /// Constructs an event that indicates a node finished dirtying work
98  /// items [node]
99  static PDG_Event DirtyStop(
100  PDG_GraphContext* context,
101  const PDG_Node* node);
102  /// Constructs an event that indicates that all work items in the graph
103  /// are being dirtied []
104  static PDG_Event DirtyAll(PDG_GraphContext* context);
105 
106 
107  /// Constructs an event that indicates an error occured in a node while
108  /// cooking [node, message]
109  static PDG_Event CookError(
110  PDG_GraphContext *context,
111  const PDG_Node *node,
112  const UT_StringHolder &message);
113  /// Constructs an event that indicates an error occured in a scheduler
114  /// while cooking [node, message]
115  static PDG_Event CookError(
116  PDG_GraphContext *context,
117  const PDG_Scheduler *scheduler,
118  const UT_StringHolder &message);
119  /// Constructs an event that indicates a warning occured in a node while
120  /// cooking [node, message]
121  static PDG_Event CookWarning(
122  PDG_GraphContext *context,
123  const PDG_Node *node,
124  const UT_StringHolder &message);
125  /// Constructs an event that indicates a warningoccured in a scheduler
126  /// while cooking [node, message]
127  static PDG_Event CookWarning(
128  PDG_GraphContext *context,
129  const PDG_Scheduler *scheduler,
130  const UT_StringHolder &message);
131  /// Creates an event that indicates that cooking has started [?node]
132  static PDG_Event CookStart(
133  PDG_GraphContext *context,
134  const PDG_Node *node=nullptr);
135  /// Creates an event that indicates that cooking has finished [?node]
136  static PDG_Event CookComplete(
137  PDG_GraphContext *context,
138  const PDG_Node *node=nullptr);
139 
140 
141  /// Creates an event that indicates that a dependency was added between
142  /// two work items [workitem, dependency]
143  static PDG_Event WorkItemAddDep(
144  PDG_GraphContext *context,
145  const PDG_Node *node,
146  PDG_WorkItemID work_item,
147  PDG_WorkItemID dependency);
148  /// Creates an event that indicates that a dependency was removed between
149  /// two work items [workitem, dependency]
150  static PDG_Event WorkItemRemoveDep(
151  PDG_GraphContext *context,
152  const PDG_Node *node,
153  PDG_WorkItemID work_item,
154  PDG_WorkItemID depdendency);
155  /// Creates an event that indicates a work item's cook progress was
156  /// updated [node, workitem]
157  static PDG_Event WorkItemCookPercentUpdate(
158  PDG_GraphContext *context,
159  const PDG_Node *node,
160  PDG_WorkItemID work_item);
161  /// Creates an event that indicates that a work item changed states
162  /// [node, oldstate, newstate]
163  static PDG_Event WorkItemStateChange(
164  PDG_GraphContext *context,
165  const PDG_Node *node,
166  PDG_WorkItemID work_item,
167  PDG_WorkItemState old_state,
168  PDG_WorkItemState new_state);
169  /// Creates an event that indicates that a work item was added to a
170  /// node [node, workitem]
171  static PDG_Event WorkItemAdd(
172  PDG_GraphContext *context,
173  const PDG_Node *node,
174  PDG_WorkItemID work_item);
175  /// Creates an event that indicates that a list of work items was added to
176  /// a node [node, workitemArray]
177  static PDG_Event WorkItemAddList(
178  PDG_GraphContext *context,
179  const PDG_Node *node,
180  const PDG_WorkItemIDArray& work_items);
181  /// Constructs an event that indicates a work item was removed from a
182  /// node [node, workitem, state]
183  static PDG_Event WorkItemRemove(
184  PDG_GraphContext *context,
185  const PDG_Node *node,
186  PDG_WorkItemID work_item,
187  PDG_WorkItemState state);
188  /// Constructs an event that indicates a list of work item was removed
189  /// from a node [node, workitemArray]
190  static PDG_Event WorkItemRemoveList(
191  PDG_GraphContext *context,
192  const PDG_Node *node,
193  const PDG_WorkItemIDArray& work_items);
194  /// Constructs an event that indicates a work item was selected in the
195  /// UI [node, workitem]
196  static PDG_Event WorkItemSelect(
197  PDG_GraphContext *context,
198  const PDG_Node *node,
199  PDG_WorkItemID work_item);
200  /// Constructs an event that indicates a work item's attribute data was
201  /// updated [node, workitem]
202  static PDG_Event WorkItemMergeData(
203  PDG_GraphContext *context,
204  const PDG_Node *node,
205  PDG_WorkItemID work_item);
206  /// Constructs an event that indicates a work item's output files were
207  /// updated [node, workitem]
208  static PDG_Event WorkItemOutputFiles(
209  PDG_GraphContext *context,
210  const PDG_Node *node,
211  PDG_WorkItemID work_item);
212  /// Constructs an event that indicates an attribute was changed
213  /// on a work item [node, workitem, attribname]
214  static PDG_Event WorkItemSetAttrib(
215  PDG_GraphContext *context,
216  const PDG_Node *node,
217  PDG_WorkItemID work_item,
218  PDG_AttributeType attr_type,
219  const UT_StringHolder &attr_name);
220  /// Constructs an event that indicates an integer attribute was changed
221  /// on a work item [node, workitem, attribname]
222  static PDG_Event WorkItemSetIntAttrib(
223  PDG_GraphContext *context,
224  const PDG_Node *node,
225  PDG_WorkItemID work_item,
226  const UT_StringHolder &attr_name);
227  /// Constructs an event that indicates a float attribute was changed
228  /// on a work item [node, workitem, attribname]
229  static PDG_Event WorkItemSetFloatAttrib(
230  PDG_GraphContext *context,
231  const PDG_Node *node,
232  PDG_WorkItemID work_item,
233  const UT_StringHolder &attr_name);
234  /// Constructs an event that indicates a string attribute was changed
235  /// on a work item [node, workitem, attribname]
236  static PDG_Event WorkItemSetStringAttrib(
237  PDG_GraphContext *context,
238  const PDG_Node *node,
239  PDG_WorkItemID work_item,
240  const UT_StringHolder &attr_name);
241  /// Constructs an event that indicates a work item's priority changed
242  /// [node, workitem]
243  static PDG_Event WorkItemPriority(
244  PDG_GraphContext *context,
245  const PDG_Node *node,
246  PDG_WorkItemID work_item);
247  /// Constructs an event that indicates that a batch work item was
248  /// initialized [node, workitems]
249  static PDG_Event WorkItemBatchInitialized(
250  PDG_GraphContext *context,
251  const PDG_Node* node,
252  PDG_WorkItemID work_item,
253  const PDG_WorkItemIDArray& work_items);
254 
255 
256  /// Constructs an event for scheduler creation [scheduler]
257  static PDG_Event SchedulerAdded(
258  PDG_GraphContext *context,
259  const PDG_Scheduler *scheduler);
260  /// Constructs an event for scheduler removal [scheduler]
261  static PDG_Event SchedulerRemoved(
262  PDG_GraphContext *context,
263  const PDG_Scheduler *scheduler);
264  /// Constructs an event for a scheduler being assigned to a node
265  /// [node, scheduler]
266  static PDG_Event SetScheduler(
267  PDG_GraphContext *context,
268  const PDG_Node *node,
269  const PDG_Scheduler *scheduler);
270 
271 
272  /// Constructs an event that indicates services have been modified[]
273  static PDG_Event ServiceManagerAll();
274  /// Constructs an event that indicates that a specific service has
275  /// started [service]
276  static PDG_Event ServiceStartBegin(
277  const UT_StringHolder& service_name);
278  /// Constructs an event that indicates that a specific service has
279  /// stopped [service]
280  static PDG_Event ServiceStartEnd(
281  const UT_StringHolder& service_name);
282  /// Constructs an event that indicates that a service client has
283  /// stopped [service, client]
284  static PDG_Event ServiceClientStarted(
285  const UT_StringHolder& service_name,
286  const UT_StringHolder& client_name);
287  /// Constructs an event that indicates that a service client has
288  /// been modified [service, client]
289  static PDG_Event ServiceClientChanged(
290  const UT_StringHolder& service_name,
291  const UT_StringHolder& client_name);
292 
293  /// Returns the string name of an event
294  static const char* eventName(PDG_EventType type);
295 
296 public:
297  /// Constructs a default initialized null event
298  PDG_Event();
299 
300  /// Constructs an event for use with services, without a graph context as
301  /// services are global to the session
302  PDG_Event(
304  bool can_consolidate,
305  const UT_StringHolder& service_name =
307  const UT_StringHolder& service_client_name =
309 
310  /// Constructs an event for a specific graph context
311  PDG_Event(
313  bool can_consolidate,
314  PDG_GraphContext* context,
315  const PDG_Node* node = nullptr,
316  const PDG_Node* node2 = nullptr,
317  PDG_WorkItemID work_item =
319  PDG_WorkItemID dependency =
321  PDG_WorkItemState current_state =
323  PDG_WorkItemState last_state =
325 
327  { return myEventType; }
328  bool canConsolidate() const
329  { return myCanConsolidate; }
330 
332  { return myContext; }
333 
334  PDG_Node* node() const;
335  PDG_Node* node2() const;
336  PDG_Scheduler* scheduler() const;
337 
339  { return myWorkItemId; }
341  { return myDependencyId; }
342 
344  { return myCurrentState; }
346  { return myLastState; }
347  const UT_StringHolder& message() const
348  { return myStringData[theMessage]; }
349 
350  const UT_StringHolder& attrName() const
351  { return myStringData[theAttributeName]; }
352 
353  const UT_StringHolder& oldName() const
354  { return myStringData[theNodeOldName]; }
355  const UT_StringHolder& newName() const
356  { return myStringData[theNodeNewName]; }
357 
359  { return myStringData[theServiceName]; }
361  { return myStringData[theServiceClientName]; }
362 
364  { return myWorkItemArray; }
365 
367  { return myNodeId; }
369  { return myNode2Id; }
371  { return myStringData[theSchedulerName]; }
372 
373  SYS_HashType hash() const;
374  bool operator==(const PDG_Event& other) const;
375 
376  UT_StringHolder toString() const;
377  void consolidate(const PDG_Event& other);
378 
379 private:
380  static int theNodeOldName;
381  static int theNodeNewName;
382  static int theAttributeName;
383  static int theMessage;
384  static int theServiceName;
385  static int theServiceClientName;
386  static int theSchedulerName;
387 
388 private:
389  UT_StringHolder myStringData[2];
390  PDG_WorkItemIDArray myWorkItemArray;
391 
392  PDG_GraphContext* myContext;
393 
394  PDG_WorkItemID myWorkItemId;
395  PDG_WorkItemID myDependencyId;
396 
397  PDG_NodeID myNodeId;
398  PDG_NodeID myNode2Id;
399 
400  PDG_EventType myEventType;
401  PDG_WorkItemState myCurrentState;
402  PDG_WorkItemState myLastState;
403 
404  bool myCanConsolidate;
405 };
406 
408 {
409  return event.hash();
410 }
411 
412 namespace UT
413 {
414  template <typename T>
415  struct DefaultClearer;
416 
417  template <>
419  {
420  static void clear(PDG_Event& event)
421  { event = PDG_Event::theEmptyEvent; }
422  static bool isClear(const PDG_Event& event)
423  { return (event == PDG_Event::theEmptyEvent); }
424  static void clearConstruct(PDG_Event *p)
425  { new ((void *)p) PDG_Event(); }
426  static const bool clearNeedsDestruction = false;
427  };
428 }
429 
430 #endif
exint PDG_WorkItemID
Type defs for unique work item IDs.
GLuint GLsizei const GLchar * message
Definition: glcorearb.h:2543
PDG_NodeID node2Id() const
Definition: PDG_Event.h:368
PDG_WorkItemID workItemId() const
Definition: PDG_Event.h:338
#define PDG_API
Definition: PDG_API.h:23
std::size_t SYS_HashType
Define the type for hash values.
Definition: SYS_Hash.h:19
const UT_StringHolder & serviceClientName() const
Definition: PDG_Event.h:360
static void clearConstruct(PDG_Event *p)
Definition: PDG_Event.h:424
const UT_StringHolder & message() const
Definition: PDG_Event.h:347
struct _cl_event * event
Definition: glcorearb.h:2961
const UT_StringHolder & attrName() const
Definition: PDG_Event.h:350
PDG_WorkItemID dependencyId() const
Definition: PDG_Event.h:340
bool operator==(const BaseDimensions< T > &a, const BaseDimensions< Y > &b)
Definition: Dimensions.h:137
PDG_NodeID nodeId() const
Definition: PDG_Event.h:366
PDG_EventType type() const
Definition: PDG_Event.h:326
SYS_FORCE_INLINE size_t hash_value(const PDG_Event &event)
Definition: PDG_Event.h:407
const UT_StringHolder & newName() const
Definition: PDG_Event.h:355
PDG_WorkItemState
Enum of possible work item states.
static void clear(PDG_Event &event)
Definition: PDG_Event.h:420
static const UT_StringHolder theEmptyString
#define SYS_FORCE_INLINE
Definition: SYS_Inline.h:45
PDG_AttributeType
Enumeration of possible attribute types.
PDG_WorkItemState currentState() const
Definition: PDG_Event.h:343
const UT_StringHolder & serviceName() const
Definition: PDG_Event.h:358
PDG_WorkItemState lastState() const
Definition: PDG_Event.h:345
bool canConsolidate() const
Definition: PDG_Event.h:328
const PDG_WorkItemIDArray & workItemArray() const
Definition: PDG_Event.h:363
static PDG_Event theEmptyEvent
Definition: PDG_Event.h:37
int PDG_NodeID
Node ID type.
Definition: PDG_NodeTypes.h:29
static constexpr PDG_WorkItemID theInvalidId
Default, invalid work item ID value.
Definition: PDG_WorkItem.h:52
PDG_EventType
type
Definition: core.h:1059
PDG_GraphContext * context() const
Definition: PDG_Event.h:331
const UT_StringHolder & oldName() const
Definition: PDG_Event.h:353
static bool isClear(const PDG_Event &event)
Definition: PDG_Event.h:422
const UT_StringHolder & schedulerName() const
Definition: PDG_Event.h:370