8#ifndef PXR_USD_NDR_REGISTRY_H
9#define PXR_USD_NDR_REGISTRY_H
14#include "pxr/usd/ndr/api.h"
17#include "pxr/usd/ndr/discoveryPlugin.h"
19#include "pxr/usd/ndr/nodeDiscoveryResult.h"
25PXR_NAMESPACE_OPEN_SCOPE
50 using DiscoveryPluginRefPtrVec = NdrDiscoveryPluginRefPtrVector;
122 const NdrTokenMap &metadata,
144 const NdrTokenMap &metadata);
164 NdrVersionFilterDefaultOnly)
const;
197 const NdrTokenVec& sourceTypePriority = NdrTokenVec());
216 const NdrTokenVec& sourceTypePriority = NdrTokenVec(),
231 NdrVersionFilterDefaultOnly);
246 NdrVersionFilterDefaultOnly);
257 NdrVersionFilterDefaultOnly);
284 class _DiscoveryContext;
285 friend class _DiscoveryContext;
287 using _TypeToParserPluginMap =
288 std::unordered_map<TfToken, NdrParserPlugin*, TfToken::HashFunctor>;
292 using _NodeMapKey = std::pair<NdrIdentifier, TfToken>;
293 using _NodeMap = std::unordered_map<_NodeMapKey, NdrNodeUniquePtr, TfHash>;
297 using _DiscoveryResultsByIdentifier = std::unordered_multimap<
299 using _DiscoveryResultsByIdentifierRange =
300 std::pair<_DiscoveryResultsByIdentifier::const_iterator,
301 _DiscoveryResultsByIdentifier::const_iterator>;
306 using _DiscoveryResultPtrsByName = std::unordered_multimap<
308 using _DiscoveryResultPtrsByNameRange =
309 std::pair<_DiscoveryResultPtrsByName::const_iterator,
310 _DiscoveryResultPtrsByName::const_iterator>;
314 mutable std::mutex _discoveryResultMutex;
318 mutable std::mutex _nodeMapMutex;
322 void _RunDiscoveryPlugins(
const DiscoveryPluginRefPtrVec& discoveryPlugins);
329 void _FindAndInstantiateDiscoveryPlugins();
332 void _FindAndInstantiateParserPlugins();
336 void _InstantiateParserPlugins(
const std::set<TfType>& parserPluginTypes);
342 NdrNodeConstPtr _ParseNodeFromAssetOrSourceCode(
347 NdrNodeConstPtr _GetNodeInIdentifierRangeWithSourceType(
348 _DiscoveryResultsByIdentifierRange range,
const TfToken& sourceType);
353 NdrNodeConstPtr _GetNodeInNameRangeWithSourceType(
354 _DiscoveryResultPtrsByNameRange range,
const TfToken& sourceType,
358 NdrNodeConstPtr _FindNodeInCache(
const _NodeMapKey &key)
const;
364 NdrNodeConstPtr _InsertNodeInCache(
365 _NodeMapKey &&key, NdrNodeUniquePtr &&node);
376 _GetParserForDiscoveryType(
const TfToken& discoveryType)
const;
380 DiscoveryPluginRefPtrVec _discoveryPlugins;
384 _TypeToParserPluginMap _parserPluginMap;
387 std::vector<std::unique_ptr<NdrParserPlugin>> _parserPlugins;
392 _DiscoveryResultsByIdentifier _discoveryResultsByIdentifier;
393 _DiscoveryResultPtrsByName _discoveryResultPtrsByName;
405PXR_NAMESPACE_CLOSE_SCOPE
Interface for parser plugins.
The registry provides access to node information.
NDR_API void AddDiscoveryResult(NdrNodeDiscoveryResult &&discoveryResult)
Allows the client to explicitly set additional discovery results that would otherwise NOT be found th...
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 t...
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 GetNodeByIdentifierAndType(const NdrIdentifier &identifier, const TfToken &sourceType)
Get the node with the specified identifier and sourceType.
NDR_API void AddDiscoveryResult(const NdrNodeDiscoveryResult &discoveryResult)
Copy version of the method above.
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 NdrNodeConstPtrVec GetNodesByIdentifier(const NdrIdentifier &identifier)
Get all nodes matching the specified identifier (multiple nodes of the same identifier,...
NDR_API NdrStringVec GetSearchURIs() const
Get the locations where the registry is searching for nodes.
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 se...
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 famil...
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 GetNodeByNameAndType(const std::string &name, const TfToken &sourceType, NdrVersionFilter filter=NdrVersionFilterDefaultOnly)
A convenience wrapper around GetNodeByName().
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 NdrStringVec GetNodeNames(const TfToken &family=TfToken()) const
Get the names of all the nodes that the registry is aware of.
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 void SetExtraParserPlugins(const std::vector< TfType > &pluginTypes)
Allows the client to set any additional parser plugins that would otherwise NOT be found through the ...
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.
Contains an asset path and an optional resolved path.
A user-extensible hashing mechanism for use with runtime hash tables.
Token for efficient comparison, assignment, and hashing of known strings.
std::set< TfToken, TfTokenFastArbitraryLessThan > Set
Predefined type for set of tokens, for when faster lookup is desired, without paying the memory or in...
Enable a concrete base class for use with TfWeakPtr.
Represents the raw data of a node, and some other bits of metadata, that were determined via a NdrDis...
Common typedefs that are used throughout the NDR library.
NdrVersionFilter
Enumeration used to select nodes by version.