HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
filesystemDiscoveryHelpers.h
Go to the documentation of this file.
1 //
2 // Copyright 2018 Pixar
3 //
4 // Licensed under the terms set forth in the LICENSE.txt file available at
5 // https://openusd.org/license.
6 //
7 
8 #ifndef PXR_USD_NDR_FILESYSTEM_DISCOVERY_HELPERS_H
9 #define PXR_USD_NDR_FILESYSTEM_DISCOVERY_HELPERS_H
10 
11 /// \file ndr/filesystemDiscoveryHelpers.h
12 ///
13 /// \deprecated
14 /// All Ndr objects are deprecated in favor of the corresponding Sdr objects
15 /// in sdr/filesystemDiscoveryHelpers.h
16 
17 #include "pxr/pxr.h"
18 #include "pxr/base/tf/envSetting.h"
19 #include "pxr/usd/ndr/api.h"
20 #include "pxr/usd/ndr/declare.h"
22 
23 #include <functional>
24 
26 
28 
29 /// \file filesystemDiscoveryHelpers.h
30 ///
31 /// Provides utilities that the default filesystem discovery plugin uses. If
32 /// a custom filesystem discovery plugin is needed, these can be used to fill
33 /// in a large chunk of the functionality.
34 ///
35 
36 /// \deprecated in favor of PXR_SDR_FS_PLUGIN_SEARCH_PATHS
37 NDR_API
39 
40 /// \deprecated in favor of PXR_SDR_FS_PLUGIN_SEARCH_PATHS
41 NDR_API
43 
44 /// \deprecated in favor of PXR_NDR_FS_PLUGIN_FOLLOW_SYMLINKS
45 NDR_API
47 
48 /// Type of a function that can be used to parse a discovery result's identifier
49 /// into its family, name, and version.
50 using NdrParseIdentifierFn = std::function<
51  bool (const TfToken &identifier,
52  TfToken *family,
53  TfToken *name,
55 
56 /// Given a shader's \p identifier token, computes the corresponding
57 /// NdrNode's family name, implementation name and shader version
58 /// (as NdrVersion).
59 ///
60 /// * \p family is the prefix of \p identifier up to and not
61 /// including the first underscore.
62 /// * \p version is the suffix of \p identifier comprised of one or
63 /// two integers representing the major and minor version numbers.
64 /// * \p name is the string we get by joining
65 /// <i>family</i> with everything that's in between <i>family</i>
66 /// and <i>version</i> with an underscore.
67 ///
68 /// Returns true if \p identifier is valid and was successfully split
69 /// into the different components.
70 ///
71 /// \note The python version of this function returns a tuple containing
72 /// (famiyName, implementationName, version).
73 ///
74 /// \deprecated
75 /// Deprecated in favor of SdrFsHelpersSplitShaderIdentifier
76 NDR_API
77 bool
79  const TfToken &identifier,
80  TfToken *family,
81  TfToken *name,
83 
84 /// Returns a vector of discovery results that have been found while walking
85 /// the given search paths.
86 ///
87 /// Each path in \p searchPaths is walked recursively, optionally following
88 /// symlinks if \p followSymlinks is true, looking for files that match one of
89 /// the provided \p allowedExtensions. These files are represented in the
90 /// discovery results that are returned.
91 ///
92 /// The identifier for each discovery result is the base name of the represented
93 /// file with the extension removed. The \p parseIdentifierFn is used to parse
94 /// the family, name, and version from the identifier that will set in the
95 /// file's discovery result. By default, NdrFsHelpersSplitShaderIdentifier is
96 /// used to parse the identifier, but the family/name/version parsing behavior
97 /// can be changed by passing a custom parseIdentifierFn. Any identifiers that
98 /// cannot be parsed by whatever the parseIdentifierFn will be considered
99 /// invalid and not added as a discovery result. Note that the version for
100 /// every discovery result returned by this function will be naively marked as
101 /// being default even if multiple versions with the same name are found.
102 ///
103 /// \deprecated
104 /// Deprecated in favor of SdrFsHelpersDiscoverShaderNodes
105 NDR_API
108  const NdrStringVec& searchPaths,
109  const NdrStringVec& allowedExtensions,
110  bool followSymlinks = true,
111  const NdrDiscoveryPluginContext* context = nullptr,
112  const NdrParseIdentifierFn &parseIdentifierFn =
114 );
115 
116 /// Struct for holding a URI and its resolved URI for a file discovered
117 /// by NdrFsHelpersDiscoverFiles
118 ///
119 /// \deprecated
120 /// Deprecated in favor of SdrDiscoveryUri
122 {
123  std::string uri;
124  std::string resolvedUri;
125 };
126 
127 /// A vector of URI/resolved URI structs.
128 using NdrDiscoveryUriVec = std::vector<NdrDiscoveryUri>;
129 
130 /// Returns a vector of discovered URIs (as both the unresolved URI and the
131 /// resolved URI) that are found while walking the given search paths.
132 ///
133 /// Each path in \p searchPaths is walked recursively, optionally following
134 /// symlinks if \p followSymlinks is true, looking for files that match one of
135 /// the provided \p allowedExtensions. These files' unresolved and resolved URIs
136 /// are returned in the result vector.
137 ///
138 /// This is an alternative to NdrFsHelpersDiscoverNodes for discovery plugins
139 /// that want to search for files that are not meant to be returned by discovery
140 /// themselves, but can be parsed to generate the discovery results.
141 ///
142 /// \deprecated
143 /// Deprecated in favor of SdrFsHelpersDiscoverFiles
144 NDR_API
147  const NdrStringVec& searchPaths,
148  const NdrStringVec& allowedExtensions,
149  bool followSymlinks = true
150 );
151 
153 
154 #endif // PXR_USD_NDR_FILESYSTEM_DISCOVERY_HELPERS_H
NDR_API NdrDiscoveryUriVec NdrFsHelpersDiscoverFiles(const NdrStringVec &searchPaths, const NdrStringVec &allowedExtensions, bool followSymlinks=true)
std::vector< NdrNodeDiscoveryResult > NdrNodeDiscoveryResultVec
OutGridT const XformOp bool bool
NDR_API TfEnvSetting< std::string > PXR_NDR_FS_PLUGIN_ALLOWED_EXTS
NDR_API TfEnvSetting< bool > PXR_NDR_FS_PLUGIN_FOLLOW_SYMLINKS
Definition: token.h:70
std::vector< NdrDiscoveryUri > NdrDiscoveryUriVec
A vector of URI/resolved URI structs.
NDR_API bool NdrFsHelpersSplitShaderIdentifier(const TfToken &identifier, TfToken *family, TfToken *name, NdrVersion *version)
std::vector< std::string > NdrStringVec
Definition: declare.h:70
GLuint const GLchar * name
Definition: glcorearb.h:786
#define NDR_API
Definition: api.h:23
GT_API const UT_StringHolder version
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1425
NDR_API NdrNodeDiscoveryResultVec NdrFsHelpersDiscoverNodes(const NdrStringVec &searchPaths, const NdrStringVec &allowedExtensions, bool followSymlinks=true, const NdrDiscoveryPluginContext *context=nullptr, const NdrParseIdentifierFn &parseIdentifierFn=NdrFsHelpersSplitShaderIdentifier)
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
std::function< bool(const TfToken &identifier, TfToken *family, TfToken *name, NdrVersion *version)> NdrParseIdentifierFn
NDR_API TfEnvSetting< std::string > PXR_NDR_FS_PLUGIN_SEARCH_PATHS