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