![]() |
|
The registry provides access to shader node information. More...
#include <registry.h>
Inheritance diagram for SdrRegistry:Public Types | |
| using | DiscoveryPluginRefPtrVec = SdrDiscoveryPluginRefPtrVector |
Public Member Functions | |
| SDR_API void | SetExtraDiscoveryPlugins (DiscoveryPluginRefPtrVec plugins) |
| Allows the client to set any additional discovery plugins that would otherwise NOT be found through the plugin system. | |
| SDR_API void | SetExtraDiscoveryPlugins (const std::vector< TfType > &pluginTypes) |
| Allows the client to set any additional discovery plugins that would otherwise NOT be found through the plugin system. | |
| SDR_API void | AddDiscoveryResult (SdrShaderNodeDiscoveryResult &&discoveryResult) |
| Allows the client to explicitly set additional discovery results that would otherwise NOT be found through the plugin system. | |
| SDR_API void | AddDiscoveryResult (const SdrShaderNodeDiscoveryResult &discoveryResult) |
| Copy version of the method above. | |
| SDR_API void | SetExtraParserPlugins (const std::vector< TfType > &pluginTypes) |
| Allows the client to set any additional parser plugins that would otherwise NOT be found through the plugin system. | |
| SDR_API SdrStringVec | GetSearchURIs () const |
| Get the locations where the registry is searching for nodes. | |
| SDR_API SdrIdentifierVec | GetShaderNodeIdentifiers (const TfToken &family=TfToken(), SdrVersionFilter filter=SdrVersionFilterDefaultOnly) const |
| Get identifiers of all the shader nodes that the registry is aware of. | |
| SDR_API SdrStringVec | GetShaderNodeNames (const TfToken &family=TfToken()) const |
| Get the names of all the shader nodes that the registry is aware of. | |
| SDR_API SdrShaderNodeConstPtr | 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. | |
| SDR_API SdrShaderNodeConstPtr | GetShaderNodeByIdentifierAndType (const SdrIdentifier &identifier, const TfToken &nodeType) |
Get the shader node with the specified identifier and sourceType. | |
| SDR_API SdrShaderNodeConstPtr | GetShaderNodeByName (const std::string &name, const SdrTokenVec &typePriority=SdrTokenVec(), SdrVersionFilter filter=SdrVersionFilterDefaultOnly) |
| Get the shader node with the specified name. | |
| SDR_API SdrShaderNodeConstPtr | GetShaderNodeByNameAndType (const std::string &name, const TfToken &nodeType, SdrVersionFilter filter=SdrVersionFilterDefaultOnly) |
A convenience wrapper around GetShaderNodeByName(). | |
| SDR_API SdrShaderNodeConstPtr | 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. | |
| SDR_API SdrShaderNodeConstPtr | 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. | |
| SDR_API SdrShaderNodePtrVec | GetShaderNodesByIdentifier (const SdrIdentifier &identifier) |
| Get all shader nodes matching the given identifier (multiple nodes of the same identifier, but different source types, may exist). | |
| SDR_API SdrShaderNodePtrVec | GetShaderNodesByName (const std::string &name, SdrVersionFilter filter=SdrVersionFilterDefaultOnly) |
| Get all shader nodes matching the given name. | |
| SDR_API SdrShaderNodePtrVec | 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. | |
| SDR_API SdrTokenVec | GetAllShaderNodeSourceTypes () const |
| Get a sorted list of all shader node source types that may be present on the nodes in the registry. | |
| SDR_API SdrShaderNodeQueryResult | RunQuery (const SdrShaderNodeQuery &query) |
| Run an SdrShaderNodeQuery. | |
Public Member Functions inherited from TfWeakBase | |
| TfWeakBase (const TfWeakBase &) | |
| const TfWeakBase & | __GetTfWeakBase__ () const |
| const TfWeakBase & | operator= (const TfWeakBase &) |
| void | EnableNotification2 () const |
| TF_API void const * | GetUniqueIdentifier () const |
Static Public Member Functions | |
| static SDR_API SdrRegistry & | GetInstance () |
Get the single SdrRegistry instance. | |
Protected Member Functions | |
| SdrRegistry (const SdrRegistry &)=delete | |
| SdrRegistry & | operator= (const SdrRegistry &)=delete |
Protected Member Functions inherited from TfWeakBase | |
| TfRefPtr< Tf_Remnant > | _Register () const |
| template<class T > | |
| TfRefPtr< Tf_Remnant > | _Register (T *tempRmnt) const |
| bool | _HasRemnant () const |
Friends | |
| class | TfSingleton< SdrRegistry > |
| class | _DiscoveryContext |
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 50 of file registry.h.
| using DiscoveryPluginRefPtrVec = SdrDiscoveryPluginRefPtrVector |
Definition at line 53 of file registry.h.
| SDR_API void 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 void 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 SdrTokenVec 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 |
Get the single SdrRegistry instance.
| SDR_API SdrStringVec GetSearchURIs | ( | ) | const |
Get the locations where the registry is searching for nodes.
Depending on which discovery plugins were used, this may include non-filesystem paths.
| SDR_API SdrShaderNodeConstPtr 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 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 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 (
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 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 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 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 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.
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 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 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 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.
| SDR_API SdrShaderNodeQueryResult RunQuery | ( | const SdrShaderNodeQuery & | query | ) |
Run an SdrShaderNodeQuery.
Note that SdrRegistry::RunQuery will cause all nodes in the registry to be parsed in order to examine data on these nodes in their final form.
| SDR_API void SetExtraDiscoveryPlugins | ( | const std::vector< TfType > & | pluginTypes | ) |
Allows the client to set any additional discovery plugins that would otherwise NOT be found through the plugin system.
Runs the discovery process for the specified plugins immediately.
Note that this method cannot be called after any nodes in the registry have been parsed (eg, through GetNode*()), otherwise an error will result.
| SDR_API void SetExtraDiscoveryPlugins | ( | DiscoveryPluginRefPtrVec | plugins | ) |
Allows the client to set any additional discovery plugins that would otherwise NOT be found through the plugin system.
Runs the discovery process for the specified plugins immediately.
Note that this method cannot be called after any nodes in the registry have been parsed (eg, through GetNode*()), otherwise an error will result.
| SDR_API void SetExtraParserPlugins | ( | const std::vector< TfType > & | pluginTypes | ) |
Allows the client to set any additional parser plugins that would otherwise NOT be found through the plugin system.
Note that this method cannot be called after any nodes in the registry have been parsed (eg, through GetNode*()), otherwise an error will result.
|
friend |
Definition at line 311 of file registry.h.
|
friend |
Definition at line 295 of file registry.h.