HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PDG_BatchWorkItem.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_BATCHWORKITEM_H__
10 #define __PDG_BATCHWORKITEM_H__
11 
12 #include "PDG_API.h"
13 
14 #include "PDG_WorkItem.h"
15 #include "PDG_WorkItemTypes.h"
16 
17 #include <UT/UT_StringHolder.h>
18 
20 {
21 public:
23  PDG_GraphContext* context,
24  bool is_static = true,
25  PDG_WorkItemID item_id = theInvalidId,
26  int batch_size = 0);
27 
28  ~PDG_BatchWorkItem() override;
29 
30  /// Returns the memory usage of this batch. Does not count sub items in the
31  /// batch as they're technically owned by the node.
32  void memoryInfo(PDG_MemoryInfo& memory_info,
33  bool inclusive) const override;
34 
35  /// Returns the starting index for the batch, if it supports partial
36  /// cooking.
37  int batchStart() const;
38 
39  /// Returns the size of the batch
40  int batchSize() const;
41 
42  /// Returns the list of sub items in the batch
44  { return myBatchItems; }
45 
46  /// Returns the batch name; the prefix given to all sub items
48  { return name(); }
49 
50  /// Resets the work item's dependency objects
51  void resetOwner() override;
52 
53  /// Returns a sub item for a given index, or nullptr if the index is out
54  /// of the valid range.
55  PDG_WorkItem* subitem(int index) const;
56 
57  /// Inserts a subitem at a specific index. Used for deserialization
58  void insertSubitem(int index, PDG_WorkItem* item);
59 
60  /// Initializes the batch item with a given sub item count and starting
61  /// state
62  void initBatchItems(
63  PDG_WorkItemArray& items,
64  int count);
65 
66  /// Reinitializes the batch item properties from the ones on this work
67  /// item. Assumes the same batch size.
68  void initBatchItems();
69 
70  /// Sets the pending dirty flag on all sub items
71  void setPendingDirty(PendingDirty pending) override;
72 
73  /// Sets the partial batch flag
74  void setIsPartialCook(bool is_partial);
75 
76  /// sets the is dynamic batch flag
77  void setIsDynamicBatch(bool is_dynamic);
78 
79  /// Sets the work item command directly, and updates the cook type of any
80  /// subitems in the batch
81  bool setCommand(
82  const UT_StringHolder& command,
83  bool shell=false) override;
84 
85  /// Sets a per-platform work item command, and updates the cook type of
86  /// any subitems in the batch
88  const UT_StringHolder& linux,
89  const UT_StringHolder& mac,
90  const UT_StringHolder& windows,
91  bool shell=false) override;
92 
93  /// Returns the partial batch flag
94  bool isPartialCook() const
95  { return myIsPartialCook; }
96 
97  /// Returns true if the batch is allowed to dynamically add work items
98  /// while it c ooks
99  bool isDynamicBatch() const
100  { return myIsDynamicBatch; }
101 
102  /// Sets the batch offset
103  void setOffset(int offset);
104 
105  /// Returns the batch offset, e.g. the start of the first item in the real
106  /// index space
107  int offset() const
108  { return myOffset; }
109 
110  /// Sets the activation mode of the batch
111  void setActivationMode(
113 
114  /// Sets the activation count, used when the activation mode is set to
115  /// ActivateFixed.
116  void setActivationCount(
117  int activation_count);
118 
119  /// Gets the activation mode of the batch
120  PDG_BatchActivation activationMode() const;
121 
122  /// Gets the activation count
123  int activationCount() const;
124 
125  /// Sets the start index of the batch
126  void setStartIndex(int index);
127 
128  /// Sets a stat on the batch item, and the subitems if requested
130  bool batched) override;
131 
132  /// Returns the can cook dependency object for this work item
134  { return &myNotCachedDep; }
135 
136  /// Tries marking the not cached dep as resolved
137  void tryNotCached(
138  PDGE_Resolutions& resolutions,
139  PDG_WorkItem* work_item);
140 
141  /// Returns the active batch sub item, if any
142  const PDG_WorkItem* activeBatchItem() const;
143 
144  /// Sets the active batch sub item index, and returns that sub item if
145  /// the index is valid
146  const PDG_WorkItem* setActiveBatchIndex(int index) const;
147 
148  /// Dynamically adds a new work item to the batch
149  PDG_WorkItem* appendSubItem(UT_WorkBuffer& errors);
150 
151  /// Returns the output file cache state of this work item
152  PDG_WorkItemCacheState outputCacheState() const override;
153 
154 protected:
155  /// Returns true if the entire batch is cached, else false
156  PDG_WorkItemState checkCached(bool add_results) override;
157 
158  /// Notifies the batch item than a given subitem index has finished cooking
159  void notifyCook(PDGE_Resolutions& resolutions,
161  int batch_index,
162  fpreal duration,
163  bool notify_all,
164  bool static_cook,
165  bool unresolve) override;
166 
167  /// Syncs the cache for all subitems
168  void syncCacheId() override;
169 
170  /// Sets the frame of the batch item and all sub items, using the step
171  /// size.
172  bool setFrame(fpreal frame,
173  fpreal frame_step,
174  bool check_dirty) override;
175 
176  /// Called when one of the dependencies owned by this work item
177  /// is resolved.
179  PDGE_Resolutions& resolutions,
180  const PDGE_Evaluator& evaluator,
181  PDGE_Dependency* dependency) override;
182 
183 private:
184  PDG_WorkItemArray myBatchItems;
185  PDGE_Dependency myNotCachedDep;
186 
187  int myOffset;
188  int myStartIndex;
189  int myCacheCheck;
190  int myActivationCount;
191  mutable int myActiveBatchIndex;
192 
193  PDG_BatchActivation myActivationMode;
194  bool myIsPartialCook;
195  bool myIsDynamicBatch;
196 };
197 
198 #endif /* __PDG_BATCHWORKITEM_H__ */
exint PDG_WorkItemID
Type defs for unique work item IDs.
virtual PDG_WorkItemState checkCached(bool add_outputs)
PDG_BatchActivation
const PDG_WorkItemArray & batchItems() const
Returns the list of sub items in the batch.
bool isPartialCook() const
Returns the partial batch flag.
void resetOwner() override
Resets the work item's dependency objects.
#define PDG_API
Definition: PDG_API.h:23
**But if you need a result
Definition: thread.h:613
GLintptr offset
Definition: glcorearb.h:665
virtual void syncCacheId()
Syncs a work item's cache with its dependents.
PDG_WorkItemState
Enum of possible work item states.
PDGE_Dependency * notCachedDep()
Returns the can cook dependency object for this work item.
friend class PDG_BatchWorkItem
virtual PDG_WorkItemCacheState outputCacheState() const
Returns the output file cache state of this work item.
PDGE_Dependency::State evalResolve(PDGE_Resolutions &resolutions, const PDGE_Evaluator &evaluator, PDGE_Dependency *dependency) override
virtual bool setPlatformCommands(const UT_StringHolder &linux, const UT_StringHolder &mac, const UT_StringHolder &windows, bool shell=false)
Sets a per-platform work item command.
UT_StringHolder batchName() const
Returns the batch name; the prefix given to all sub items.
GLenum mode
Definition: glcorearb.h:99
PDG_WorkItemCacheState
bool isDynamicBatch() const
bool setFrame(fpreal frame)
virtual void setPendingDirty(PendingDirty pending)
Sets the pending dirty flag on the work item, used for regeneration.
StatType
Enumeration of stats stored in this object.
virtual void memoryInfo(PDG_MemoryInfo &memory_info, bool inclusive) const
Returns a break down of the memory used by the work item.
virtual fpreal setTimeStat(PDG_WorkItemStats::StatType stat, bool batched)
Sets a stat to the current time.
fpreal64 fpreal
Definition: SYS_Types.h:277
GLuint index
Definition: glcorearb.h:786
virtual bool setCommand(const UT_StringHolder &command, bool shell=false)
Sets the work item command directly.
virtual void notifyCook(PDGE_Resolutions &resolutions, PDG_WorkItemState result, int batch_index, fpreal duration, bool notify_all, bool static_cook, bool unresolve)
Notifies this work item that is has cooked.
GLint GLsizei count
Definition: glcorearb.h:405
UT_StringHolder name() const
Returns the name of the work item, guaranteed to be unique.