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

#include <registry.h>

+ Inheritance diagram for SdrRegistry:

Public Types

using DiscoveryPluginRefPtrVec = SdrDiscoveryPluginRefPtrVector
 
- Public Types inherited from NdrRegistry
using DiscoveryPluginRefPtrVec = NdrDiscoveryPluginRefPtrVector
 

Public Member Functions

SDR_API void AddDiscoveryResult (SdrShaderNodeDiscoveryResult &&discoveryResult)
 
SDR_API void AddDiscoveryResult (const SdrShaderNodeDiscoveryResult &discoveryResult)
 
SDR_API SdrIdentifierVec GetShaderNodeIdentifiers (const TfToken &family=TfToken(), SdrVersionFilter filter=SdrVersionFilterDefaultOnly) const
 
SDR_API SdrStringVec GetShaderNodeNames (const TfToken &family=TfToken()) const
 
SDR_API SdrShaderNodeConstPtr GetShaderNodeByIdentifier (const SdrIdentifier &identifier, const SdrTokenVec &typePriority=SdrTokenVec())
 
SDR_API SdrShaderNodeConstPtr GetShaderNodeByIdentifierAndType (const SdrIdentifier &identifier, const TfToken &nodeType)
 
SDR_API SdrShaderNodeConstPtr GetShaderNodeByName (const std::string &name, const NdrTokenVec &typePriority, NdrVersionFilter filter)
 
SDR_API SdrShaderNodeConstPtr GetShaderNodeByName (const std::string &name, const SdrTokenVec &typePriority=SdrTokenVec(), SdrVersionFilter filter=SdrVersionFilterDefaultOnly)
 
SDR_API SdrShaderNodeConstPtr GetShaderNodeByNameAndType (const std::string &name, const TfToken &nodeType, NdrVersionFilter filter)
 
SDR_API SdrShaderNodeConstPtr GetShaderNodeByNameAndType (const std::string &name, const TfToken &nodeType, SdrVersionFilter filter=SdrVersionFilterDefaultOnly)
 
SDR_API SdrShaderNodeConstPtr GetShaderNodeFromAsset (const SdfAssetPath &shaderAsset, const SdrTokenMap &metadata=SdrTokenMap(), const TfToken &subIdentifier=TfToken(), const TfToken &sourceType=TfToken())
 
SDR_API SdrShaderNodeConstPtr GetShaderNodeFromSourceCode (const std::string &sourceCode, const TfToken &sourceType, const SdrTokenMap &metadata=SdrTokenMap())
 
SDR_API SdrShaderNodePtrVec GetShaderNodesByIdentifier (const SdrIdentifier &identifier)
 
SDR_API SdrShaderNodePtrVec GetShaderNodesByName (const std::string &name, NdrVersionFilter filter)
 
SDR_API SdrShaderNodePtrVec GetShaderNodesByName (const std::string &name, SdrVersionFilter filter=SdrVersionFilterDefaultOnly)
 
SDR_API SdrShaderNodePtrVec GetShaderNodesByFamily (const TfToken &family, NdrVersionFilter filter)
 
SDR_API SdrShaderNodePtrVec GetShaderNodesByFamily (const TfToken &family=TfToken(), SdrVersionFilter filter=SdrVersionFilterDefaultOnly)
 
SDR_API SdrTokenVec GetAllShaderNodeSourceTypes () const
 
- Public Member Functions inherited from NdrRegistry
NDR_API void SetExtraDiscoveryPlugins (DiscoveryPluginRefPtrVec plugins)
 
NDR_API void SetExtraDiscoveryPlugins (const std::vector< TfType > &pluginTypes)
 
NDR_API void AddDiscoveryResult (NdrNodeDiscoveryResult &&discoveryResult)
 
NDR_API void AddDiscoveryResult (const NdrNodeDiscoveryResult &discoveryResult)
 
NDR_API void SetExtraParserPlugins (const std::vector< TfType > &pluginTypes)
 
NDR_API NdrNodeConstPtr GetNodeFromAsset (const SdfAssetPath &asset, const NdrTokenMap &metadata, const TfToken &subIdentifier=TfToken(), const TfToken &sourceType=TfToken())
 
NDR_API NdrNodeConstPtr GetNodeFromSourceCode (const std::string &sourceCode, const TfToken &sourceType, const NdrTokenMap &metadata)
 
NDR_API NdrStringVec GetSearchURIs () const
 
NDR_API NdrIdentifierVec GetNodeIdentifiers (const TfToken &family=TfToken(), NdrVersionFilter filter=NdrVersionFilterDefaultOnly) const
 
NDR_API NdrStringVec GetNodeNames (const TfToken &family=TfToken()) const
 
NDR_API NdrNodeConstPtr GetNodeByIdentifier (const NdrIdentifier &identifier, const NdrTokenVec &sourceTypePriority=NdrTokenVec())
 
NDR_API NdrNodeConstPtr GetNodeByIdentifierAndType (const NdrIdentifier &identifier, const TfToken &sourceType)
 
NDR_API NdrNodeConstPtr GetNodeByName (const std::string &name, const NdrTokenVec &sourceTypePriority=NdrTokenVec(), NdrVersionFilter filter=NdrVersionFilterDefaultOnly)
 
NDR_API NdrNodeConstPtr GetNodeByNameAndType (const std::string &name, const TfToken &sourceType, NdrVersionFilter filter=NdrVersionFilterDefaultOnly)
 
NDR_API NdrNodeConstPtrVec GetNodesByIdentifier (const NdrIdentifier &identifier)
 
NDR_API NdrNodeConstPtrVec GetNodesByName (const std::string &name, NdrVersionFilter filter=NdrVersionFilterDefaultOnly)
 
NDR_API NdrNodeConstPtrVec GetNodesByFamily (const TfToken &family=TfToken(), NdrVersionFilter filter=NdrVersionFilterDefaultOnly)
 
NDR_API NdrTokenVec GetAllNodeSourceTypes () const
 
- Public Member Functions inherited from TfWeakBase
 TfWeakBase ()
 
 TfWeakBase (const TfWeakBase &)
 
const TfWeakBase__GetTfWeakBase__ () const
 
const TfWeakBaseoperator= (const TfWeakBase &)
 
void EnableNotification2 () const
 
TF_API void const * GetUniqueIdentifier () const
 

Static Public Member Functions

static SDR_API SdrRegistryGetInstance ()
 Get the single SdrRegistry instance. More...
 

Protected Member Functions

SDR_API SdrRegistry ()
 
SDR_API ~SdrRegistry ()
 
- Protected Member Functions inherited from NdrRegistry
 NdrRegistry (const NdrRegistry &)=delete
 
NdrRegistryoperator= (const NdrRegistry &)=delete
 
NDR_API NdrRegistry ()
 
NDR_API ~NdrRegistry ()
 
- Protected Member Functions inherited from TfWeakBase
 ~TfWeakBase ()
 
TfRefPtr< Tf_Remnant_Register () const
 
template<class T >
TfRefPtr< Tf_Remnant_Register (T *tempRmnt) const
 
bool _HasRemnant () const
 

Friends

class TfSingleton< SdrRegistry >
 

Detailed Description

The registry provides access to shader node information. "Discovery Plugins" are responsible for finding the nodes that should be included in the registry.

Discovery plugins are found through the plugin system. If additional discovery plugins need to be specified, a client can pass them to SetExtraDiscoveryPlugins().

When the registry is first told about the discovery plugins, the plugins will be asked to discover nodes. These plugins will generate SdrShaderNodeDiscoveryResult instances, which only contain basic metadata. Once the client asks for information that would require the node's contents to be parsed (eg, what its inputs and outputs are), the registry will begin the parsing process on an as-needed basis. See SdrShaderNodeDiscoveryResult for the information that can be retrieved without triggering a parse.

Some methods in this library may allow for a "family" to be provided. A family is simply a generic grouping which is optional.

Definition at line 55 of file registry.h.

Member Typedef Documentation

using SdrRegistry::DiscoveryPluginRefPtrVec = SdrDiscoveryPluginRefPtrVector

Definition at line 58 of file registry.h.

Constructor & Destructor Documentation

SDR_API SdrRegistry::SdrRegistry ( )
protected
SDR_API SdrRegistry::~SdrRegistry ( )
protected

Member Function Documentation

SDR_API void SdrRegistry::AddDiscoveryResult ( SdrShaderNodeDiscoveryResult &&  discoveryResult)

Allows the client to explicitly set additional discovery results that would otherwise NOT be found through the plugin system. For example to support lazily-loaded plugins which cannot be easily discovered in advance.

This method will not immediately spawn a parse call which will be deferred until a GetShaderNode*() method is called.

SDR_API void SdrRegistry::AddDiscoveryResult ( const SdrShaderNodeDiscoveryResult discoveryResult)

Copy version of the method above. For performance reasons, one should prefer to use the rvalue reference form. This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

SDR_API SdrTokenVec SdrRegistry::GetAllShaderNodeSourceTypes ( ) const

Get a sorted list of all shader node source types that may be present on the nodes in the registry.

Source types originate from the discovery process, but there is no guarantee that the discovered source types will also have a registered parser plugin. The actual supported source types here depend on the parsers that are available. Also note that some parser plugins may not advertise a source type.

See the documentation for SdrParserPlugin and SdrShaderNode::GetSourceType() for more information.

static SDR_API SdrRegistry& SdrRegistry::GetInstance ( )
static

Get the single SdrRegistry instance.

SDR_API SdrShaderNodeConstPtr SdrRegistry::GetShaderNodeByIdentifier ( const SdrIdentifier identifier,
const SdrTokenVec typePriority = SdrTokenVec() 
)

Get the shader node with the specified identifier, and an optional sourceTypePriority list specifying the set of node SOURCE types (see SdrShaderNode::GetSourceType()) that should be searched.

If no sourceTypePriority is specified, the first encountered node with the specified identifier will be returned (first is arbitrary) if found.

If a sourceTypePriority list is specified, then this will iterate through each source type and try to find a node matching by identifier. This is equivalent to calling SdrRegistry::GetShaderNodeByIdentifierAndType for each source type until a node is found.

Nodes of the same identifier but different source type can exist in the registry. If a node 'Foo' with source types 'abc' and 'xyz' exist in the registry, and you want to make sure the 'abc' version is fetched before the 'xyz' version, the priority list would be specified as ['abc', 'xyz']. If the 'abc' version did not exist in the registry, then the 'xyz' version would be returned.

Returns nullptr if a node matching the arguments can't be found.

SDR_API SdrShaderNodeConstPtr SdrRegistry::GetShaderNodeByIdentifierAndType ( const SdrIdentifier identifier,
const TfToken nodeType 
)

Get the shader node with the specified identifier and sourceType. If there is no matching node for the sourceType, nullptr is returned.

SDR_API SdrShaderNodeConstPtr SdrRegistry::GetShaderNodeByName ( const std::string &  name,
const NdrTokenVec typePriority,
NdrVersionFilter  filter 
)

Get the shader node with the specified name.

Deprecated:
Deprecated in favor of GetShaderNodeByName(..., SdrVersionFilter filter)
SDR_API SdrShaderNodeConstPtr SdrRegistry::GetShaderNodeByName ( const std::string &  name,
const SdrTokenVec typePriority = SdrTokenVec(),
SdrVersionFilter  filter = SdrVersionFilterDefaultOnly 
)

Get the shader node with the specified name. An optional priority list specifies the set of node SOURCE types (

See Also
SdrShaderNode::GetSourceType()) that should be searched and in what order.

Optionally, a filter can be specified to consider just the default versions of nodes matching name (the default) or all versions of the nodes.

See Also
GetShaderNodeByIdentifier().
SDR_API SdrShaderNodeConstPtr SdrRegistry::GetShaderNodeByNameAndType ( const std::string &  name,
const TfToken nodeType,
NdrVersionFilter  filter 
)

A convenience wrapper around GetShaderNodeByName().

Deprecated:
Deprecated in favor of GetShaderNodeByNameAndType(..., SdrVersionFilter filter)
SDR_API SdrShaderNodeConstPtr SdrRegistry::GetShaderNodeByNameAndType ( const std::string &  name,
const TfToken nodeType,
SdrVersionFilter  filter = SdrVersionFilterDefaultOnly 
)

A convenience wrapper around GetShaderNodeByName(). Instead of providing a priority list, an exact type is specified, and nullptr is returned if a node with the exact identifier and type does not exist.

Optionally, a filter can be specified to consider just the default versions of nodes matching name (the default) or all versions of the nodes.

SDR_API SdrShaderNodeConstPtr SdrRegistry::GetShaderNodeFromAsset ( const SdfAssetPath shaderAsset,
const SdrTokenMap metadata = SdrTokenMap(),
const TfToken subIdentifier = TfToken(),
const TfToken sourceType = TfToken() 
)

Parses the given asset, constructs a SdrShaderNode from it and adds it to the registry.

Nodes created from an asset using this API can be looked up by the unique identifier and sourceType of the returned node, or by URI, which will be set to the unresolved asset path value.

metadata contains additional metadata needed for parsing and compiling the source code in the file pointed to by asset correctly. This metadata supplements the metadata available in the asset and overrides it in cases where there are key collisions.

subidentifier is optional, and it would be used to indicate a particular definition in the asset file if the asset contains multiple node definitions.

sourceType is optional, and it is only needed to indicate a particular type if the asset file is capable of representing a node definition of multiple source types.

Returns a valid node if the asset is parsed successfully using one of the registered parser plugins.

SDR_API SdrShaderNodeConstPtr SdrRegistry::GetShaderNodeFromSourceCode ( const std::string &  sourceCode,
const TfToken sourceType,
const SdrTokenMap metadata = SdrTokenMap() 
)

Parses the given sourceCode string, constructs a SdrShaderNode from it and adds it to the registry. The parser to be used is determined by the specified sourceType.

Nodes created from source code using this API can be looked up by the unique identifier and sourceType of the returned node.

metadata contains additional metadata needed for parsing and compiling the source code correctly. This metadata supplements the metadata available in sourceCode and overrides it cases where there are key collisions.

Returns a valid node if the given source code is parsed successfully using the parser plugins that is registered for the specified sourceType.

SDR_API SdrIdentifierVec SdrRegistry::GetShaderNodeIdentifiers ( const TfToken family = TfToken(),
SdrVersionFilter  filter = SdrVersionFilterDefaultOnly 
) const

Get identifiers of all the shader nodes that the registry is aware of.

This will not run the parsing plugins on the nodes that have been discovered, so this method is relatively quick. Optionally, a "family" name can be specified to only get the identifiers of nodes that belong to that family and a filter can be specified to get just the default version (the default) or all versions of the node.

SDR_API SdrStringVec SdrRegistry::GetShaderNodeNames ( const TfToken family = TfToken()) const

Get the names of all the shader nodes that the registry is aware of.

This will not run the parsing plugins on the nodes that have been discovered, so this method is relatively quick. Optionally, a "family" name can be specified to only get the names of nodes that belong to that family.

SDR_API SdrShaderNodePtrVec SdrRegistry::GetShaderNodesByFamily ( const TfToken family,
NdrVersionFilter  filter 
)

Get all shader nodes, optionally restricted to the nodes that fall under a specified family and/or the default version.

Deprecated:
Deprecated in favor of GetShaderNodesByFamily(..., SdrVersionFilter filter)
SDR_API SdrShaderNodePtrVec SdrRegistry::GetShaderNodesByFamily ( const TfToken family = TfToken(),
SdrVersionFilter  filter = SdrVersionFilterDefaultOnly 
)

Get all shader nodes, optionally restricted to the nodes that fall under a specified family and/or the default version.

Note that this will parse all nodes that the registry is aware of (unless a family is specified), so this may take some time to run the first time it is called.

SDR_API SdrShaderNodePtrVec SdrRegistry::GetShaderNodesByIdentifier ( const SdrIdentifier identifier)

Get all shader nodes matching the given identifier (multiple nodes of the same identifier, but different source types, may exist). If no nodes match the identifier, an empty vector is returned.

SDR_API SdrShaderNodePtrVec SdrRegistry::GetShaderNodesByName ( const std::string &  name,
NdrVersionFilter  filter 
)

Get all shader nodes matching the given name.

Deprecated:
Deprecated in favor of GetShaderNodesByName(..., SdrVersionFilter filter)
SDR_API SdrShaderNodePtrVec SdrRegistry::GetShaderNodesByName ( const std::string &  name,
SdrVersionFilter  filter = SdrVersionFilterDefaultOnly 
)

Get all shader nodes matching the given name. Only nodes matching the specified name will be parsed. Optionally, a filter can be specified to get just the default version (the default) or all versions of the node. If no nodes match an empty vector is returned.

Friends And Related Function Documentation

friend class TfSingleton< SdrRegistry >
friend

Definition at line 300 of file registry.h.


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