HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PDG_NodeOptions.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_NODE_OPTIONS_H__
10 #define __PDG_NODE_OPTIONS_H__
11 
12 #include "PDG_API.h"
13 
14 #include "PDG_AttributeInfo.h"
15 #include "PDG_AttributeData.h"
16 #include "PDG_ServiceTypes.h"
17 #include "PDG_WorkItemTypes.h"
18 
19 #include <UT/UT_Array.h>
20 #include <UT/UT_StringHolder.h>
21 
22 class PDG_Node;
23 class PDG_NodeInterface;
24 class PDG_WorkItem;
25 
26 /**
27  * Configuration options for a node instance, based on the current parms of
28  * the node before a cook begins. Filled in by the onConfigureNode callback.
29  */
31 {
32 public:
34 
35 public:
37  : myServiceBlockCookType(
39  , myRequiresGeneratedInputs(false)
40  , myRequiresCookedInputs(false)
41  , myRequiresEndBlock(false)
42  , myRequiresSceneFile(false)
43  , myRequiresInputData(false)
44  , myIsCompressWorkItemData(true)
45  , myIsAlwaysRegenerate(false)
46  , myIsDirtyOnRegenerate(false)
47  , myIsDirtyOnIncomplete(false)
48  , myIsClearFailures(false)
49  , myAllowDuplicateOutputs(false)
50  , myUsesSharedServers(false)
51  , myUsesDynamicBatching(false)
52  , myIsValid(true) {}
53 
54  /// Returns the work item state filter for the node. An empty filter means
55  /// the node will generate from all successful work items, and not generate
56  /// from any failed items.
57  const StateFilter& stateFilter() const
58  { return myStateFilter; }
59 
60  /// Returns true if the node has at least one state in its state filter
61  bool hasStateFilter() const
62  { return (myStateFilter.size() > 0); }
63 
64  /// Returns true if the state filter contains the specified state
65  bool filterState(PDG_WorkItemState state) const
66  { return (myStateFilter.find(state) >= 0); }
67 
68  /// Returns true if the node can generate from the specified work item
69  bool filterState(const PDG_WorkItem* work_item) const;
70 
71  /// Returns the UI description for the node, based on the current parms.
72  /// The string is filled out by the onConfigureNode callback, based on
73  /// the state of the node.
75  { return myDescription; }
76 
77  /// Returns true if a description has been set.
78  bool hasDescription() const
79  { return myDescription.isstring() &&
80  !myDescription.isEmpty(); }
81 
82  /// Returns the service block cook type for this node
84  { return myServiceBlockCookType; }
85 
86  /// Returns true if the node requires all input work items to be
87  /// generated before it can generate.
89  { return myRequiresGeneratedInputs; }
90 
91  /// Returns true if the node requires input work items to be cooked.
92  /// Unliked requiresGeneratedInputs, this does not necessarily mean
93  /// the node waits for ALL inputs -- it just makes it dynamic.
94  bool requiresCookedInputs() const
95  { return myRequiresCookedInputs; }
96 
97  /// Returns true if this node requires an end block to cook correctly
98  bool requiresEndBlock() const
99  { return myRequiresEndBlock; }
100 
101  /// Returns true if this node requires the scene file (e.g. a .hip) to
102  /// cook correctly.
103  bool requiresSceneFile() const
104  { return myRequiresSceneFile; }
105 
106  /// Returns true if the node reads input file data during work item
107  /// generation, instead of just using the file path
108  bool requiresInputData() const
109  { return myRequiresInputData; }
110 
111  /// Returns true if this node supports compression of work item .json
112  /// data for out of process tasks.
114  { return myIsCompressWorkItemData; }
115 
116  /// Returns true if the node should always regenerate work items each
117  /// cook
118  bool isAlwaysRegenerate() const
119  { return myIsAlwaysRegenerate; }
120 
121  /// Returns true if the node should always dirty itself when regenerating
122  /// work items.
123  bool isDirtyOnRegenerate() const
124  { return myIsDirtyOnRegenerate; }
125 
126  /// Returns true if the node should dirty itself on the next cook, if it
127  /// has any uncooked work items
128  bool isDirtyOnIncomplete() const
129  { return myIsDirtyOnIncomplete; }
130 
131  /// Returns true iof the node should reset failure states back to success,
132  /// when generating from failed nputs.
133  bool isClearFailures() const
134  { return myIsClearFailures; }
135 
136  /// Returns true if the the node should allow multiple work items to have
137  /// the same output file
139  { return myAllowDuplicateOutputs; }
140 
141  /// Returns true if this node creates work items that use shared servers
142  bool usesSharedServers() const
143  { return myUsesSharedServers; }
144 
145  /// Returns true if thise node creates work items that use dynamic batching
146  bool usesDynamicBatching() const
147  { return myUsesDynamicBatching; }
148 
149  /// Returns true if the node options are valid
150  bool isValid() const
151  { return myIsValid; }
152 
153  /// Sets the state filter
155  { myStateFilter = filter; }
156 
157  /// Sets the UI description for the node.
158  void setDescription(const UT_StringHolder& desc)
159  { myDescription = desc; }
160 
161  /// Sets the service block cook type for this node
163  PDG_ServiceBlockCookType cook_type)
164  { myServiceBlockCookType = cook_type; }
165 
166  /// Indicates whether or not the node requires all inputs to be generated
167  /// before it can generate.
168  void setRequiresGeneratedInputs(bool requires_all)
169  { myRequiresGeneratedInputs = requires_all; }
170 
171  /// Indicates whether or not the node requires inputs to be cooked before
172  /// it can generate.
173  void setRequiresCookedInputs(bool requires_cooked)
174  { myRequiresCookedInputs = requires_cooked; }
175 
176  /// Indicates whether or not this node requires an end block in order to
177  /// cook properly. This only applies to feedback begin nodes.
178  void setRequiresEndBlock(bool requires_block)
179  { myRequiresEndBlock = requires_block; }
180 
181  /// Indicates whether or not this node requires the current scene file
182  void setRequiresSceneFile(bool requires_scene)
183  { myRequiresSceneFile = requires_scene; }
184 
185 
186  /// Indicates whether or not this node needs to read input file data
187  /// when generating work items
188  void setRequiresInputData(bool requires_data)
189  { myRequiresInputData = requires_data; }
190 
191  /// Indicates whether or not work items created by this node should
192  /// store compressed .json data when running out of process.
193  void setIsCompressWorkItemData(bool compress)
194  { myIsCompressWorkItemData = compress; }
195 
196  /// Indicates whether or not the node should regenerate work items
197  /// every cook. If the node has a custom onRegenerate implementation
198  /// it will always be called -- this option is only for nodes that don't
199  /// define their own implementation.
200  void setIsAlwaysRegenerate(bool always_regenerate)
201  { myIsAlwaysRegenerate = always_regenerate; }
202 
203  /// Indicates whether or not the node should always dirty if it requires
204  /// regeneration.
205  void setDirtyOnRegenerate(bool dirty_node)
206  { myIsDirtyOnRegenerate = dirty_node; }
207 
208  /// Indicates whether or not the node should always dirty itself if it
209  /// has incomplete work items
210  void setDirtyOnIncomplete(bool dirty_node)
211  { myIsDirtyOnIncomplete = dirty_node; }
212 
213  /// Indicates whether or not the node should clear failure states when
214  /// the state filter is configured to include failed work items
215  void setClearFailures(bool clear_failures)
216  { myIsClearFailures = clear_failures; }
217 
218  /// Indicates whether or not the work items in the node should be
219  /// allowed to have duplicate output files
220  void setAllowDuplicateOutputs(bool allow_dupes)
221  { myAllowDuplicateOutputs = allow_dupes; }
222 
223  /// Indicates whether or not this node creates work items that use
224  /// shared servers
225  void setUsesSharedServers(bool uses_servers)
226  { myUsesSharedServers = uses_servers; }
227 
228  /// Indicates whether or not this node creates work items that use
229  /// dynamic batching
230  void setUsesDynamicBatching(bool uses_batching)
231  { myUsesDynamicBatching = uses_batching; }
232 
233  /// Sets the valid flag
234  void setIsValid(bool is_valid)
235  { myIsValid = is_valid; }
236 
237  /// Returns the service name for the node
238  /// The string is filled out by the onConfigureNode callback
240  { return myServiceName; }
241 
242  /// Returns true if a service name has been set
243  bool hasServiceName() const
244  { return myServiceName.isstring() &&
245  !myServiceName.isEmpty(); }
246 
247  /// Sets the service name
249  { myServiceName = name; }
250 
251  /// Adds an attribute name and origin type to the attribute origin map.
252  /// This should be used for instant-specific attributes, which differ
253  /// from the ones in the node template. The origin can be the ORed value
254  /// of an of the enum entries in PDG_AttributeInfo::AttribOrigin.
256  int origin)
257  {
258  if (!name.isstring() || name.isEmpty())
259  return;
260  if (!PDG_AttributeData::validName(name, true))
261  return;
262  myOutputAttribs.myOrigins[name] = origin;
263  }
265  int origin)
266  {
267  if (!name.isstring() || name.isEmpty())
268  return;
269  if (!PDG_AttributeData::validName(name, true))
270  return;
271  myInputAttribs.myOrigins[name] = origin;
272  }
273 
274  /// Updates the evaluation origin for a port on this specific node
275  /// instance
277  int origin)
278  {
279  if (!name.isstring() || name.isEmpty())
280  return;
281  myPortOrigins[name] = origin;
282  }
283 
284  /// Sets the default origin for the attribute type
285  void setOutputAttribDefault(int origin)
286  { myOutputAttribs.myDefaultOrigin = origin; }
287  void setInputAttribDefault(int origin)
288  { myInputAttribs.myDefaultOrigin = origin; }
289 
290  /// Returns the current output attribute origin map
293  { return myOutputAttribs; }
294 
296  inputAttribs() const
297  { return myInputAttribs; }
298 
299  /// Returns the evaluation origin overrides for ports on this instance
301  portOrigins() const
302  { return myPortOrigins; }
303 
304  /// Resets the node options back to their default values
305  void reset(const PDG_NodeInterface* node_template,
306  const PDG_Node* node_instance);
307 
308 private:
309  PDG_AttributeInfo::Config myOutputAttribs;
310  PDG_AttributeInfo::Config myInputAttribs;
311  UT_ArrayStringMap<int> myPortOrigins;
312 
313  StateFilter myStateFilter;
314  UT_StringHolder myDescription;
315  UT_StringHolder myServiceName;
316 
317  PDG_ServiceBlockCookType myServiceBlockCookType;
318 
319  bool myRequiresGeneratedInputs;
320  bool myRequiresCookedInputs;
321  bool myRequiresEndBlock;
322  bool myRequiresSceneFile;
323  bool myRequiresInputData;
324 
325  bool myIsCompressWorkItemData;
326 
327  bool myIsAlwaysRegenerate;
328  bool myIsDirtyOnRegenerate;
329  bool myIsDirtyOnIncomplete;
330  bool myIsClearFailures;
331 
332  bool myAllowDuplicateOutputs;
333 
334  bool myUsesSharedServers;
335  bool myUsesDynamicBatching;
336 
337  bool myIsValid;
338 };
339 
340 #endif
Only overwrite the attribute if the type matches.
bool usesSharedServers() const
Returns true if this node creates work items that use shared servers.
bool hasServiceName() const
Returns true if a service name has been set.
const PDG_AttributeInfo::Config & inputAttribs() const
void setOutputAttrib(const UT_StringHolder &name, int origin)
const UT_StringHolder & description() const
void setServiceBlockCookType(PDG_ServiceBlockCookType cook_type)
Sets the service block cook type for this node.
bool isCompressWorkItemData() const
bool requiresGeneratedInputs() const
const UT_ArrayStringMap< int > & portOrigins() const
Returns the evaluation origin overrides for ports on this instance.
#define PDG_API
Definition: PDG_API.h:23
void setRequiresCookedInputs(bool requires_cooked)
void setInputAttrib(const UT_StringHolder &name, int origin)
bool isEmpty() const
Same as !isstring()
static bool validName(const UT_StringHolder &str, bool allow_internal=false)
bool isDirtyOnIncomplete() const
void setInputAttribDefault(int origin)
bool requiresInputData() const
bool hasDescription() const
Returns true if a description has been set.
void setAllowDuplicateOutputs(bool allow_dupes)
bool isClearFailures() const
bool isAlwaysRegenerate() const
GLboolean reset
Definition: glad.h:5138
PDG_WorkItemState
Enum of possible work item states.
bool allowDuplicateOutputs() const
void setDirtyOnRegenerate(bool dirty_node)
bool isValid() const
Returns true if the node options are valid.
void setRequiresInputData(bool requires_data)
bool filterState(PDG_WorkItemState state) const
Returns true if the state filter contains the specified state.
void setOutputAttribDefault(int origin)
Sets the default origin for the attribute type.
bool requiresSceneFile() const
void setIsValid(bool is_valid)
Sets the valid flag.
const StateFilter & stateFilter() const
bool usesDynamicBatching() const
Returns true if thise node creates work items that use dynamic batching.
GLuint const GLchar * name
Definition: glcorearb.h:786
void setDirtyOnIncomplete(bool dirty_node)
PDG_ServiceBlockCookType serviceBlockCookType() const
Returns the service block cook type for this node.
void setDescription(const UT_StringHolder &desc)
Sets the UI description for the node.
bool requiresEndBlock() const
Returns true if this node requires an end block to cook correctly.
void setClearFailures(bool clear_failures)
void setRequiresEndBlock(bool requires_block)
void setIsCompressWorkItemData(bool compress)
const PDG_AttributeInfo::Config & outputAttribs() const
Returns the current output attribute origin map.
void setRequiresSceneFile(bool requires_scene)
Indicates whether or not this node requires the current scene file.
void setRequiresGeneratedInputs(bool requires_all)
void setPortOrigin(const UT_StringHolder &name, int origin)
bool hasStateFilter() const
Returns true if the node has at least one state in its state filter.
void setServiceName(const UT_StringHolder &name)
Sets the service name.
void setUsesDynamicBatching(bool uses_batching)
void setUsesSharedServers(bool uses_servers)
void setIsAlwaysRegenerate(bool always_regenerate)
bool isDirtyOnRegenerate() const
SYS_FORCE_INLINE bool isstring() const
bool requiresCookedInputs() const
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
Definition: glcorearb.h:1297
void setStateFilter(const StateFilter &filter)
Sets the state filter.
const UT_StringHolder & serviceName() const
PDG_ServiceBlockCookType
Enumeration of service block cook modes.