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