HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Node Class Reference

#include <Node.h>

+ Inheritance diagram for Node:

Public Member Functions

 Node (ElementPtr parent, const string &name)
 
virtual ~Node ()
 
Connections
void setConnectedNode (const string &inputName, ConstNodePtr node)
 
NodePtr getConnectedNode (const string &inputName) const
 
void setConnectedNodeName (const string &inputName, const string &nodeName)
 
string getConnectedNodeName (const string &inputName) const
 
void setConnectedOutput (const string &inputName, OutputPtr output)
 
OutputPtr getConnectedOutput (const string &inputName) const
 
NodeDef References
NodeDefPtr getNodeDef (const string &target=EMPTY_STRING, bool allowRoughMatch=false) const
 
Implementation References
InterfaceElementPtr getImplementation (const string &target=EMPTY_STRING) const
 
Traversal
Edge getUpstreamEdge (size_t index=0) const override
 
size_t getUpstreamEdgeCount () const override
 Return the number of queriable upstream edges for this element. More...
 
OutputPtr getNodeDefOutput (ElementPtr connectingElement)
 
vector< PortElementPtrgetDownstreamPorts () const
 
Utility
ConstInterfaceElementPtr getDeclaration (const string &target=EMPTY_STRING) const override
 
InputPtr addInputFromNodeDef (const string &inputName)
 
void addInputsFromNodeDef ()
 Add inputs based on the corresponding associated node definition. More...
 
Validation
bool validate (string *message=nullptr) const override
 
- Public Member Functions inherited from InterfaceElement
virtual ~InterfaceElement ()
 
void setNodeDefString (const string &nodeDef)
 Set the NodeDef string for the interface. More...
 
bool hasNodeDefString () const
 Return true if the given interface has a NodeDef string. More...
 
const stringgetNodeDefString () const
 Return the NodeDef string for the interface. More...
 
InputPtr addInput (const string &name=EMPTY_STRING, const string &type=DEFAULT_TYPE_STRING)
 
InputPtr getInput (const string &name) const
 Return the Input, if any, with the given name. More...
 
vector< InputPtrgetInputs () const
 Return a vector of all Input elements. More...
 
size_t getInputCount () const
 Return the number of Input elements. More...
 
void removeInput (const string &name)
 Remove the Input, if any, with the given name. More...
 
InputPtr getActiveInput (const string &name) const
 
vector< InputPtrgetActiveInputs () const
 
OutputPtr addOutput (const string &name=EMPTY_STRING, const string &type=DEFAULT_TYPE_STRING)
 
OutputPtr getOutput (const string &name) const
 Return the Output, if any, with the given name. More...
 
vector< OutputPtrgetOutputs () const
 Return a vector of all Output elements. More...
 
size_t getOutputCount () const
 Return the number of Output elements. More...
 
void removeOutput (const string &name)
 Remove the Output, if any, with the given name. More...
 
OutputPtr getActiveOutput (const string &name) const
 
vector< OutputPtrgetActiveOutputs () const
 
void setConnectedOutput (const string &inputName, OutputPtr output)
 
OutputPtr getConnectedOutput (const string &inputName) const
 
TokenPtr addToken (const string &name=EMPTY_STRING)
 
TokenPtr getToken (const string &name) const
 Return the Token, if any, with the given name. More...
 
vector< TokenPtrgetTokens () const
 Return a vector of all Token elements. More...
 
void removeToken (const string &name)
 Remove the Token, if any, with the given name. More...
 
TokenPtr getActiveToken (const string &name) const
 
vector< TokenPtrgetActiveTokens () const
 
ValueElementPtr getValueElement (const string &name) const
 Return the ValueElement, if any, with the given name. More...
 
ValueElementPtr getActiveValueElement (const string &name) const
 
vector< ValueElementPtrgetActiveValueElements () const
 
template<class T >
InputPtr setInputValue (const string &name, const T &value, const string &type=EMPTY_STRING)
 
ValuePtr getInputValue (const string &name, const string &target=EMPTY_STRING) const
 
TokenPtr setTokenValue (const string &name, const string &value)
 
string getTokenValue (const string &name)
 
void setTarget (const string &target)
 Set the target string of this interface. More...
 
bool hasTarget () const
 Return true if the given interface has a target string. More...
 
const stringgetTarget () const
 Return the target string of this interface. More...
 
void setVersionString (const string &version)
 Set the version string of this interface. More...
 
bool hasVersionString () const
 Return true if this interface has a version string. More...
 
const stringgetVersionString () const
 Return the version string of this interface. More...
 
void setVersionIntegers (int majorVersion, int minorVersion)
 Set the major and minor versions as an integer pair. More...
 
virtual std::pair< int, intgetVersionIntegers () const
 Return the major and minor versions as an integer pair. More...
 
void setDefaultVersion (bool defaultVersion)
 Set the default version flag of this element. More...
 
bool getDefaultVersion () const
 Return the default version flag of this element. More...
 
void clearContent () override
 Clear all attributes and descendants from this element. More...
 
bool hasExactInputMatch (ConstInterfaceElementPtr declaration, string *message=nullptr) const
 
- Public Member Functions inherited from TypedElement
virtual ~TypedElement ()
 
void setType (const string &type)
 Set the element's type string. More...
 
bool hasType () const
 Return true if the given element has a type string. More...
 
virtual const stringgetType () const
 Return the element's type string. More...
 
bool isColorType () const
 Return true if the element is of color type. More...
 
bool isMultiOutputType () const
 Return true if the element is of multi-output type. More...
 
TypeDefPtr getTypeDef () const
 
- Public Member Functions inherited from Element
virtual ~Element ()
 
 Element (const Element &)=delete
 
Elementoperator= (const Element &)=delete
 
bool operator== (const Element &rhs) const
 
bool operator!= (const Element &rhs) const
 
void setCategory (const string &category)
 Set the element's category string. More...
 
const stringgetCategory () const
 
void setName (const string &name)
 
const stringgetName () const
 Return the element's name string. More...
 
string getNamePath (ConstElementPtr relativeTo=nullptr) const
 
ElementPtr getDescendant (const string &namePath) const
 
void setFilePrefix (const string &prefix)
 Set the element's file prefix string. More...
 
bool hasFilePrefix () const
 Return true if the given element has a file prefix string. More...
 
const stringgetFilePrefix () const
 Return the element's file prefix string. More...
 
const stringgetActiveFilePrefix () const
 
void setGeomPrefix (const string &prefix)
 Set the element's geom prefix string. More...
 
bool hasGeomPrefix () const
 Return true if the given element has a geom prefix string. More...
 
const stringgetGeomPrefix () const
 Return the element's geom prefix string. More...
 
const stringgetActiveGeomPrefix () const
 
void setColorSpace (const string &colorSpace)
 Set the element's color space string. More...
 
bool hasColorSpace () const
 Return true if the given element has a color space string. More...
 
const stringgetColorSpace () const
 Return the element's color space string. More...
 
const stringgetActiveColorSpace () const
 
void setInheritString (const string &inherit)
 Set the inherit string of this element. More...
 
bool hasInheritString () const
 Return true if this element has an inherit string. More...
 
const stringgetInheritString () const
 Return the inherit string of this element. More...
 
void setInheritsFrom (ConstElementPtr super)
 Set the element that this one directly inherits from. More...
 
ElementPtr getInheritsFrom () const
 Return the element, if any, that this one directly inherits from. More...
 
bool hasInheritedBase (ConstElementPtr base) const
 
bool hasInheritanceCycle () const
 Return true if the inheritance chain for this element contains a cycle. More...
 
void setNamespace (const string &space)
 Set the namespace string of this element. More...
 
bool hasNamespace () const
 Return true if this element has a namespace string. More...
 
const stringgetNamespace () const
 Return the namespace string of this element. More...
 
string getQualifiedName (const string &name) const
 
void setDocString (const string &doc)
 Set the documentation string of this element. More...
 
string getDocString () const
 Return the documentation string of this element. More...
 
template<class T >
bool isA (const string &category=EMPTY_STRING) const
 
template<class T >
shared_ptr< TasA ()
 Dynamic cast to an instance of the given subclass. More...
 
template<class T >
shared_ptr< const TasA () const
 Dynamic cast to a const instance of the given subclass. More...
 
template<class T >
shared_ptr< TaddChild (const string &name=EMPTY_STRING)
 
ElementPtr addChildOfCategory (const string &category, string name=EMPTY_STRING)
 
ElementPtr changeChildCategory (ElementPtr child, const string &category)
 
ElementPtr getChild (const string &name) const
 Return the child element, if any, with the given name. More...
 
template<class T >
shared_ptr< TgetChildOfType (const string &name) const
 
const vector< ElementPtr > & getChildren () const
 
template<class T >
vector< shared_ptr< T > > getChildrenOfType (const string &category=EMPTY_STRING) const
 
void setChildIndex (const string &name, int index)
 
int getChildIndex (const string &name) const
 
void removeChild (const string &name)
 Remove the child element, if any, with the given name. More...
 
template<class T >
void removeChildOfType (const string &name)
 
void setAttribute (const string &attrib, const string &value)
 Set the value string of the given attribute. More...
 
bool hasAttribute (const string &attrib) const
 Return true if the given attribute is present. More...
 
const stringgetAttribute (const string &attrib) const
 
const StringVecgetAttributeNames () const
 Return a vector of stored attribute names, in the order they were set. More...
 
template<class T >
void setTypedAttribute (const string &attrib, const T &data)
 
template<class T >
T getTypedAttribute (const string &attrib) const
 
void removeAttribute (const string &attrib)
 Remove the given attribute, if present. More...
 
ElementPtr getSelf ()
 Return our self pointer. More...
 
ConstElementPtr getSelf () const
 Return our self pointer. More...
 
ElementPtr getParent ()
 Return our parent element. More...
 
ConstElementPtr getParent () const
 Return our parent element. More...
 
ElementPtr getRoot ()
 Return the root element of our tree. More...
 
ConstElementPtr getRoot () const
 Return the root element of our tree. More...
 
DocumentPtr getDocument ()
 Return the root document of our tree. More...
 
ConstDocumentPtr getDocument () const
 Return the root document of our tree. More...
 
template<class T >
shared_ptr< const TgetAncestorOfType () const
 
TreeIterator traverseTree () const
 
GraphIterator traverseGraph () const
 
ElementPtr getUpstreamElement (size_t index=0) const
 
InheritanceIterator traverseInheritance () const
 
void setSourceUri (const string &sourceUri)
 
bool hasSourceUri () const
 Return true if this element has a source URI. More...
 
const stringgetSourceUri () const
 Return the element's source URI. More...
 
const stringgetActiveSourceUri () const
 
void copyContentFrom (const ConstElementPtr &source)
 
string createValidChildName (string name) const
 
StringResolverPtr createStringResolver (const string &geom=EMPTY_STRING) const
 
string asString () const
 

Static Public Attributes

static const string CATEGORY
 
- Static Public Attributes inherited from InterfaceElement
static const string NODE_DEF_ATTRIBUTE
 
static const string TARGET_ATTRIBUTE
 
static const string VERSION_ATTRIBUTE
 
static const string DEFAULT_VERSION_ATTRIBUTE
 
- Static Public Attributes inherited from TypedElement
static const string TYPE_ATTRIBUTE
 
- Static Public Attributes inherited from Element
static const string NAME_ATTRIBUTE
 
static const string FILE_PREFIX_ATTRIBUTE
 
static const string GEOM_PREFIX_ATTRIBUTE
 
static const string COLOR_SPACE_ATTRIBUTE
 
static const string INHERIT_ATTRIBUTE
 
static const string NAMESPACE_ATTRIBUTE
 
static const string DOC_ATTRIBUTE
 

Additional Inherited Members

- Protected Types inherited from InterfaceElement
using NodeDefPtr = shared_ptr< NodeDef >
 
using ConstNodeDefPtr = shared_ptr< const NodeDef >
 
- Protected Types inherited from TypedElement
using TypeDefPtr = shared_ptr< class TypeDef >
 
- Protected Types inherited from Element
using DocumentPtr = shared_ptr< Document >
 
using ConstDocumentPtr = shared_ptr< const Document >
 
- Protected Member Functions inherited from InterfaceElement
 InterfaceElement (ElementPtr parent, const string &category, const string &name)
 
void registerChildElement (ElementPtr child) override
 
void unregisterChildElement (ElementPtr child) override
 
- Protected Member Functions inherited from TypedElement
 TypedElement (ElementPtr parent, const string &category, const string &name)
 
- Protected Member Functions inherited from Element
 Element (ElementPtr parent, const string &category, const string &name)
 
template<class T >
shared_ptr< TresolveNameReference (const string &name, ConstElementPtr parent=nullptr) const
 
void validateRequire (bool expression, bool &res, string *message, const string &errorDesc) const
 
ElementPtr getSelfNonConst () const
 
- Protected Attributes inherited from Element
string _category
 
string _name
 
string _sourceUri
 
ElementMap _childMap
 
vector< ElementPtr_childOrder
 
StringMap _attributeMap
 
StringVec _attributeOrder
 
weak_ptr< Element_parent
 
weak_ptr< Element_root
 

Detailed Description

A node element within a NodeGraph or Document.

A Node represents an instance of a NodeDef within a graph, and its Input elements apply specific values and connections to that instance.

Definition at line 52 of file Node.h.

Constructor & Destructor Documentation

Node::Node ( ElementPtr  parent,
const string name 
)
inline

Definition at line 55 of file Node.h.

virtual Node::~Node ( )
inlinevirtual

Definition at line 59 of file Node.h.

Member Function Documentation

InputPtr Node::addInputFromNodeDef ( const string inputName)

Add an input based on the corresponding input for the associated node definition. If the input already exists on the node it will just be returned.

void Node::addInputsFromNodeDef ( )

Add inputs based on the corresponding associated node definition.

NodePtr Node::getConnectedNode ( const string inputName) const

Return the Node connected to the given input. If the given input is not present, then an empty NodePtr is returned.

string Node::getConnectedNodeName ( const string inputName) const

Return the name of the Node connected to the given input. If the given input is not present, then an empty string is returned.

OutputPtr Node::getConnectedOutput ( const string inputName) const

Return the output connected to the given input. If the given input is not present, then an empty OutputPtr is returned.

ConstInterfaceElementPtr Node::getDeclaration ( const string target = EMPTY_STRING) const
inlineoverridevirtual

Return the first declaration of this interface, optionally filtered by the given target name.

Reimplemented from InterfaceElement.

Definition at line 154 of file Node.h.

vector<PortElementPtr> Node::getDownstreamPorts ( ) const

Return a vector of all downstream ports that connect to this node, ordered by the names of the port elements.

InterfaceElementPtr Node::getImplementation ( const string target = EMPTY_STRING) const
inline

Return the first implementation for this node, optionally filtered by the given target and language names.

Parameters
targetAn optional target name, which will be used to filter the implementations that are considered.
Returns
An implementation for this node, or an empty shared pointer if none was found. Note that a node implementation may be either an Implementation element or a NodeGraph element.

Definition at line 117 of file Node.h.

NodeDefPtr Node::getNodeDef ( const string target = EMPTY_STRING,
bool  allowRoughMatch = false 
) const

Return the first NodeDef that declares this node, optionally filtered by the given target name.

Parameters
targetAn optional target name, which will be used to filter the nodedefs that are considered.
allowRoughMatchIf specified, then a rough match will be allowed when an exact match is not found. An exact match requires that each node input corresponds to a nodedef input of the same name and type.
Returns
A NodeDef for this node, or an empty shared pointer if none was found.
OutputPtr Node::getNodeDefOutput ( ElementPtr  connectingElement)

Given a connecting element (Input or Output) return the NodeDef output corresponding to the output the element is connected to. This is only valid if the NodeDef has explicit outputs defined, e.g. multiple outputs or an explicitly named output. If this is not the case, nullptr is returned, which implies the node is a standard node with a single implicit output.

Edge Node::getUpstreamEdge ( size_t  index = 0) const
overridevirtual

Return the Edge with the given index that lies directly upstream from this element in the dataflow graph.

Reimplemented from Element.

size_t Node::getUpstreamEdgeCount ( ) const
inlineoverridevirtual

Return the number of queriable upstream edges for this element.

Reimplemented from Element.

Definition at line 132 of file Node.h.

void Node::setConnectedNode ( const string inputName,
ConstNodePtr  node 
)

Set the node to which the given input is connected, creating a child input if needed. If the node argument is null, then any existing node connection on the input will be cleared.

void Node::setConnectedNodeName ( const string inputName,
const string nodeName 
)

Set the name of the Node connected to the given input, creating a child element for the input if needed.

void Node::setConnectedOutput ( const string inputName,
OutputPtr  output 
)

Set the output to which the given input is connected, creating a child input if needed. If the node argument is null, then any existing output connection on the input will be cleared.

bool Node::validate ( string message = nullptr) const
overridevirtual

Validate that the given element tree, including all descendants, is consistent with the MaterialX specification.

Reimplemented from Element.

Member Data Documentation

const string Node::CATEGORY
static

Definition at line 177 of file Node.h.


The documentation for this class was generated from the following file: