HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
filesystemDiscoveryHelpers.h File Reference
+ Include dependency graph for filesystemDiscoveryHelpers.h:

Go to the source code of this file.

Classes

struct  SdrDiscoveryUri
 

Typedefs

using SdrParseIdentifierFn = std::function< bool(const TfToken &identifier, TfToken *family, TfToken *name, SdrVersion *version)>
 
using SdrDiscoveryUriVec = std::vector< SdrDiscoveryUri >
 A vector of URI/resolved URI structs. More...
 

Functions

SDR_API bool SdrFsHelpersSplitShaderIdentifier (const TfToken &identifier, TfToken *family, TfToken *name, SdrVersion *version)
 
SDR_API
SdrShaderNodeDiscoveryResultVec 
SdrFsHelpersDiscoverShaderNodes (const SdrStringVec &searchPaths, const SdrStringVec &allowedExtensions, bool followSymlinks=true, const SdrDiscoveryPluginContext *context=nullptr, const SdrParseIdentifierFn &parseIdentifierFn=SdrFsHelpersSplitShaderIdentifier)
 
SDR_API SdrDiscoveryUriVec SdrFsHelpersDiscoverFiles (const SdrStringVec &searchPaths, const SdrStringVec &allowedExtensions, bool followSymlinks=true)
 

Detailed Description

Note
All Ndr objects are deprecated in favor of the corresponding Sdr objects in this file. All existing pxr/usd/ndr implementations will be moved to pxr/usd/sdr.

Definition in file filesystemDiscoveryHelpers.h.

Typedef Documentation

using SdrDiscoveryUriVec = std::vector<SdrDiscoveryUri>

A vector of URI/resolved URI structs.

Definition at line 108 of file filesystemDiscoveryHelpers.h.

using SdrParseIdentifierFn = std::function< bool (const TfToken &identifier, TfToken *family, TfToken *name, SdrVersion *version)>

Type of a function that can be used to parse a discovery result's identifier into its family, name, and version.

Definition at line 43 of file filesystemDiscoveryHelpers.h.

Function Documentation

SDR_API SdrDiscoveryUriVec SdrFsHelpersDiscoverFiles ( const SdrStringVec searchPaths,
const SdrStringVec allowedExtensions,
bool  followSymlinks = true 
)

Returns a vector of discovered URIs (as both the unresolved URI and the resolved URI) that are found while walking the given search paths.

Each path in searchPaths is walked recursively, optionally following symlinks if followSymlinks is true, looking for files that match one of the provided allowedExtensions. These files' unresolved and resolved URIs are returned in the result vector.

This is an alternative to SdrFsHelpersDiscoverNodes for discovery plugins that want to search for files that are not meant to be returned by discovery themselves, but can be parsed to generate the discovery results.

SDR_API SdrShaderNodeDiscoveryResultVec SdrFsHelpersDiscoverShaderNodes ( const SdrStringVec searchPaths,
const SdrStringVec allowedExtensions,
bool  followSymlinks = true,
const SdrDiscoveryPluginContext context = nullptr,
const SdrParseIdentifierFn parseIdentifierFn = SdrFsHelpersSplitShaderIdentifier 
)

Returns a vector of discovery results that have been found while walking the given search paths.

Each path in searchPaths is walked recursively, optionally following symlinks if followSymlinks is true, looking for files that match one of the provided allowedExtensions. These files are represented in the discovery results that are returned.

The identifier for each discovery result is the base name of the represented file with the extension removed. The parseIdentifierFn is used to parse the family, name, and version from the identifier that will set in the file's discovery result. By default, SdrFsHelpersSplitShaderIdentifier is used to parse the identifier, but the family/name/version parsing behavior can be changed by passing a custom parseIdentifierFn. Any identifiers that cannot be parsed by whatever the parseIdentifierFn will be considered invalid and not added as a discovery result. Note that the version for every discovery result returned by this function will be naively marked as being default even if multiple versions with the same name are found.

SDR_API bool SdrFsHelpersSplitShaderIdentifier ( const TfToken identifier,
TfToken family,
TfToken name,
SdrVersion version 
)

Given a shader's identifier token, computes the corresponding SdrShaderNode's family name, implementation name and shader version (as SdrVersion).

  • family is the prefix of identifier up to and not including the first underscore.
  • version is the suffix of identifier comprised of one or two integers representing the major and minor version numbers.
  • name is the string we get by joining family with everything that's in between family and version with an underscore.

Returns true if identifier is valid and was successfully split into the different components.

Note
The python version of this function returns a tuple containing (famiyName, implementationName, version).