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  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 Connections
142  /// @{
143 
144  /// Set the node to which this element is connected. The given node must
145  /// belong to the same node graph. If the node argument is null, then
146  /// any existing node connection will be cleared.
147  void setConnectedNode(ConstNodePtr node);
148 
149  /// Return the node, if any, to which this element is connected.
150  virtual NodePtr getConnectedNode() const;
151 
152  /// @}
153  /// @name Validation
154  /// @{
155 
156  /// Validate that the given element tree, including all descendants, is
157  /// consistent with the MaterialX specification.
158  bool validate(string* message = nullptr) const override;
159 
160  /// @}
161 
162  public:
163  static const string NODE_NAME_ATTRIBUTE;
164  static const string NODE_GRAPH_ATTRIBUTE;
165  static const string OUTPUT_ATTRIBUTE;
166 };
167 
168 /// @class Input
169 /// An input element within a Node or NodeDef.
170 ///
171 /// An Input holds either a uniform value or a connection to a spatially-varying
172 /// Output, either of which may be modified within the scope of a Material.
174 {
175  public:
176  Input(ElementPtr parent, const string& name) :
177  PortElement(parent, CATEGORY, name)
178  {
179  }
180  virtual ~Input() { }
181 
182  public:
183  /// @name Default Geometric Property
184  /// @{
185 
186  /// Set the defaultgeomprop string for the input.
187  void setDefaultGeomPropString(const string& geomprop)
188  {
189  setAttribute(DEFAULT_GEOM_PROP_ATTRIBUTE, geomprop);
190  }
191 
192  /// Return true if the given input has a defaultgeomprop string.
194  {
195  return hasAttribute(DEFAULT_GEOM_PROP_ATTRIBUTE);
196  }
197 
198  /// Return the defaultgeomprop string for the input.
199  const string& getDefaultGeomPropString() const
200  {
201  return getAttribute(DEFAULT_GEOM_PROP_ATTRIBUTE);
202  }
203 
204  /// Return the GeomPropDef element to use, if defined for this input.
205  GeomPropDefPtr getDefaultGeomProp() const;
206 
207  /// @}
208  /// @name Connections
209  /// @{
210 
211  /// Return the node, if any, to which this input is connected.
212  NodePtr getConnectedNode() const override;
213 
214  /// Connects this input to a corresponding interface with the given name.
215  /// If the interface name specified is an empty string then any existing connection is removed.
216  void setConnectedInterfaceName(const string& interfaceName);
217 
218  /// Return the input on the parent graph corresponding to the interface name
219  /// for this input.
220  InputPtr getInterfaceInput() const;
221 
222  /// @}
223  /// @name Hints
224  /// @{
225 
226  /// Return true if the input has a hint
227  bool hasHint() const
228  {
229  return hasAttribute(HINT_ATTRIBUTE);
230  }
231 
232  /// Return the code generation hint
233  const string& getHint() const
234  {
235  return getAttribute(HINT_ATTRIBUTE);
236  }
237 
238  // Set the code generation hint
239  void setHint(const string& hint)
240  {
241  setAttribute(HINT_ATTRIBUTE, hint);
242  }
243 
244  /// @}
245  /// @name Validation
246  /// @{
247 
248  /// Validate that the given element tree, including all descendants, is
249  /// consistent with the MaterialX specification.
250  bool validate(string* message = nullptr) const override;
251 
252  /// @}
253 
254  public:
255  static const string CATEGORY;
256  static const string DEFAULT_GEOM_PROP_ATTRIBUTE;
257  static const string HINT_ATTRIBUTE;
258  static const string TRANSPARENCY_HINT;
259  static const string OPACITY_HINT;
260  static const string ANISOTROPY_HINT;
261 };
262 
263 /// @class Output
264 /// A spatially-varying output element within a NodeGraph or NodeDef.
266 {
267  public:
268  Output(ElementPtr parent, const string& name) :
269  PortElement(parent, CATEGORY, name)
270  {
271  }
272  virtual ~Output() { }
273 
274  public:
275  /// @name Traversal
276  /// @{
277 
278  /// Return the Edge with the given index that lies directly upstream from
279  /// this element in the dataflow graph.
280  Edge getUpstreamEdge(size_t index = 0) const override;
281 
282  /// Return the number of queryable upstream edges for this element.
283  size_t getUpstreamEdgeCount() const override
284  {
285  return 1;
286  }
287 
288  /// Return true if a cycle exists in any upstream path from this element.
289  bool hasUpstreamCycle() const;
290 
291  /// @}
292  /// @name Validation
293  /// @{
294 
295  /// Validate that the given element tree, including all descendants, is
296  /// consistent with the MaterialX specification.
297  bool validate(string* message = nullptr) const override;
298 
299  /// @}
300 
301  public:
302  static const string CATEGORY;
303  static const string DEFAULT_INPUT_ATTRIBUTE;
304 };
305 
306 /// @class InterfaceElement
307 /// The base class for interface elements such as Node, NodeDef, and NodeGraph.
308 ///
309 /// An InterfaceElement supports a set of Input and Output elements, with an API
310 /// for setting their values.
312 {
313  protected:
314  InterfaceElement(ElementPtr parent, const string& category, const string& name) :
315  TypedElement(parent, category, name),
316  _inputCount(0),
317  _outputCount(0)
318  {
319  }
320 
321  public:
322  virtual ~InterfaceElement() { }
323 
324  protected:
325  using NodeDefPtr = shared_ptr<NodeDef>;
326  using ConstNodeDefPtr = shared_ptr<const NodeDef>;
327 
328  public:
329  /// @name NodeDef String
330  /// @{
331 
332  /// Set the NodeDef string for the interface.
333  void setNodeDefString(const string& nodeDef)
334  {
335  setAttribute(NODE_DEF_ATTRIBUTE, nodeDef);
336  }
337 
338  /// Return true if the given interface has a NodeDef string.
339  bool hasNodeDefString() const
340  {
341  return hasAttribute(NODE_DEF_ATTRIBUTE);
342  }
343 
344  /// Return the NodeDef string for the interface.
345  const string& getNodeDefString() const
346  {
347  return getAttribute(NODE_DEF_ATTRIBUTE);
348  }
349 
350  /// @}
351  /// @name Inputs
352  /// @{
353 
354  /// Add an Input to this interface.
355  /// @param name The name of the new Input.
356  /// If no name is specified, then a unique name will automatically be
357  /// generated.
358  /// @param type An optional type string.
359  /// @return A shared pointer to the new Input.
361  const string& type = DEFAULT_TYPE_STRING)
362  {
363  InputPtr child = addChild<Input>(name);
364  child->setType(type);
365  return child;
366  }
367 
368  /// Return the Input, if any, with the given name.
369  InputPtr getInput(const string& name) const
370  {
371  return getChildOfType<Input>(name);
372  }
373 
374  /// Return a vector of all Input elements.
375  vector<InputPtr> getInputs() const
376  {
377  return getChildrenOfType<Input>();
378  }
379 
380  /// Return the number of Input elements.
381  size_t getInputCount() const
382  {
383  return _inputCount;
384  }
385 
386  /// Remove the Input, if any, with the given name.
387  void removeInput(const string& name)
388  {
389  removeChildOfType<Input>(name);
390  }
391 
392  /// Return the first Input with the given name that belongs to this
393  /// interface, taking interface inheritance into account.
394  InputPtr getActiveInput(const string& name) const;
395 
396  /// Return a vector of all Input elements that belong to this interface,
397  /// taking inheritance into account.
398  vector<InputPtr> getActiveInputs() const;
399 
400  /// @}
401  /// @name Outputs
402  /// @{
403 
404  /// Add an Output to this interface.
405  /// @param name The name of the new Output.
406  /// If no name is specified, then a unique name will automatically be
407  /// generated.
408  /// @param type An optional type string.
409  /// @return A shared pointer to the new Output.
411  const string& type = DEFAULT_TYPE_STRING)
412  {
413  OutputPtr output = addChild<Output>(name);
414  output->setType(type);
415  return output;
416  }
417 
418  /// Return the Output, if any, with the given name.
419  OutputPtr getOutput(const string& name) const
420  {
421  return getChildOfType<Output>(name);
422  }
423 
424  /// Return a vector of all Output elements.
425  vector<OutputPtr> getOutputs() const
426  {
427  return getChildrenOfType<Output>();
428  }
429 
430  /// Return the number of Output elements.
431  size_t getOutputCount() const
432  {
433  return _outputCount;
434  }
435 
436  /// Remove the Output, if any, with the given name.
437  void removeOutput(const string& name)
438  {
439  removeChildOfType<Output>(name);
440  }
441 
442  /// Return the first Output with the given name that belongs to this
443  /// interface, taking interface inheritance into account.
444  OutputPtr getActiveOutput(const string& name) const;
445 
446  /// Return a vector of all Output elements that belong to this interface,
447  /// taking inheritance into account.
448  vector<OutputPtr> getActiveOutputs() const;
449 
450  /// Set the output to which the given input is connected, creating a
451  /// child input if needed. If the node argument is null, then any
452  /// existing output connection on the input will be cleared.
453  void setConnectedOutput(const string& inputName, OutputPtr output);
454 
455  /// Return the output connected to the given input. If the given input is
456  /// not present, then an empty OutputPtr is returned.
457  OutputPtr getConnectedOutput(const string& inputName) const;
458 
459  /// @}
460  /// @name Tokens
461  /// @{
462 
463  /// Add a Token to this interface.
464  /// @param name The name of the new Token.
465  /// If no name is specified, then a unique name will automatically be
466  /// generated.
467  /// @return A shared pointer to the new Token.
469  {
470  return addChild<Token>(name);
471  }
472 
473  /// Return the Token, if any, with the given name.
474  TokenPtr getToken(const string& name) const
475  {
476  return getChildOfType<Token>(name);
477  }
478 
479  /// Return a vector of all Token elements.
480  vector<TokenPtr> getTokens() const
481  {
482  return getChildrenOfType<Token>();
483  }
484 
485  /// Remove the Token, if any, with the given name.
486  void removeToken(const string& name)
487  {
488  removeChildOfType<Token>(name);
489  }
490 
491  /// Return the first Token with the given name that belongs to this
492  /// interface, taking interface inheritance into account.
493  TokenPtr getActiveToken(const string& name) const;
494 
495  /// Return a vector of all Token elements that belong to this interface,
496  /// taking inheritance into account.
497  vector<TokenPtr> getActiveTokens() const;
498 
499  /// @}
500  /// @name Value Elements
501  /// @{
502 
503  /// Return the ValueElement, if any, with the given name.
504  ValueElementPtr getValueElement(const string& name) const
505  {
506  return getChildOfType<ValueElement>(name);
507  }
508 
509  /// Return the first value element with the given name that belongs to this
510  /// interface, taking interface inheritance into account.
511  /// Examples of value elements are Input, Output, and Token.
512  ValueElementPtr getActiveValueElement(const string& name) const;
513 
514  /// Return a vector of all value elements that belong to this interface,
515  /// taking inheritance into account.
516  /// Examples of value elements are Input, Output, and Token.
517  vector<ValueElementPtr> getActiveValueElements() const;
518 
519  /// @}
520  /// @name Values
521  /// @{
522 
523  /// Set the typed value of an input by its name, creating a child element
524  /// to hold the input if needed.
525  template <class T> InputPtr setInputValue(const string& name,
526  const T& value,
527  const string& type = EMPTY_STRING);
528 
529  /// Return the typed value of an input by its name, taking both the calling
530  /// element and its declaration into account.
531  /// @param name The name of the input to be evaluated.
532  /// @param target An optional target name, which will be used to filter
533  /// the declarations that are considered.
534  /// @return If the given input is found in this interface or its
535  /// declaration, then a shared pointer to its value is returned;
536  /// otherwise, an empty shared pointer is returned.
537  ValuePtr getInputValue(const string& name, const string& target = EMPTY_STRING) const;
538 
539  /// Set the string value of a Token by its name, creating a child element
540  /// to hold the Token if needed.
541  TokenPtr setTokenValue(const string& name, const string& value)
542  {
543  TokenPtr token = getToken(name);
544  if (!token)
545  token = addToken(name);
546  token->setValue<string>(value);
547  return token;
548  }
549 
550  /// Return the string value of a Token by its name, or an empty string if
551  /// the given Token is not present.
552  string getTokenValue(const string& name)
553  {
554  TokenPtr token = getToken(name);
555  return token ? token->getValueString() : EMPTY_STRING;
556  }
557 
558  /// @}
559  /// @name Target
560  /// @{
561 
562  /// Set the target string of this interface.
563  void setTarget(const string& target)
564  {
565  setAttribute(TARGET_ATTRIBUTE, target);
566  }
567 
568  /// Return true if the given interface has a target string.
569  bool hasTarget() const
570  {
571  return hasAttribute(TARGET_ATTRIBUTE);
572  }
573 
574  /// Return the target string of this interface.
575  const string& getTarget() const
576  {
577  return getAttribute(TARGET_ATTRIBUTE);
578  }
579 
580  /// @}
581  /// @name Version
582  /// @{
583 
584  /// Set the version string of this interface.
585  void setVersionString(const string& version)
586  {
587  setAttribute(VERSION_ATTRIBUTE, version);
588  }
589 
590  /// Return true if this interface has a version string.
591  bool hasVersionString() const
592  {
593  return hasAttribute(VERSION_ATTRIBUTE);
594  }
595 
596  /// Return the version string of this interface.
597  const string& getVersionString() const
598  {
599  return getAttribute(VERSION_ATTRIBUTE);
600  }
601 
602  /// Set the major and minor versions as an integer pair.
603  void setVersionIntegers(int majorVersion, int minorVersion);
604 
605  /// Return the major and minor versions as an integer pair.
606  virtual std::pair<int, int> getVersionIntegers() const;
607 
608  /// @}
609  /// @name Default Version
610  /// @{
611 
612  /// Set the default version flag of this element.
613  void setDefaultVersion(bool defaultVersion)
614  {
615  setTypedAttribute<bool>(DEFAULT_VERSION_ATTRIBUTE, defaultVersion);
616  }
617 
618  /// Return the default version flag of this element.
619  bool getDefaultVersion() const
620  {
621  return getTypedAttribute<bool>(DEFAULT_VERSION_ATTRIBUTE);
622  }
623 
624  /// @}
625  /// @name Utility
626  /// @{
627 
628  /// Return the first declaration of this interface, optionally filtered
629  /// by the given target name.
630  /// @param target An optional target name, which will be used to filter
631  /// the declarations that are considered.
632  /// @return A shared pointer to declaration, or an empty shared pointer if
633  /// no declaration was found.
634  virtual ConstInterfaceElementPtr getDeclaration(const string& target = EMPTY_STRING) const;
635 
636  /// Clear all attributes and descendants from this element.
637  void clearContent() override;
638 
639  /// Return true if this instance has an exact input match with the given
640  /// declaration, where each input of this the instance corresponds to a
641  /// declaration input of the same name and type.
642  ///
643  /// If an exact input match is not found, and the optional message argument
644  /// is provided, then an error message will be appended to the given string.
645  bool hasExactInputMatch(ConstInterfaceElementPtr declaration, string* message = nullptr) const;
646 
647  /// @}
648 
649  public:
650  static const string NODE_DEF_ATTRIBUTE;
651  static const string TARGET_ATTRIBUTE;
652  static const string VERSION_ATTRIBUTE;
653  static const string DEFAULT_VERSION_ATTRIBUTE;
654 
655  protected:
656  void registerChildElement(ElementPtr child) override;
657  void unregisterChildElement(ElementPtr child) override;
658 
659  private:
660  size_t _inputCount;
661  size_t _outputCount;
662 };
663 
664 template <class T> InputPtr InterfaceElement::setInputValue(const string& name,
665  const T& value,
666  const string& type)
667 {
668  InputPtr input = getChildOfType<Input>(name);
669  if (!input)
670  input = addInput(name);
671  input->setValue(value, type);
672  return input;
673 }
674 
676 
677 #endif
static const string NODE_DEF_ATTRIBUTE
Definition: Interface.h:650
static const string ANISOTROPY_HINT
Definition: Interface.h:260
Input(ElementPtr parent, const string &name)
Definition: Interface.h:176
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:664
shared_ptr< NodeDef > NodeDefPtr
Definition: Interface.h:325
OutputPtr getOutput(const string &name) const
Return the Output, if any, with the given name.
Definition: Interface.h:419
virtual void clearContent()
Clear all attributes and descendants from this element.
static const string DEFAULT_GEOM_PROP_ATTRIBUTE
Definition: Interface.h:256
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:193
static const string OPACITY_HINT
Definition: Interface.h:259
vector< OutputPtr > getOutputs() const
Return a vector of all Output elements.
Definition: Interface.h:425
static const string NODE_NAME_ATTRIBUTE
Definition: Interface.h:163
#define MATERIALX_NAMESPACE_BEGIN
Definition: Generated.h:25
bool hasVersionString() const
Return true if this interface has a version string.
Definition: Interface.h:591
Definition: Node.h:52
virtual ~Input()
Definition: Interface.h:180
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:552
virtual ~Output()
Definition: Interface.h:272
MATERIALX_NAMESPACE_BEGIN MX_CORE_API const string EMPTY_STRING
bool getDefaultVersion() const
Return the default version flag of this element.
Definition: Interface.h:619
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:492
MX_CORE_API std::tuple< int, int, int > getVersionIntegers()
vector< InputPtr > getInputs() const
Return a vector of all Input elements.
Definition: Interface.h:375
size_t getUpstreamEdgeCount() const override
Return the number of queryable upstream edges for this element.
Definition: Interface.h:283
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:468
size_t getInputCount() const
Return the number of Input elements.
Definition: Interface.h:381
#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:474
static const string CATEGORY
Definition: Interface.h:255
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:345
Output(ElementPtr parent, const string &name)
Definition: Interface.h:268
void removeToken(const string &name)
Remove the Token, if any, with the given name.
Definition: Interface.h:486
GLint GLint GLsizei GLint GLenum GLenum type
Definition: glcorearb.h:108
static const string DEFAULT_INPUT_ATTRIBUTE
Definition: Interface.h:303
void setTarget(const string &target)
Set the target string of this interface.
Definition: Interface.h:563
size_t getOutputCount() const
Return the number of Output elements.
Definition: Interface.h:431
virtual ~PortElement()
Definition: Interface.h:60
static const string TRANSPARENCY_HINT
Definition: Interface.h:258
bool hasNodeDefString() const
Return true if the given interface has a NodeDef string.
Definition: Interface.h:339
static const string HINT_ATTRIBUTE
Definition: Interface.h:257
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:437
InputPtr getInput(const string &name) const
Return the Input, if any, with the given name.
Definition: Interface.h:369
shared_ptr< PortElement > PortElementPtr
A shared pointer to a PortElement.
Definition: Interface.h:26
static const string NODE_GRAPH_ATTRIBUTE
Definition: Interface.h:164
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:569
bool validate(string *message=nullptr) const override
InterfaceElement(ElementPtr parent, const string &category, const string &name)
Definition: Interface.h:314
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:387
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:410
void setDefaultVersion(bool defaultVersion)
Set the default version flag of this element.
Definition: Interface.h:613
ValueElementPtr getValueElement(const string &name) const
Return the ValueElement, if any, with the given name.
Definition: Interface.h:504
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:322
GT_API const UT_StringHolder version
const string & getHint() const
Return the code generation hint.
Definition: Interface.h:233
void setNodeDefString(const string &nodeDef)
Set the NodeDef string for the interface.
Definition: Interface.h:333
void setVersionString(const string &version)
Set the version string of this interface.
Definition: Interface.h:585
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:541
static const string CATEGORY
Definition: Interface.h:302
shared_ptr< const NodeDef > ConstNodeDefPtr
Definition: Interface.h:326
bool hasHint() const
Return true if the input has a hint.
Definition: Interface.h:227
bool hasAttribute(const string &attrib) const
Return true if the given attribute is present.
Definition: Element.h:485
static const string DEFAULT_VERSION_ATTRIBUTE
Definition: Interface.h:653
PortElement(ElementPtr parent, const string &category, const string &name)
Definition: Interface.h:54
static const string VERSION_ATTRIBUTE
Definition: Interface.h:652
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:651
void setHint(const string &hint)
Return true if the input has a hint.
Definition: Interface.h:239
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.
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:575
void setDefaultGeomPropString(const string &geomprop)
Set the defaultgeomprop string for the input.
Definition: Interface.h:187
vector< TokenPtr > getTokens() const
Return a vector of all Token elements.
Definition: Interface.h:480
shared_ptr< Value > ValuePtr
A shared pointer to a Value.
Definition: Value.h:30
InputPtr addInput(const string &name=EMPTY_STRING, const string &type=DEFAULT_TYPE_STRING)
Definition: Interface.h:360
const string & getDefaultGeomPropString() const
Return the defaultgeomprop string for the input.
Definition: Interface.h:199
static const string OUTPUT_ATTRIBUTE
Definition: Interface.h:165
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:597