HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
filesystemDiscovery.h
Go to the documentation of this file.
1 //
2 // Copyright 2025 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_SDR_FILESYSTEM_DISCOVERY_H
9 #define PXR_USD_SDR_FILESYSTEM_DISCOVERY_H
10 
11 /// \file sdr/filesystemDiscovery.h
12 ///
13 /// \note
14 /// All Ndr objects are deprecated in favor of the corresponding Sdr objects
15 /// in this file. All existing pxr/usd/ndr implementations will be moved to
16 /// pxr/usd/sdr.
17 
18 #include "pxr/pxr.h"
20 #include "pxr/usd/sdr/api.h"
22 #include <functional>
23 
25 
27 
28 /// \class _SdrFilesystemDiscoveryPlugin
29 ///
30 /// Discovers shader nodes on the filesystem. The provided search paths are
31 /// walked to find files that have certain extensions. If a file with a
32 /// matching extension is found, it is turned into a
33 /// `SdrShaderNodeDiscoveryResult` and will be parsed into a node when its
34 /// information is accessed.
35 ///
36 /// Parameters for this plugin are specified via environment variables (which
37 /// must be set before the library is loaded):
38 ///
39 /// PXR_SDR_FS_PLUGIN_SEARCH_PATHS - The paths that should be searched,
40 /// recursively, for files that represent nodes. Paths should be separated by
41 /// either a ':' or a ';' depending on your platform (it should mimic the PATH
42 /// env var on your platform). See ARCH_PATH_LIST_SEP.
43 ///
44 /// PXR_SDR_FS_PLUGIN_ALLOWED_EXTS - The extensions on files that define nodes.
45 /// Do not include the leading ".". Extensions should be separated by a colon.
46 ///
47 /// PXR_SDR_FS_PLUGIN_FOLLOW_SYMLINKS - Whether symlinks should be followed
48 /// while walking the search paths. Set to "true" (case sensitive) if they
49 /// should be followed.
51 public:
52  /// A filter for discovered nodes. If the function returns false
53  /// then the discovered node is discarded. Otherwise the function
54  /// can modify the discovery result.
55  using Filter = std::function<bool(SdrShaderNodeDiscoveryResult&)>;
56 
57  /// Constructor.
58  SDR_API
60 
61  /// DiscoverNodes() will pass each result to the given function for
62  /// modification. If the function returns false then the result is
63  /// discarded.
64  SDR_API
66 
67  /// Destructor
68  SDR_API
70 
71  /// Discover all of the nodes that appear within the the search paths
72  /// provided and match the extensions provided.
73  SDR_API
75  const Context&) override;
76 
77  /// Gets the paths that this plugin is searching for nodes in.
78  SDR_API
79  const SdrStringVec& GetSearchURIs() const override { return _searchPaths; }
80 
81 private:
82  /// The paths (abs) indicating where the plugin should search for nodes.
83  SdrStringVec _searchPaths;
84 
85  /// The extensions (excluding leading '.') that signify a valid node file.
86  /// The extension will be used as the `type` member in the resulting
87  /// `SdrShaderNodeDiscoveryResult` instance.
88  SdrStringVec _allowedExtensions;
89 
90  /// Whether or not to follow symlinks while scanning directories for files.
91  bool _followSymlinks;
92 
93  // The filter to run on the results.
94  Filter _filter;
95 };
96 
98 
99 #endif // PXR_USD_SDR_FILESYSTEM_DISCOVERY_H
std::vector< SdrShaderNodeDiscoveryResult > SdrShaderNodeDiscoveryResultVec
std::vector< std::string > SdrStringVec
Definition: declare.h:67
SDR_API SdrShaderNodeDiscoveryResultVec DiscoverShaderNodes(const Context &) override
SDR_API const SdrStringVec & GetSearchURIs() const override
Gets the paths that this plugin is searching for nodes in.
SDR_API _SdrFilesystemDiscoveryPlugin()
Constructor.
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1425
SDR_API ~_SdrFilesystemDiscoveryPlugin()
Destructor.
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
Context provides a wrapper around the Core library context object.
Definition: ImfContext.h:30
PXR_NAMESPACE_OPEN_SCOPE TF_DECLARE_WEAK_AND_REF_PTRS(_NdrFilesystemDiscoveryPlugin)
std::function< bool(SdrShaderNodeDiscoveryResult &)> Filter
#define SDR_API
Definition: api.h:23
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
Definition: glcorearb.h:1297