HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Interface.h
Go to the documentation of this file.
1 //
2 // Copyright Contributors to the MaterialX Project
3 // SPDX-License-Identifier: Apache-2.0
4 //
5 
6 #ifndef MATERIALX_INTERFACE_H
7 #define MATERIALX_INTERFACE_H
8 
9 /// @file
10 /// Interface element subclasses
11 
12 #include <MaterialXCore/Export.h>
13 
14 #include <MaterialXCore/Geom.h>
15 
17 
18 class PortElement;
19 class Input;
20 class Output;
21 class InterfaceElement;
22 class Node;
23 class NodeDef;
24 
25 /// A shared pointer to a PortElement
26 using PortElementPtr = shared_ptr<PortElement>;
27 /// A shared pointer to a const PortElement
28 using ConstPortElementPtr = shared_ptr<const PortElement>;
29 
30 /// A shared pointer to an Input
31 using InputPtr = shared_ptr<Input>;
32 /// A shared pointer to a const Input
33 using ConstInputPtr = shared_ptr<const Input>;
34 
35 /// A shared pointer to an Output
36 using OutputPtr = shared_ptr<Output>;
37 /// A shared pointer to a const Output
38 using ConstOutputPtr = shared_ptr<const Output>;
39 
40 /// A shared pointer to an InterfaceElement
41 using InterfaceElementPtr = shared_ptr<InterfaceElement>;
42 /// A shared pointer to a const InterfaceElement
43 using ConstInterfaceElementPtr = shared_ptr<const InterfaceElement>;
44 
45 using CharSet = std::set<char>;
46 
47 /// @class PortElement
48 /// The base class for port elements such as Input and Output.
49 ///
50 /// Port elements support spatially-varying upstream connections to nodes.
52 {
53  protected:
54  PortElement(ElementPtr parent, const string& category, const string& name) :
55  ValueElement(parent, category, name)
56  {
57  }
58 
59  public:
60  virtual ~PortElement() { }
61 
62  protected:
63  using NodePtr = shared_ptr<Node>;
64  using ConstNodePtr = shared_ptr<const Node>;
65 
66  public:
67  /// @name Node Name
68  /// @{
69 
70  /// Set the node name string of this element, creating a connection to
71  /// the Node with the given name within the same NodeGraph.
72  void setNodeName(const string& node)
73  {
74  setAttribute(NODE_NAME_ATTRIBUTE, node);
75  }
76 
77  /// Return true if this element has a node name string.
78  bool hasNodeName() const
79  {
80  return hasAttribute(NODE_NAME_ATTRIBUTE);
81  }
82 
83  /// Return the node name string of this element.
84  const string& getNodeName() const
85  {
86  return getAttribute(NODE_NAME_ATTRIBUTE);
87  }
88 
89  /// @}
90  /// @name Node Graph
91  /// @{
92 
93  /// Set the node graph string of this element.
94  void setNodeGraphString(const string& node)
95  {
96  setAttribute(NODE_GRAPH_ATTRIBUTE, node);
97  }
98 
99  /// Return true if this element has a node graph string.
100  bool hasNodeGraphString() const
101  {
102  return hasAttribute(NODE_GRAPH_ATTRIBUTE);
103  }
104 
105  /// Return the node graph string of this element.
106  const string& getNodeGraphString() const
107  {
108  return getAttribute(NODE_GRAPH_ATTRIBUTE);
109  }
110 
111  /// @}
112  /// @name Output
113  /// @{
114 
115  /// Set the output string of this element.
116  void setOutputString(const string& output)
117  {
118  setAttribute(OUTPUT_ATTRIBUTE, output);
119  }
120 
121  /// Return true if this element has an output string.
122  bool hasOutputString() const
123  {
124  return hasAttribute(OUTPUT_ATTRIBUTE);
125  }
126 
127  /// Set the output to which this input is connected. If the output
128  /// argument is null, then any existing output connection will be cleared.
129  void setConnectedOutput(ConstOutputPtr output);
130 
131  /// Return the output, if any, to which this input is connected.
132  virtual OutputPtr getConnectedOutput() const;
133 
134  /// Return the output string of this element.
135  const string& getOutputString() const
136  {
137  return getAttribute(OUTPUT_ATTRIBUTE);
138  }
139 
140  /// @}
141  /// @name Channels
142  /// @{
143 
144  /// Set the channels string of this element, defining a channel swizzle
145  /// that will be applied to the upstream result if this port is connected.
146  void setChannels(const string& channels)
147  {
148  setAttribute(CHANNELS_ATTRIBUTE, channels);
149  }
150 
151  /// Return true if this element has a channels string.
152  bool hasChannels() const
153  {
154  return hasAttribute(CHANNELS_ATTRIBUTE);
155  }
156 
157  /// Return the channels string of this element.
158  const string& getChannels() const
159  {
160  return getAttribute(CHANNELS_ATTRIBUTE);
161  }
162 
163  /// Return true if the given channels characters are valid for the given
164  /// source type string.
165  static bool validChannelsCharacters(const string& channels, const string& sourceType);
166 
167  /// Return true if the given channels string is valid for the given source
168  /// and destination type strings.
169  static bool validChannelsString(const string& channels, const string& sourceType, const string& destinationType);
170 
171  /// @}
172  /// @name Connections
173  /// @{
174 
175  /// Set the node to which this element is connected. The given node must
176  /// belong to the same node graph. If the node argument is null, then
177  /// any existing node connection will be cleared.
178  void setConnectedNode(ConstNodePtr node);
179 
180  /// Return the node, if any, to which this element is connected.
181  virtual NodePtr getConnectedNode() const;
182 
183  /// @}
184  /// @name Validation
185  /// @{
186 
187  /// Validate that the given element tree, including all descendants, is
188  /// consistent with the MaterialX specification.
189  bool validate(string* message = nullptr) const override;
190 
191  /// @}
192 
193  public:
194  static const string NODE_NAME_ATTRIBUTE;
195  static const string NODE_GRAPH_ATTRIBUTE;
196  static const string OUTPUT_ATTRIBUTE;
197  static const string CHANNELS_ATTRIBUTE;
198 
199  private:
200  static const std::unordered_map<string, CharSet> CHANNELS_CHARACTER_SET;
201  static const std::unordered_map<string, size_t> CHANNELS_PATTERN_LENGTH;
202 };
203 
204 /// @class Input
205 /// An input element within a Node or NodeDef.
206 ///
207 /// An Input holds either a uniform value or a connection to a spatially-varying
208 /// Output, either of which may be modified within the scope of a Material.
210 {
211  public:
212  Input(ElementPtr parent, const string& name) :
213  PortElement(parent, CATEGORY, name)
214  {
215  }
216  virtual ~Input() { }
217 
218  public:
219  /// @name Default Geometric Property
220  /// @{
221 
222  /// Set the defaultgeomprop string for the input.
223  void setDefaultGeomPropString(const string& geomprop)
224  {
225  setAttribute(DEFAULT_GEOM_PROP_ATTRIBUTE, geomprop);
226  }
227 
228  /// Return true if the given input has a defaultgeomprop string.
230  {
231  return hasAttribute(DEFAULT_GEOM_PROP_ATTRIBUTE);
232  }
233 
234  /// Return the defaultgeomprop string for the input.
235  const string& getDefaultGeomPropString() const
236  {
237  return getAttribute(DEFAULT_GEOM_PROP_ATTRIBUTE);
238  }
239 
240  /// Return the GeomPropDef element to use, if defined for this input.
241  GeomPropDefPtr getDefaultGeomProp() const;
242 
243  /// @}
244  /// @name Connections
245  /// @{
246 
247  /// Return the node, if any, to which this input is connected.
248  NodePtr getConnectedNode() const override;
249 
250  /// Return the input on the parent graph corresponding to the interface name
251  /// for this input.
252  InputPtr getInterfaceInput() const;
253 
254  /// @}
255  /// @name Validation
256  /// @{
257 
258  /// Validate that the given element tree, including all descendants, is
259  /// consistent with the MaterialX specification.
260  bool validate(string* message = nullptr) const override;
261 
262  /// @}
263 
264  public:
265  static const string CATEGORY;
266  static const string DEFAULT_GEOM_PROP_ATTRIBUTE;
267 };
268 
269 /// @class Output
270 /// A spatially-varying output element within a NodeGraph or NodeDef.
272 {
273  public:
274  Output(ElementPtr parent, const string& name) :
275  PortElement(parent, CATEGORY, name)
276  {
277  }
278  virtual ~Output() { }
279 
280  public:
281  /// @name Traversal
282  /// @{
283 
284  /// Return the Edge with the given index that lies directly upstream from
285  /// this element in the dataflow graph.
286  Edge getUpstreamEdge(size_t index = 0) const override;
287 
288  /// Return the number of queriable upstream edges for this element.
289  size_t getUpstreamEdgeCount() const override
290  {
291  return 1;
292  }
293 
294  /// Return true if a cycle exists in any upstream path from this element.
295  bool hasUpstreamCycle() const;
296 
297  /// @}
298  /// @name Validation
299  /// @{
300 
301  /// Validate that the given element tree, including all descendants, is
302  /// consistent with the MaterialX specification.
303  bool validate(string* message = nullptr) const override;
304 
305  /// @}
306 
307  public:
308  static const string CATEGORY;
309  static const string DEFAULT_INPUT_ATTRIBUTE;
310 };
311 
312 /// @class InterfaceElement
313 /// The base class for interface elements such as Node, NodeDef, and NodeGraph.
314 ///
315 /// An InterfaceElement supports a set of Input and Output elements, with an API
316 /// for setting their values.
318 {
319  protected:
320  InterfaceElement(ElementPtr parent, const string& category, const string& name) :
321  TypedElement(parent, category, name),
322  _inputCount(0),
323  _outputCount(0)
324  {
325  }
326 
327  public:
328  virtual ~InterfaceElement() { }
329 
330  protected:
331  using NodeDefPtr = shared_ptr<NodeDef>;
332  using ConstNodeDefPtr = shared_ptr<const NodeDef>;
333 
334  public:
335  /// @name NodeDef String
336  /// @{
337 
338  /// Set the NodeDef string for the interface.
339  void setNodeDefString(const string& nodeDef)
340  {
341  setAttribute(NODE_DEF_ATTRIBUTE, nodeDef);
342  }
343 
344  /// Return true if the given interface has a NodeDef string.
345  bool hasNodeDefString() const
346  {
347  return hasAttribute(NODE_DEF_ATTRIBUTE);
348  }
349 
350  /// Return the NodeDef string for the interface.
351  const string& getNodeDefString() const
352  {
353  return getAttribute(NODE_DEF_ATTRIBUTE);
354  }
355 
356  /// @}
357  /// @name Inputs
358  /// @{
359 
360  /// Add an Input to this interface.
361  /// @param name The name of the new Input.
362  /// If no name is specified, then a unique name will automatically be
363  /// generated.
364  /// @param type An optional type string.
365  /// @return A shared pointer to the new Input.
367  const string& type = DEFAULT_TYPE_STRING)
368  {
369  InputPtr child = addChild<Input>(name);
370  child->setType(type);
371  return child;
372  }
373 
374  /// Return the Input, if any, with the given name.
375  InputPtr getInput(const string& name) const
376  {
377  return getChildOfType<Input>(name);
378  }
379 
380  /// Return a vector of all Input elements.
381  vector<InputPtr> getInputs() const
382  {
383  return getChildrenOfType<Input>();
384  }
385 
386  /// Return the number of Input elements.
387  size_t getInputCount() const
388  {
389  return _inputCount;
390  }
391 
392  /// Remove the Input, if any, with the given name.
393  void removeInput(const string& name)
394  {
395  removeChildOfType<Input>(name);
396  }
397 
398  /// Return the first Input with the given name that belongs to this
399  /// interface, taking interface inheritance into account.
400  InputPtr getActiveInput(const string& name) const;
401 
402  /// Return a vector of all Input elements that belong to this interface,
403  /// taking inheritance into account.
404  vector<InputPtr> getActiveInputs() const;
405 
406  /// @}
407  /// @name Outputs
408  /// @{
409 
410  /// Add an Output to this interface.
411  /// @param name The name of the new Output.
412  /// If no name is specified, then a unique name will automatically be
413  /// generated.
414  /// @param type An optional type string.
415  /// @return A shared pointer to the new Output.
417  const string& type = DEFAULT_TYPE_STRING)
418  {
419  OutputPtr output = addChild<Output>(name);
420  output->setType(type);
421  return output;
422  }
423 
424  /// Return the Output, if any, with the given name.
425  OutputPtr getOutput(const string& name) const
426  {
427  return getChildOfType<Output>(name);
428  }
429 
430  /// Return a vector of all Output elements.
431  vector<OutputPtr> getOutputs() const
432  {
433  return getChildrenOfType<Output>();
434  }
435 
436  /// Return the number of Output elements.
437  size_t getOutputCount() const
438  {
439  return _outputCount;
440  }
441 
442  /// Remove the Output, if any, with the given name.
443  void removeOutput(const string& name)
444  {
445  removeChildOfType<Output>(name);
446  }
447 
448  /// Return the first Output with the given name that belongs to this
449  /// interface, taking interface inheritance into account.
450  OutputPtr getActiveOutput(const string& name) const;
451 
452  /// Return a vector of all Output elements that belong to this interface,
453  /// taking inheritance into account.
454  vector<OutputPtr> getActiveOutputs() const;
455 
456  /// Set the output to which the given input is connected, creating a
457  /// child input if needed. If the node argument is null, then any
458  /// existing output connection on the input will be cleared.
459  void setConnectedOutput(const string& inputName, OutputPtr output);
460 
461  /// Return the output connected to the given input. If the given input is
462  /// not present, then an empty OutputPtr is returned.
463  OutputPtr getConnectedOutput(const string& inputName) const;
464 
465  /// @}
466  /// @name Tokens
467  /// @{
468 
469  /// Add a Token to this interface.
470  /// @param name The name of the new Token.
471  /// If no name is specified, then a unique name will automatically be
472  /// generated.
473  /// @return A shared pointer to the new Token.
475  {
476  return addChild<Token>(name);
477  }
478 
479  /// Return the Token, if any, with the given name.
480  TokenPtr getToken(const string& name) const
481  {
482  return getChildOfType<Token>(name);
483  }
484 
485  /// Return a vector of all Token elements.
486  vector<TokenPtr> getTokens() const
487  {
488  return getChildrenOfType<Token>();
489  }
490 
491  /// Remove the Token, if any, with the given name.
492  void removeToken(const string& name)
493  {
494  removeChildOfType<Token>(name);
495  }
496 
497  /// Return the first Token with the given name that belongs to this
498  /// interface, taking interface inheritance into account.
499  TokenPtr getActiveToken(const string& name) const;
500 
501  /// Return a vector of all Token elements that belong to this interface,
502  /// taking inheritance into account.
503  vector<TokenPtr> getActiveTokens() const;
504 
505  /// @}
506  /// @name Value Elements
507  /// @{
508 
509  /// Return the ValueElement, if any, with the given name.
510  ValueElementPtr getValueElement(const string& name) const
511  {
512  return getChildOfType<ValueElement>(name);
513  }
514 
515  /// Return the first value element with the given name that belongs to this
516  /// interface, taking interface inheritance into account.
517  /// Examples of value elements are Input, Output, and Token.
518  ValueElementPtr getActiveValueElement(const string& name) const;
519 
520  /// Return a vector of all value elements that belong to this interface,
521  /// taking inheritance into account.
522  /// Examples of value elements are Input, Output, and Token.
523  vector<ValueElementPtr> getActiveValueElements() const;
524 
525  /// @}
526  /// @name Values
527  /// @{
528 
529  /// Set the typed value of an input by its name, creating a child element
530  /// to hold the input if needed.
531  template <class T> InputPtr setInputValue(const string& name,
532  const T& value,
533  const string& type = EMPTY_STRING);
534 
535  /// Return the typed value of an input by its name, taking both the calling
536  /// element and its declaration into account.
537  /// @param name The name of the input to be evaluated.
538  /// @param target An optional target name, which will be used to filter
539  /// the declarations that are considered.
540  /// @return If the given input is found in this interface or its
541  /// declaration, then a shared pointer to its value is returned;
542  /// otherwise, an empty shared pointer is returned.
543  ValuePtr getInputValue(const string& name, const string& target = EMPTY_STRING) const;
544 
545  /// Set the string value of a Token by its name, creating a child element
546  /// to hold the Token if needed.
547  TokenPtr setTokenValue(const string& name, const string& value)
548  {
549  TokenPtr token = getToken(name);
550  if (!token)
551  token = addToken(name);
552  token->setValue<string>(value);
553  return token;
554  }
555 
556  /// Return the string value of a Token by its name, or an empty string if
557  /// the given Token is not present.
558  string getTokenValue(const string& name)
559  {
560  TokenPtr token = getToken(name);
561  return token ? token->getValueString() : EMPTY_STRING;
562  }
563 
564  /// @}
565  /// @name Target
566  /// @{
567 
568  /// Set the target string of this interface.
569  void setTarget(const string& target)
570  {
571  setAttribute(TARGET_ATTRIBUTE, target);
572  }
573 
574  /// Return true if the given interface has a target string.
575  bool hasTarget() const
576  {
577  return hasAttribute(TARGET_ATTRIBUTE);
578  }
579 
580  /// Return the target string of this interface.
581  const string& getTarget() const
582  {
583  return getAttribute(TARGET_ATTRIBUTE);
584  }
585 
586  /// @}
587  /// @name Version
588  /// @{
589 
590  /// Set the version string of this interface.
591  void setVersionString(const string& version)
592  {
593  setAttribute(VERSION_ATTRIBUTE, version);
594  }
595 
596  /// Return true if this interface has a version string.
597  bool hasVersionString() const
598  {
599  return hasAttribute(VERSION_ATTRIBUTE);
600  }
601 
602  /// Return the version string of this interface.
603  const string& getVersionString() const
604  {
605  return getAttribute(VERSION_ATTRIBUTE);
606  }
607 
608  /// Set the major and minor versions as an integer pair.
609  void setVersionIntegers(int majorVersion, int minorVersion);
610 
611  /// Return the major and minor versions as an integer pair.
612  virtual std::pair<int, int> getVersionIntegers() const;
613 
614  /// @}
615  /// @name Default Version
616  /// @{
617 
618  /// Set the default version flag of this element.
619  void setDefaultVersion(bool defaultVersion)
620  {
621  setTypedAttribute<bool>(DEFAULT_VERSION_ATTRIBUTE, defaultVersion);
622  }
623 
624  /// Return the default version flag of this element.
625  bool getDefaultVersion() const
626  {
627  return getTypedAttribute<bool>(DEFAULT_VERSION_ATTRIBUTE);
628  }
629 
630  /// @}
631  /// @name Utility
632  /// @{
633 
634  /// Return the first declaration of this interface, optionally filtered
635  /// by the given target name.
636  /// @param target An optional target name, which will be used to filter
637  /// the declarations that are considered.
638  /// @return A shared pointer to declaration, or an empty shared pointer if
639  /// no declaration was found.
640  virtual ConstInterfaceElementPtr getDeclaration(const string& target = EMPTY_STRING) const;
641 
642  /// Clear all attributes and descendants from this element.
643  void clearContent() override;
644 
645  /// Return true if this instance has an exact input match with the given
646  /// declaration, where each input of this the instance corresponds to a
647  /// declaration input of the same name and type.
648  ///
649  /// If an exact input match is not found, and the optional message argument
650  /// is provided, then an error message will be appended to the given string.
651  bool hasExactInputMatch(ConstInterfaceElementPtr declaration, string* message = nullptr) const;
652 
653  /// @}
654 
655  public:
656  static const string NODE_DEF_ATTRIBUTE;
657  static const string TARGET_ATTRIBUTE;
658  static const string VERSION_ATTRIBUTE;
659  static const string DEFAULT_VERSION_ATTRIBUTE;
660 
661  protected:
662  void registerChildElement(ElementPtr child) override;
663  void unregisterChildElement(ElementPtr child) override;
664 
665  private:
666  size_t _inputCount;
667  size_t _outputCount;
668 };
669 
670 template <class T> InputPtr InterfaceElement::setInputValue(const string& name,
671  const T& value,
672  const string& type)
673 {
674  InputPtr input = getChildOfType<Input>(name);
675  if (!input)
676  input = addInput(name);
677  input->setValue(value, type);
678  return input;
679 }
680 
682 
683 #endif
static const string NODE_DEF_ATTRIBUTE
Definition: Interface.h:656
Input(ElementPtr parent, const string &name)
Definition: Interface.h:212
GLuint GLsizei const GLchar * message
Definition: glcorearb.h:2543
shared_ptr< Output > OutputPtr
A shared pointer to an Output.
Definition: Interface.h:36
InputPtr setInputValue(const string &name, const T &value, const string &type=EMPTY_STRING)
Definition: Interface.h:670
shared_ptr< NodeDef > NodeDefPtr
Definition: Interface.h:331
OutputPtr getOutput(const string &name) const
Return the Output, if any, with the given name.
Definition: Interface.h:425
virtual void clearContent()
Clear all attributes and descendants from this element.
static const string DEFAULT_GEOM_PROP_ATTRIBUTE
Definition: Interface.h:266
shared_ptr< const PortElement > ConstPortElementPtr
A shared pointer to a const PortElement.
Definition: Interface.h:28
bool hasDefaultGeomPropString() const
Return true if the given input has a defaultgeomprop string.
Definition: Interface.h:229
vector< OutputPtr > getOutputs() const
Return a vector of all Output elements.
Definition: Interface.h:431
static const string NODE_NAME_ATTRIBUTE
Definition: Interface.h:194
#define MATERIALX_NAMESPACE_BEGIN
Definition: Generated.h:25
bool hasVersionString() const
Return true if this interface has a version string.
Definition: Interface.h:597
Definition: Node.h:52
virtual ~Input()
Definition: Interface.h:216
shared_ptr< const InterfaceElement > ConstInterfaceElementPtr
A shared pointer to a const InterfaceElement.
Definition: Interface.h:43
GLsizei const GLfloat * value
Definition: glcorearb.h:824
const string & getNodeName() const
Return the node name string of this element.
Definition: Interface.h:84
shared_ptr< Node > NodePtr
Definition: Interface.h:63
string getTokenValue(const string &name)
Definition: Interface.h:558
virtual ~Output()
Definition: Interface.h:278
MATERIALX_NAMESPACE_BEGIN MX_CORE_API const string EMPTY_STRING
bool getDefaultVersion() const
Return the default version flag of this element.
Definition: Interface.h:625
bool hasNodeGraphString() const
Return true if this element has a node graph string.
Definition: Interface.h:100
shared_ptr< const Node > ConstNodePtr
A shared pointer to a const Node.
Definition: Node.h:26
bool hasNodeName() const
Return true if this element has a node name string.
Definition: Interface.h:78
const string & getAttribute(const string &attrib) const
Definition: Element.h:504
MX_CORE_API std::tuple< int, int, int > getVersionIntegers()
bool hasChannels() const
Return true if this element has a channels string.
Definition: Interface.h:152
vector< InputPtr > getInputs() const
Return a vector of all Input elements.
Definition: Interface.h:381
size_t getUpstreamEdgeCount() const override
Return the number of queriable upstream edges for this element.
Definition: Interface.h:289
shared_ptr< InterfaceElement > InterfaceElementPtr
A shared pointer to an InterfaceElement.
Definition: Interface.h:41
shared_ptr< Token > TokenPtr
A shared pointer to a Token.
Definition: Element.h:46
TokenPtr addToken(const string &name=EMPTY_STRING)
Definition: Interface.h:474
size_t getInputCount() const
Return the number of Input elements.
Definition: Interface.h:387
#define MX_CORE_API
Definition: Export.h:18
void setNodeGraphString(const string &node)
Set the node graph string of this element.
Definition: Interface.h:94
virtual Edge getUpstreamEdge(size_t index=0) const
TokenPtr getToken(const string &name) const
Return the Token, if any, with the given name.
Definition: Interface.h:480
static const string CATEGORY
Definition: Interface.h:265
void setOutputString(const string &output)
Set the output string of this element.
Definition: Interface.h:116
Definition: Traversal.h:29
const string & getNodeDefString() const
Return the NodeDef string for the interface.
Definition: Interface.h:351
Output(ElementPtr parent, const string &name)
Definition: Interface.h:274
void removeToken(const string &name)
Remove the Token, if any, with the given name.
Definition: Interface.h:492
static const string DEFAULT_INPUT_ATTRIBUTE
Definition: Interface.h:309
void setTarget(const string &target)
Set the target string of this interface.
Definition: Interface.h:569
size_t getOutputCount() const
Return the number of Output elements.
Definition: Interface.h:437
virtual ~PortElement()
Definition: Interface.h:60
bool hasNodeDefString() const
Return true if the given interface has a NodeDef string.
Definition: Interface.h:345
shared_ptr< const Input > ConstInputPtr
A shared pointer to a const Input.
Definition: Interface.h:33
shared_ptr< const Output > ConstOutputPtr
A shared pointer to a const Output.
Definition: Interface.h:38
void removeOutput(const string &name)
Remove the Output, if any, with the given name.
Definition: Interface.h:443
InputPtr getInput(const string &name) const
Return the Input, if any, with the given name.
Definition: Interface.h:375
shared_ptr< PortElement > PortElementPtr
A shared pointer to a PortElement.
Definition: Interface.h:26
static const string NODE_GRAPH_ATTRIBUTE
Definition: Interface.h:195
const string & getOutputString() const
Return the output string of this element.
Definition: Interface.h:135
GLenum target
Definition: glcorearb.h:1667
shared_ptr< GeomPropDef > GeomPropDefPtr
A shared pointer to a GeomPropDef.
Definition: Geom.h:48
bool validate(string *message=nullptr) const override
bool hasTarget() const
Return true if the given interface has a target string.
Definition: Interface.h:575
bool validate(string *message=nullptr) const override
InterfaceElement(ElementPtr parent, const string &category, const string &name)
Definition: Interface.h:320
GLuint const GLchar * name
Definition: glcorearb.h:786
void removeInput(const string &name)
Remove the Input, if any, with the given name.
Definition: Interface.h:393
const string & getNodeGraphString() const
Return the node graph string of this element.
Definition: Interface.h:106
OutputPtr addOutput(const string &name=EMPTY_STRING, const string &type=DEFAULT_TYPE_STRING)
Definition: Interface.h:416
void setChannels(const string &channels)
Definition: Interface.h:146
void setDefaultVersion(bool defaultVersion)
Set the default version flag of this element.
Definition: Interface.h:619
ValueElementPtr getValueElement(const string &name) const
Return the ValueElement, if any, with the given name.
Definition: Interface.h:510
SYS_FORCE_INLINE UT_StringHolder getToken(Add enum_value)
Definition: SOP_Add.proto.h:35
shared_ptr< Input > InputPtr
A shared pointer to an Input.
Definition: Interface.h:31
virtual ~InterfaceElement()
Definition: Interface.h:328
GT_API const UT_StringHolder version
void setNodeDefString(const string &nodeDef)
Set the NodeDef string for the interface.
Definition: Interface.h:339
void setVersionString(const string &version)
Set the version string of this interface.
Definition: Interface.h:591
void setAttribute(const string &attrib, const string &value)
Set the value string of the given attribute.
MATERIALX_NAMESPACE_BEGIN MX_CORE_API const string DEFAULT_TYPE_STRING
shared_ptr< const Node > ConstNodePtr
Definition: Interface.h:64
TokenPtr setTokenValue(const string &name, const string &value)
Definition: Interface.h:547
static const string CATEGORY
Definition: Interface.h:308
shared_ptr< const NodeDef > ConstNodeDefPtr
Definition: Interface.h:332
bool hasAttribute(const string &attrib) const
Return true if the given attribute is present.
Definition: Element.h:497
static const string DEFAULT_VERSION_ATTRIBUTE
Definition: Interface.h:659
PortElement(ElementPtr parent, const string &category, const string &name)
Definition: Interface.h:54
static const string VERSION_ATTRIBUTE
Definition: Interface.h:658
GLuint index
Definition: glcorearb.h:786
bool hasOutputString() const
Return true if this element has an output string.
Definition: Interface.h:122
virtual void unregisterChildElement(ElementPtr child)
static const string TARGET_ATTRIBUTE
Definition: Interface.h:657
std::set< char > CharSet
Definition: Interface.h:45
virtual void registerChildElement(ElementPtr child)
virtual NodePtr getConnectedNode() const
Return the node, if any, to which this element is connected.
Definition: core.h:1131
shared_ptr< Element > ElementPtr
A shared pointer to an Element.
Definition: Element.h:31
shared_ptr< ValueElement > ValueElementPtr
A shared pointer to a ValueElement.
Definition: Element.h:41
#define MATERIALX_NAMESPACE_END
Definition: Generated.h:26
const string & getTarget() const
Return the target string of this interface.
Definition: Interface.h:581
static const string CHANNELS_ATTRIBUTE
Definition: Interface.h:197
const string & getChannels() const
Return the channels string of this element.
Definition: Interface.h:158
void setDefaultGeomPropString(const string &geomprop)
Set the defaultgeomprop string for the input.
Definition: Interface.h:223
vector< TokenPtr > getTokens() const
Return a vector of all Token elements.
Definition: Interface.h:486
shared_ptr< Value > ValuePtr
A shared pointer to a Value.
Definition: Value.h:29
type
Definition: core.h:1059
InputPtr addInput(const string &name=EMPTY_STRING, const string &type=DEFAULT_TYPE_STRING)
Definition: Interface.h:366
const string & getDefaultGeomPropString() const
Return the defaultgeomprop string for the input.
Definition: Interface.h:235
static const string OUTPUT_ATTRIBUTE
Definition: Interface.h:196
ImageBuf OIIO_API channels(const ImageBuf &src, int nchannels, cspan< int > channelorder, cspan< float > channelvalues={}, cspan< std::string > newchannelnames={}, bool shuffle_channel_names=false, int nthreads=0)
void setNodeName(const string &node)
Definition: Interface.h:72
shared_ptr< Node > NodePtr
A shared pointer to a Node.
Definition: Node.h:24
const string & getVersionString() const
Return the version string of this interface.
Definition: Interface.h:603