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