25 #ifndef PXR_USD_NDR_REGISTRY_H 26 #define PXR_USD_NDR_REGISTRY_H 31 #include "pxr/usd/ndr/api.h" 34 #include "pxr/usd/ndr/discoveryPlugin.h" 36 #include "pxr/usd/ndr/nodeDiscoveryResult.h" 42 PXR_NAMESPACE_OPEN_SCOPE
67 using DiscoveryPluginRefPtrVec = NdrDiscoveryPluginRefPtrVector;
139 const NdrTokenMap &metadata,
161 const NdrTokenMap &metadata);
181 NdrVersionFilterDefaultOnly)
const;
214 const NdrTokenVec& sourceTypePriority = NdrTokenVec());
233 const NdrTokenVec& sourceTypePriority = NdrTokenVec(),
248 NdrVersionFilterDefaultOnly);
263 NdrVersionFilterDefaultOnly);
274 NdrVersionFilterDefaultOnly);
301 class _DiscoveryContext;
302 friend class _DiscoveryContext;
304 using _TypeToParserPluginMap =
305 std::unordered_map<TfToken, NdrParserPlugin*, TfToken::HashFunctor>;
309 using _NodeMapKey = std::pair<NdrIdentifier, TfToken>;
310 using _NodeMap = std::unordered_map<_NodeMapKey, NdrNodeUniquePtr, TfHash>;
314 using _DiscoveryResultsByIdentifier = std::unordered_multimap<
316 using _DiscoveryResultsByIdentifierRange =
317 std::pair<_DiscoveryResultsByIdentifier::const_iterator,
318 _DiscoveryResultsByIdentifier::const_iterator>;
323 using _DiscoveryResultPtrsByName = std::unordered_multimap<
325 using _DiscoveryResultPtrsByNameRange =
326 std::pair<_DiscoveryResultPtrsByName::const_iterator,
327 _DiscoveryResultPtrsByName::const_iterator>;
331 mutable std::mutex _discoveryResultMutex;
335 mutable std::mutex _nodeMapMutex;
339 void _RunDiscoveryPlugins(
const DiscoveryPluginRefPtrVec& discoveryPlugins);
346 void _FindAndInstantiateDiscoveryPlugins();
349 void _FindAndInstantiateParserPlugins();
353 void _InstantiateParserPlugins(
const std::set<TfType>& parserPluginTypes);
359 NdrNodeConstPtr _ParseNodeFromAssetOrSourceCode(
364 NdrNodeConstPtr _GetNodeInIdentifierRangeWithSourceType(
365 _DiscoveryResultsByIdentifierRange range,
const TfToken& sourceType);
370 NdrNodeConstPtr _GetNodeInNameRangeWithSourceType(
371 _DiscoveryResultPtrsByNameRange range,
const TfToken& sourceType,
375 NdrNodeConstPtr _FindNodeInCache(
const _NodeMapKey &key)
const;
381 NdrNodeConstPtr _InsertNodeInCache(
382 _NodeMapKey &&key, NdrNodeUniquePtr &&node);
393 _GetParserForDiscoveryType(
const TfToken& discoveryType)
const;
397 DiscoveryPluginRefPtrVec _discoveryPlugins;
401 _TypeToParserPluginMap _parserPluginMap;
404 std::vector<std::unique_ptr<NdrParserPlugin>> _parserPlugins;
409 _DiscoveryResultsByIdentifier _discoveryResultsByIdentifier;
410 _DiscoveryResultPtrsByName _discoveryResultPtrsByName;
422 PXR_NAMESPACE_CLOSE_SCOPE
424 #endif // PXR_USD_NDR_REGISTRY_H NdrVersionFilter
Enumeration used to select nodes by version.
NDR_API NdrStringVec GetSearchURIs() const
Get the locations where the registry is searching for nodes.
NDR_API NdrNodeConstPtr GetNodeByName(const std::string &name, const NdrTokenVec &sourceTypePriority=NdrTokenVec(), NdrVersionFilter filter=NdrVersionFilterDefaultOnly)
Get the node with the specified name.
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 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 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 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 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 NdrNodeConstPtr GetNodeByIdentifierAndType(const NdrIdentifier &identifier, const TfToken &sourceType)
Get the node with the specified identifier and sourceType.
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 void AddDiscoveryResult(NdrNodeDiscoveryResult &&discoveryResult)
Allows the client to explicitly set additional discovery results that would otherwise NOT be found th...
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...
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,...
Represents the raw data of a node, and some other bits of metadata, that were determined via a NdrDis...
NDR_API NdrNodeConstPtr GetNodeByNameAndType(const std::string &name, const TfToken &sourceType, NdrVersionFilter filter=NdrVersionFilterDefaultOnly)
A convenience wrapper around GetNodeByName().
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 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.