This document is for a version of USD that is under development. See this page for the current release.
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
NdrNode Class Reference

Represents an abstract node. More...

#include <node.h>

+ Inheritance diagram for NdrNode:

Public Member Functions

NDR_API NdrNode (const NdrIdentifier &identifier, const NdrVersion &version, const std::string &name, const TfToken &family, const TfToken &context, const TfToken &sourceType, const std::string &definitionURI, const std::string &implementationURI, NdrPropertyUniquePtrVec &&properties, const NdrTokenMap &metadata=NdrTokenMap(), const std::string &sourceCode=std::string())
 Constructor.
 
virtual NDR_API ~NdrNode ()
 Destructor.
 
The Basics
const NdrIdentifierGetIdentifier () const
 Return the identifier of the node.
 
NdrVersion GetVersion () const
 Return the version of the node.
 
const std::string & GetName () const
 Gets the name of the node.
 
const TfTokenGetFamily () const
 Gets the name of the family that the node belongs to.
 
const TfTokenGetContext () const
 Gets the context of the node.
 
const TfTokenGetSourceType () const
 Gets the type of source that this node originated from.
 
const std::string & GetResolvedDefinitionURI () const
 Gets the URI to the resource that provided this node's definition.
 
const std::string & GetResolvedImplementationURI () const
 Gets the URI to the resource that provides this node's implementation.
 
const std::string & GetSourceCode () const
 Returns the source code for this node.
 
virtual NDR_API bool IsValid () const
 Whether or not this node is valid.
 
virtual NDR_API std::string GetInfoString () const
 Gets a string with basic information about this node.
 
Inputs and Outputs

An input or output is also generically referred to as a "property".

NDR_API const NdrTokenVec & GetInputNames () const
 Get an ordered list of all the input names on this node.
 
NDR_API const NdrTokenVec & GetOutputNames () const
 Get an ordered list of all the output names on this node.
 
NDR_API NdrPropertyConstPtr GetInput (const TfToken &inputName) const
 Get an input property by name.
 
NDR_API NdrPropertyConstPtr GetOutput (const TfToken &outputName) const
 Get an output property by name.
 
Metadata

The metadata returned here is a direct result of what the parser plugin is able to determine about the node.

See the documentation for a specific parser plugin to get help on what the parser is looking for to populate these values.

NDR_API const NdrTokenMap & GetMetadata () const
 All metadata that came from the parse process.
 

Protected Member Functions

NdrNodeoperator= (const NdrNode &)=delete
 

Protected Attributes

bool _isValid
 
NdrIdentifier _identifier
 
NdrVersion _version
 
std::string _name
 
TfToken _family
 
TfToken _context
 
TfToken _sourceType
 
std::string _definitionURI
 
std::string _implementationURI
 
NdrPropertyUniquePtrVec _properties
 
NdrTokenMap _metadata
 
std::string _sourceCode
 
NdrPropertyPtrMap _inputs
 
NdrTokenVec _inputNames
 
NdrPropertyPtrMap _outputs
 
NdrTokenVec _outputNames
 

Detailed Description

Represents an abstract node.

Describes information like the name of the node, what its inputs and outputs are, and any associated metadata.

In almost all cases, this class will not be used directly. More specialized nodes can be created that derive from NdrNode; those specialized nodes can add their own domain-specific data and methods.

Definition at line 31 of file node.h.

Constructor & Destructor Documentation

◆ NdrNode()

NDR_API NdrNode ( const NdrIdentifier identifier,
const NdrVersion &  version,
const std::string &  name,
const TfToken family,
const TfToken context,
const TfToken sourceType,
const std::string &  definitionURI,
const std::string &  implementationURI,
NdrPropertyUniquePtrVec &&  properties,
const NdrTokenMap &  metadata = NdrTokenMap(),
const std::string &  sourceCode = std::string() 
)

Constructor.

◆ ~NdrNode()

virtual NDR_API ~NdrNode ( )
virtual

Destructor.

Member Function Documentation

◆ GetContext()

const TfToken & GetContext ( ) const
inline

Gets the context of the node.

The context is the context that the node declares itself as having (or, if a particular node does not declare a context, it will be assigned a default context by the parser).

As a concrete example from the Sdr library, a shader with a specific source type may perform different duties vs. another shader with the same source type. For example, one shader with a source type of SdrArgsParser::SourceType may declare itself as having a context of 'pattern', while another shader of the same source type may say it is used for lighting, and thus has a context of 'light'.

Definition at line 80 of file node.h.

◆ GetFamily()

const TfToken & GetFamily ( ) const
inline

Gets the name of the family that the node belongs to.

An empty token will be returned if the node does not belong to a family.

Definition at line 66 of file node.h.

◆ GetIdentifier()

const NdrIdentifier & GetIdentifier ( ) const
inline

Return the identifier of the node.

Definition at line 56 of file node.h.

◆ GetInfoString()

virtual NDR_API std::string GetInfoString ( ) const
virtual

Gets a string with basic information about this node.

Helpful for things like adding this node to a log.

◆ GetInput()

NDR_API NdrPropertyConstPtr GetInput ( const TfToken inputName) const

Get an input property by name.

nullptr is returned if an input with the given name does not exist.

◆ GetInputNames()

NDR_API const NdrTokenVec & GetInputNames ( ) const

Get an ordered list of all the input names on this node.

◆ GetMetadata()

NDR_API const NdrTokenMap & GetMetadata ( ) const

All metadata that came from the parse process.

Specialized nodes may isolate values in the metadata (with possible manipulations and/or additional parsing) and expose those values in their API.

◆ GetName()

const std::string & GetName ( ) const
inline

Gets the name of the node.

Definition at line 62 of file node.h.

◆ GetOutput()

NDR_API NdrPropertyConstPtr GetOutput ( const TfToken outputName) const

Get an output property by name.

nullptr is returned if an output with the given name does not exist.

◆ GetOutputNames()

NDR_API const NdrTokenVec & GetOutputNames ( ) const

Get an ordered list of all the output names on this node.

◆ GetResolvedDefinitionURI()

const std::string & GetResolvedDefinitionURI ( ) const
inline

Gets the URI to the resource that provided this node's definition.

Could be a path to a file, or some other resource identifier. This URI should be fully resolved.

See also
NdrNode::GetResolvedImplementationURI()

Definition at line 101 of file node.h.

◆ GetResolvedImplementationURI()

const std::string & GetResolvedImplementationURI ( ) const
inline

Gets the URI to the resource that provides this node's implementation.

Could be a path to a file, or some other resource identifier. This URI should be fully resolved.

See also
NdrNode::GetResolvedDefinitionURI()

Definition at line 108 of file node.h.

◆ GetSourceCode()

const std::string & GetSourceCode ( ) const
inline

Returns the source code for this node.

This will be empty for most nodes. It will be non-empty only for the nodes that are constructed using NdrRegistry::GetNodeFromSourceCode(), in which case, the source code has not been parsed (or even compiled) yet.

An unparsed node with non-empty source-code but no properties is considered to be invalid. Once the node is parsed and the relevant properties and metadata are extracted from the source code, the node becomes valid.

See also
NdrNode::IsValid

Definition at line 121 of file node.h.

◆ GetSourceType()

const TfToken & GetSourceType ( ) const
inline

Gets the type of source that this node originated from.

Note that this is distinct from GetContext(), which is the type that the node declares itself as having.

As a concrete example from the Sdr library, several shader parsers exist and operate on different types of shaders. In this scenario, each distinct type of shader (OSL, Args, etc) is considered a different source, even though they are all shaders. In addition, the shaders under each source type may declare themselves as having a specific context (shaders can serve different roles). See GetContext() for more information on this.

Definition at line 94 of file node.h.

◆ GetVersion()

NdrVersion GetVersion ( ) const
inline

Return the version of the node.

Definition at line 59 of file node.h.

◆ IsValid()

virtual NDR_API bool IsValid ( ) const
inlinevirtual

Whether or not this node is valid.

A node that is valid indicates that the parser plugin was able to successfully parse the contents of this node.

Note that if a node is not valid, some data like its name, URI, source code etc. could still be available (data that was obtained during the discovery process). However, other data that must be gathered from the parsing process will NOT be available (eg, inputs and outputs).

Definition at line 132 of file node.h.

Member Data Documentation

◆ _context

TfToken _context
protected

Definition at line 190 of file node.h.

◆ _definitionURI

std::string _definitionURI
protected

Definition at line 192 of file node.h.

◆ _family

TfToken _family
protected

Definition at line 189 of file node.h.

◆ _identifier

NdrIdentifier _identifier
protected

Definition at line 186 of file node.h.

◆ _implementationURI

std::string _implementationURI
protected

Definition at line 193 of file node.h.

◆ _inputNames

NdrTokenVec _inputNames
protected

Definition at line 199 of file node.h.

◆ _inputs

NdrPropertyPtrMap _inputs
protected

Definition at line 198 of file node.h.

◆ _isValid

bool _isValid
protected

Definition at line 185 of file node.h.

◆ _metadata

NdrTokenMap _metadata
protected

Definition at line 195 of file node.h.

◆ _name

std::string _name
protected

Definition at line 188 of file node.h.

◆ _outputNames

NdrTokenVec _outputNames
protected

Definition at line 201 of file node.h.

◆ _outputs

NdrPropertyPtrMap _outputs
protected

Definition at line 200 of file node.h.

◆ _properties

NdrPropertyUniquePtrVec _properties
protected

Definition at line 194 of file node.h.

◆ _sourceCode

std::string _sourceCode
protected

Definition at line 196 of file node.h.

◆ _sourceType

TfToken _sourceType
protected

Definition at line 191 of file node.h.

◆ _version

NdrVersion _version
protected

Definition at line 187 of file node.h.


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