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
NdrRegistry Class Reference

The registry provides access to node information. More...

#include <registry.h>

+ Inheritance diagram for NdrRegistry:

Public Types

using DiscoveryPluginRefPtrVec = NdrDiscoveryPluginRefPtrVector
 

Public Member Functions

NDR_API void SetExtraDiscoveryPlugins (DiscoveryPluginRefPtrVec plugins)
 Allows the client to set any additional discovery plugins that would otherwise NOT be found through the plugin system.
 
NDR_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.
 
NDR_API void AddDiscoveryResult (NdrNodeDiscoveryResult &&discoveryResult)
 Allows the client to explicitly set additional discovery results that would otherwise NOT be found through the plugin system.
 
NDR_API void AddDiscoveryResult (const NdrNodeDiscoveryResult &discoveryResult)
 Copy version of the method above.
 
NDR_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.
 
NDR_API NdrNodeConstPtr GetNodeFromAsset (const SdfAssetPath &asset, const NdrTokenMap &metadata, const TfToken &subIdentifier=TfToken(), const TfToken &sourceType=TfToken())
 Parses the given asset, constructs a NdrNode from it and adds it to the registry.
 
NDR_API NdrNodeConstPtr GetNodeFromSourceCode (const std::string &sourceCode, const TfToken &sourceType, const NdrTokenMap &metadata)
 Parses the given sourceCode string, constructs a NdrNode from it and adds it to the registry.
 
NDR_API NdrStringVec GetSearchURIs () const
 Get the locations where the registry is searching for nodes.
 
NDR_API NdrIdentifierVec GetNodeIdentifiers (const TfToken &family=TfToken(), NdrVersionFilter filter=NdrVersionFilterDefaultOnly) const
 Get the identifiers of all the nodes that the registry is aware of.
 
NDR_API NdrStringVec GetNodeNames (const TfToken &family=TfToken()) const
 Get the names of all the nodes that the registry is aware of.
 
NDR_API NdrNodeConstPtr GetNodeByIdentifier (const NdrIdentifier &identifier, const NdrTokenVec &sourceTypePriority=NdrTokenVec())
 Get the node with the specified identifier, and an optional sourceTypePriority list specifying the set of node SOURCE types (see NdrNode::GetSourceType()) that should be searched.
 
NDR_API NdrNodeConstPtr GetNodeByIdentifierAndType (const NdrIdentifier &identifier, const TfToken &sourceType)
 Get the node with the specified identifier and sourceType.
 
NDR_API NdrNodeConstPtr GetNodeByName (const std::string &name, const NdrTokenVec &sourceTypePriority=NdrTokenVec(), NdrVersionFilter filter=NdrVersionFilterDefaultOnly)
 Get the node with the specified name.
 
NDR_API NdrNodeConstPtr GetNodeByNameAndType (const std::string &name, const TfToken &sourceType, NdrVersionFilter filter=NdrVersionFilterDefaultOnly)
 A convenience wrapper around GetNodeByName().
 
NDR_API NdrNodeConstPtrVec GetNodesByIdentifier (const NdrIdentifier &identifier)
 Get all nodes matching the specified identifier (multiple nodes of the same identifier, but different source types, may exist).
 
NDR_API NdrNodeConstPtrVec GetNodesByName (const std::string &name, NdrVersionFilter filter=NdrVersionFilterDefaultOnly)
 Get all nodes matching the specified name.
 
NDR_API NdrNodeConstPtrVec GetNodesByFamily (const TfToken &family=TfToken(), NdrVersionFilter filter=NdrVersionFilterDefaultOnly)
 Get all nodes from the registry, optionally restricted to the nodes that fall under a specified family and/or the default version.
 
NDR_API NdrTokenVec GetAllNodeSourceTypes () const
 Get a sorted list of all node source types that may be present on the nodes in the registry.
 
- Public Member Functions inherited from TfWeakBase
 TfWeakBase (const TfWeakBase &)
 
const TfWeakBase__GetTfWeakBase__ () const
 
const TfWeakBaseoperator= (const TfWeakBase &)
 
void EnableNotification2 () const
 
TF_API void const * GetUniqueIdentifier () const
 

Protected Member Functions

 NdrRegistry (const NdrRegistry &)=delete
 
NdrRegistryoperator= (const NdrRegistry &)=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 _DiscoveryContext
 

Detailed Description

The registry provides access to 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 NdrNodeDiscoveryResult 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 NdrNodeDiscoveryResult 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 47 of file registry.h.

Member Typedef Documentation

◆ DiscoveryPluginRefPtrVec

using DiscoveryPluginRefPtrVec = NdrDiscoveryPluginRefPtrVector

Definition at line 50 of file registry.h.

Member Function Documentation

◆ AddDiscoveryResult() [1/2]

NDR_API void AddDiscoveryResult ( const NdrNodeDiscoveryResult 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.

◆ AddDiscoveryResult() [2/2]

NDR_API void AddDiscoveryResult ( NdrNodeDiscoveryResult &&  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 GetNode*() method is called.

◆ GetAllNodeSourceTypes()

NDR_API NdrTokenVec GetAllNodeSourceTypes ( ) const

Get a sorted list of all 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 NdrParserPlugin and NdrNode::GetSourceType() for more information.

◆ GetNodeByIdentifier()

NDR_API NdrNodeConstPtr GetNodeByIdentifier ( const NdrIdentifier identifier,
const NdrTokenVec &  sourceTypePriority = NdrTokenVec() 
)

Get the node with the specified identifier, and an optional sourceTypePriority list specifying the set of node SOURCE types (see NdrNode::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 NdrRegistry::GetNodeByIdentifierAndType 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.

◆ GetNodeByIdentifierAndType()

NDR_API NdrNodeConstPtr GetNodeByIdentifierAndType ( const NdrIdentifier identifier,
const TfToken sourceType 
)

Get the node with the specified identifier and sourceType.

If there is no matching node for the sourceType, nullptr is returned.

◆ GetNodeByName()

NDR_API NdrNodeConstPtr GetNodeByName ( const std::string &  name,
const NdrTokenVec &  sourceTypePriority = NdrTokenVec(),
NdrVersionFilter  filter = NdrVersionFilterDefaultOnly 
)

Get the node with the specified name.

An optional priority list specifies the set of node SOURCE types (

See also
NdrNode::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
GetNodeByIdentifier().

◆ GetNodeByNameAndType()

NDR_API NdrNodeConstPtr GetNodeByNameAndType ( const std::string &  name,
const TfToken sourceType,
NdrVersionFilter  filter = NdrVersionFilterDefaultOnly 
)

A convenience wrapper around GetNodeByName().

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.

◆ GetNodeFromAsset()

NDR_API NdrNodeConstPtr GetNodeFromAsset ( const SdfAssetPath asset,
const NdrTokenMap &  metadata,
const TfToken subIdentifier = TfToken(),
const TfToken sourceType = TfToken() 
)

Parses the given asset, constructs a NdrNode 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.

◆ GetNodeFromSourceCode()

NDR_API NdrNodeConstPtr GetNodeFromSourceCode ( const std::string &  sourceCode,
const TfToken sourceType,
const NdrTokenMap &  metadata 
)

Parses the given sourceCode string, constructs a NdrNode 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.

◆ GetNodeIdentifiers()

NDR_API NdrIdentifierVec GetNodeIdentifiers ( const TfToken family = TfToken(),
NdrVersionFilter  filter = NdrVersionFilterDefaultOnly 
) const

Get the identifiers of all the 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.

◆ GetNodeNames()

NDR_API NdrStringVec GetNodeNames ( const TfToken family = TfToken()) const

Get the names of all the 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.

◆ GetNodesByFamily()

NDR_API NdrNodeConstPtrVec GetNodesByFamily ( const TfToken family = TfToken(),
NdrVersionFilter  filter = NdrVersionFilterDefaultOnly 
)

Get all nodes from the registry, 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.

◆ GetNodesByIdentifier()

NDR_API NdrNodeConstPtrVec GetNodesByIdentifier ( const NdrIdentifier identifier)

Get all nodes matching the specified identifier (multiple nodes of the same identifier, but different source types, may exist).

If no nodes match the identifier, an empty vector is returned.

◆ GetNodesByName()

NDR_API NdrNodeConstPtrVec GetNodesByName ( const std::string &  name,
NdrVersionFilter  filter = NdrVersionFilterDefaultOnly 
)

Get all nodes matching the specified 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.

◆ GetSearchURIs()

NDR_API NdrStringVec 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.

◆ SetExtraDiscoveryPlugins() [1/2]

NDR_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.

◆ SetExtraDiscoveryPlugins() [2/2]

NDR_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.

◆ SetExtraParserPlugins()

NDR_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.

Friends And Related Function Documentation

◆ _DiscoveryContext

friend class _DiscoveryContext
friend

Definition at line 285 of file registry.h.


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