HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
filesystemDiscoveryHelpers.h File Reference
#include "pxr/pxr.h"
#include "pxr/usd/ndr/api.h"
#include "pxr/usd/ndr/declare.h"
#include "pxr/usd/ndr/nodeDiscoveryResult.h"
#include <functional>
+ Include dependency graph for filesystemDiscoveryHelpers.h:

Go to the source code of this file.

Classes

struct  NdrDiscoveryUri
 

Typedefs

using NdrParseIdentifierFn = std::function< bool(const TfToken &identifier, TfToken *family, TfToken *name, NdrVersion *version)>
 
using NdrDiscoveryUriVec = std::vector< NdrDiscoveryUri >
 A vector of URI/resolved URI structs. More...
 

Functions

NDR_API bool NdrFsHelpersSplitShaderIdentifier (const TfToken &identifier, TfToken *family, TfToken *name, NdrVersion *version)
 
NDR_API NdrNodeDiscoveryResultVec NdrFsHelpersDiscoverNodes (const NdrStringVec &searchPaths, const NdrStringVec &allowedExtensions, bool followSymlinks=true, const NdrDiscoveryPluginContext *context=nullptr, const NdrParseIdentifierFn &parseIdentifierFn=NdrFsHelpersSplitShaderIdentifier)
 
NDR_API NdrDiscoveryUriVec NdrFsHelpersDiscoverFiles (const NdrStringVec &searchPaths, const NdrStringVec &allowedExtensions, bool followSymlinks=true)
 

Detailed Description

Provides utilities that the default filesystem discovery plugin uses. If a custom filesystem discovery plugin is needed, these can be used to fill in a large chunk of the functionality.

Definition in file filesystemDiscoveryHelpers.h.

Typedef Documentation

using NdrDiscoveryUriVec = std::vector<NdrDiscoveryUri>

A vector of URI/resolved URI structs.

Definition at line 119 of file filesystemDiscoveryHelpers.h.

using NdrParseIdentifierFn = std::function< bool (const TfToken &identifier, TfToken *family, TfToken *name, NdrVersion *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 54 of file filesystemDiscoveryHelpers.h.

Function Documentation

NDR_API NdrDiscoveryUriVec NdrFsHelpersDiscoverFiles ( const NdrStringVec searchPaths,
const NdrStringVec 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 NdrFsHelpersDiscoverNodes 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.

NDR_API NdrNodeDiscoveryResultVec NdrFsHelpersDiscoverNodes ( const NdrStringVec searchPaths,
const NdrStringVec allowedExtensions,
bool  followSymlinks = true,
const NdrDiscoveryPluginContext context = nullptr,
const NdrParseIdentifierFn parseIdentifierFn = NdrFsHelpersSplitShaderIdentifier 
)

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, NdrFsHelpersSplitShaderIdentifier 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.

NDR_API bool NdrFsHelpersSplitShaderIdentifier ( const TfToken identifier,
TfToken family,
TfToken name,
NdrVersion version 
)

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

  • 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).