HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PDG_AttributeInfo.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_ATTRIBUTE_INFO_H__
10 #define __PDG_ATTRIBUTE_INFO_H__
11 
12 #include "PDG_API.h"
13 
14 #include <UT/UT_ArrayStringMap.h>
15 #include <UT/UT_StringMap.h>
16 #include <UT/UT_StringSet.h>
17 
18 class PDG_NodeInterface;
19 
20 class UT_JSONValueArray;
21 class UT_WorkBuffer;
22 
23 /**
24  * Stores information about the attributes needed and created by a node
25  */
27 {
28 public:
29  /// Whether the attributes is create/used in the generate/cook stage
31  {
32  eOriginNone = 0x0,
33  eOriginGenerate = 0x1,
34  eOriginCook = 0x2,
35  eOriginExpected = 0x4,
36 
37  eOriginGenerateExpected = eOriginGenerate | eOriginExpected,
38  };
39 
40  /// Configuration struct which can be used at either the node template or
41  /// node instance level.
42  struct PDG_API Config
43  {
44  Config() : myDefaultOrigin(eOriginNone) {}
45 
46  bool contains(const UT_StringHolder& name) const
47  { return myOrigins.contains(name); }
48 
51  };
52 
53  /// Utility struct for information record about attributes used in
54  /// expressions
56  {
59  };
60 
61 public:
62 
63  /// Default attribute origins are initialized to static
65 
66  /// Resets the internal structures of this object. Called during a cook,
67  /// so the info can be re-filled from the inputs, node options and parms
68  void reset();
69 
70 
71  /// Adds the attributes from the maap to the output map of this object
72  void addOutputAttribs(const Config& attrib_config);
73 
74  /// Adds attributes that are consumed by this object
75  void addInputAttribs(const Config& attrib_config);
76 
77  /// Adds the input attributes from the attribute info to the input map of
78  /// this object
79  void addUpstreamAttribs(const PDG_AttributeInfo& info,
80  bool dynamic_generator);
81 
82  /// Copies expression attributes to inputs based on the port map
83  void processExpressionAttribs(
84  const PDG_NodeInterface* node_interface,
85  const UT_ArrayStringMap<int>& ports);
86 
87  /// Returns true if the node needs to be dynamic in order to access the
88  /// attributes it needs to generate.
89  bool checkNeedsDynamic(
90  bool require_inputs) const;
91 
92  /// Returns the output attribute map, i.e. attributes produced by the node
93  /// that owns this object
94  const Config& outputAttributes() const
95  { return myOutputAttributes; }
96 
97  /// Utility that returns true if the specified output attribute exists
99  const UT_StringHolder& name) const
100  {
101  return myOutputAttributes.contains(name);
102  }
103 
104  /// Returns the attributes referenced or use during the current cook
105  const Config& inputAttributes() const
106  { return myInputAttributes; }
107 
108  /// Utility that returns true if the specified input attribute exists
110  const UT_StringHolder& name) const
111  {
112  return myInputAttributes.contains(name);
113  }
114 
115  /// Returns the upstream attribute map, i.e. the total set of all upstream
116  /// attributes that might be available to work items in this node.
117  const Config& upstreamAttributes() const
118  { return myUpstreamAttributes; }
119 
120  /// Utility that returns true if the specified upstream attribute exists
122  const UT_StringHolder& name) const
123  {
124  return myUpstreamAttributes.contains(name);
125  }
126 
127  /// Loads a Config object from a JSON array.
128  static bool fromJSON(
129  Config& config,
130  const UT_JSONValueArray& json_array,
131  UT_WorkBuffer& errors);
132 
133 private:
134  Config myOutputAttributes;
135  Config myInputAttributes;
136  Config myUpstreamAttributes;
137 
138  bool myHasDynamicInputs;
139 };
140 
141 #endif
bool contains(const UT_StringHolder &name) const
const Config & upstreamAttributes() const
UT_ArrayStringMap< int > myAttributeCounts
UT_JSONValueArray stores a list of UT_JSONValue objects.
#define PDG_API
Definition: PDG_API.h:23
UT_StringMap< UT_StringSet > myChannelAttributes
class OCIOEXPORT Config
UT_ArrayStringMap< int > myOrigins
bool hasUpstreamAttribute(const UT_StringHolder &name) const
Utility that returns true if the specified upstream attribute exists.
AttribOrigin
Whether the attributes is create/used in the generate/cook stage.
GLboolean reset
Definition: glad.h:5138
const Config & inputAttributes() const
Returns the attributes referenced or use during the current cook.
bool hasInputAttribute(const UT_StringHolder &name) const
Utility that returns true if the specified input attribute exists.
bool hasOutputAttribute(const UT_StringHolder &name) const
Utility that returns true if the specified output attribute exists.
GLuint const GLchar * name
Definition: glcorearb.h:786
const Config & outputAttributes() const