25 #ifndef NDR_REGISTRY_H
26 #define NDR_REGISTRY_H
31 #include "pxr/usd/ndr/api.h"
32 #include "pxr/base/tf/singleton.h"
33 #include "pxr/base/tf/weakBase.h"
34 #include "pxr/usd/ndr/declare.h"
35 #include "pxr/usd/ndr/discoveryPlugin.h"
36 #include "pxr/usd/ndr/node.h"
37 #include "pxr/usd/ndr/nodeDiscoveryResult.h"
38 #include "pxr/usd/ndr/parserPlugin.h"
39 #include "pxr/usd/sdf/assetPath.h"
41 PXR_NAMESPACE_OPEN_SCOPE
66 using DiscoveryPluginRefPtrVec = NdrDiscoveryPluginRefPtrVector;
108 const NdrTokenMap &metadata);
128 const NdrTokenMap &metadata);
148 NdrVersionFilterDefaultOnly)
const;
177 const NdrTokenVec& typePriority = NdrTokenVec());
198 const NdrTokenVec& typePriority = NdrTokenVec(),
200 NdrVersionFilterDefaultOnly);
214 NdrVersionFilterDefaultOnly);
238 NdrVersionFilterDefaultOnly);
249 NdrVersionFilterDefaultOnly);
276 virtual ~NdrRegistry();
279 class _DiscoveryContext;
280 friend class _DiscoveryContext;
284 typedef std::pair<NdrIdentifier, TfToken> NodeMapKey;
285 struct NodeMapKeyHashFunctor {
286 size_t operator()(
const NodeMapKey& x)
const {
291 typedef std::unordered_multimap<NodeMapKey, NdrNodeUniquePtr,
292 NodeMapKeyHashFunctor> NodeMap;
296 mutable std::mutex _discoveryResultMutex;
300 mutable std::mutex _nodeMapMutex;
304 void _RunDiscoveryPlugins(
const DiscoveryPluginRefPtrVec& discoveryPlugins);
307 void _FindAndInstantiateDiscoveryPlugins();
310 void _FindAndInstantiateParserPlugins();
318 NdrNodeConstPtrVec _ParseNodesMatchingPredicate(
320 bool onlyParseFirstMatch);
329 NdrNodeConstPtrVec _GetNodeMapAsNodePtrVec(
const TfToken& family,
335 _GetParserForDiscoveryType(
const TfToken& discoveryType)
const;
341 static NdrNodeConstPtr
342 _GetNodeByTypePriority(
const NdrNodeConstPtrVec& nodes,
343 const NdrTokenVec& typePriority);
347 DiscoveryPluginRefPtrVec _discoveryPlugins;
351 TypeToParserPluginMap _parserPluginMap;
354 std::vector<std::unique_ptr<NdrParserPlugin>> _parserPlugins;
358 NdrNodeDiscoveryResultVec _discoveryResults;
365 NdrTokenVec _availableSourceTypes;
368 PXR_NAMESPACE_CLOSE_SCOPE
370 #endif // NDR_REGISTRY_H
NDR_API NdrNodeConstPtr GetNodeByURI(const std::string &uri)
Gets the node matching the specified URI (eg, a filesystem path).
Manage a single instance of an object (see.
Interface for parser plugins.
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 famil...
NDR_API NdrStringVec GetNodeNames(const TfToken &family=TfToken()) const
Get the names of all the nodes that the registry is aware of.
Functor to use for hash maps from tokens to other things.
NDR_API NdrNodeConstPtr GetNodeByIdentifierAndType(const NdrIdentifier &identifier, const TfToken &nodeType)
A convenience wrapper around GetNodeByIdentifier().
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.
Token for efficient comparison, assignment, and hashing of known strings.
NDR_API NdrNodeConstPtr GetNodeFromAsset(const SdfAssetPath &asset, const NdrTokenMap &metadata)
Parses the given asset, constucts a NdrNode from it and adds it to the registry.
NDR_API NdrNodeConstPtr GetNodeByName(const std::string &name, const NdrTokenVec &typePriority=NdrTokenVec(), NdrVersionFilter filter=NdrVersionFilterDefaultOnly)
Get the node with the specified name.
NDR_API NdrStringVec GetSearchURIs() const
Get the locations where the registry is searching for nodes.
static NDR_API NdrRegistry & GetInstance()
Get the single NdrRegistry instance.
NdrVersionFilter
Enumeration used to select nodes by version.
The registry provides access to node information.
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).
Represents the raw data of a node, and some other bits of metadata, that were determined via a NdrDis...
NDR_API NdrTokenVec GetAllNodeSourceTypes() const
Get a sorted list of all node source types that may be present on the nodes in the registry...
NDR_API NdrNodeConstPtr GetNodeByIdentifier(const NdrIdentifier &identifier, const NdrTokenVec &typePriority=NdrTokenVec())
Get the node with the specified identifier, and an optional priority list specifying the set of node ...
Contains an asset path and an optional resolved path.
NDR_API void SetExtraDiscoveryPlugins(DiscoveryPluginRefPtrVec plugins)
Allows the client to set any additional discovery plugins that would otherwise NOT be found through t...
NDR_API NdrNodeConstPtrVec GetNodesByName(const std::string &name, NdrVersionFilter filter=NdrVersionFilterDefaultOnly)
Get all nodes matching the specified name.
NDR_API NdrNodeConstPtr GetNodeByNameAndType(const std::string &name, const TfToken &nodeType, NdrVersionFilter filter=NdrVersionFilterDefaultOnly)
A convenience wrapper around GetNodeByName().
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...
Enable a concrete base class for use with TfWeakPtr.