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 Apache License, Version 2.0 (the "Apache License")
5 // with the following modification; you may not use this file except in
6 // compliance with the Apache License and the following modification to it:
7 // Section 6. Trademarks. is deleted and replaced with:
8 //
9 // 6. Trademarks. This License does not grant permission to use the trade
10 // names, trademarks, service marks, or product names of the Licensor
11 // and its affiliates, except as required to comply with Section 4(c) of
12 // the License and to reproduce the content of the NOTICE file.
13 //
14 // You may obtain a copy of the Apache License at
15 //
16 // http://www.apache.org/licenses/LICENSE-2.0
17 //
18 // Unless required by applicable law or agreed to in writing, software
19 // distributed under the Apache License with the above modification is
20 // distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
21 // KIND, either express or implied. See the Apache License for the specific
22 // language governing permissions and limitations under the Apache License.
23 //
24 
25 #ifndef PXR_USD_NDR_FILESYSTEM_DISCOVERY_H
26 #define PXR_USD_NDR_FILESYSTEM_DISCOVERY_H
27 
28 /// \file ndrDiscovery/filesystemDiscovery.h
29 
30 #include "pxr/pxr.h"
31 #include "pxr/usd/ndr/api.h"
33 #include <functional>
34 
36 
38 
39 /// \class _NdrFilesystemDiscoveryPlugin
40 ///
41 /// Discovers nodes on the filesystem. The provided search paths are walked to
42 /// find files that have certain extensions. If a file with a matching extension
43 /// is found, it is turned into a `NdrNodeDiscoveryResult` and will be parsed
44 /// into a node when its information is accessed.
45 ///
46 /// Parameters for this plugin are specified via environment variables (which
47 /// must be set before the library is loaded):
48 ///
49 /// PXR_NDR_FS_PLUGIN_SEARCH_PATHS - The paths that should be searched,
50 /// recursively, for files that represent nodes. Paths should be separated by
51 /// either a ':' or a ';' depending on your platform (it should mimic the PATH
52 /// env var on your platform). See ARCH_PATH_LIST_SEP.
53 ///
54 /// PXR_NDR_FS_PLUGIN_ALLOWED_EXTS - The extensions on files that define nodes.
55 /// Do not include the leading ".". Extensions should be separated by a colon.
56 ///
57 /// PXR_NDR_FS_PLUGIN_FOLLOW_SYMLINKS - Whether symlinks should be followed
58 /// while walking the search paths. Set to "true" (case sensitive) if they
59 /// should be followed.
60 ///
62 {
63 public:
64  /// A filter for discovered nodes. If the function returns false
65  /// then the discovered node is discarded. Otherwise the function
66  /// can modify the discovery result.
67  using Filter = std::function<bool(NdrNodeDiscoveryResult&)>;
68 
69  /// Constructor.
70  NDR_API
72 
73  /// DiscoverNodes() will pass each result to the given function for
74  /// modification. If the function returns false then the result is
75  /// discarded.
76  NDR_API
78 
79  /// Destructor
80  NDR_API
82 
83  /// Discover all of the nodes that appear within the the search paths
84  /// provided and match the extensions provided.
85  NDR_API
87 
88  /// Gets the paths that this plugin is searching for nodes in.
89  NDR_API
90  const NdrStringVec& GetSearchURIs() const override { return _searchPaths; }
91 
92 private:
93  /// The paths (abs) indicating where the plugin should search for nodes.
94  NdrStringVec _searchPaths;
95 
96  /// The extensions (excluding leading '.') that signify a valid node file.
97  /// The extension will be used as the `type` member in the resulting
98  /// `NdrNodeDiscoveryResult` instance.
99  NdrStringVec _allowedExtensions;
100 
101  /// Whether or not to follow symlinks while scanning directories for files.
102  bool _followSymlinks;
103 
104  // The filter to run on the results.
105  Filter _filter;
106 };
107 
109 
110 #endif // PXR_USD_NDR_FILESYSTEM_DISCOVERY_H
NDR_API NdrNodeDiscoveryResultVec DiscoverNodes(const Context &) override
NDR_API _NdrFilesystemDiscoveryPlugin()
Constructor.
std::vector< NdrNodeDiscoveryResult > NdrNodeDiscoveryResultVec
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
Definition: glew.h:2981
NDR_API ~_NdrFilesystemDiscoveryPlugin()
Destructor.
std::function< bool(NdrNodeDiscoveryResult &)> Filter
std::vector< std::string > NdrStringVec
Definition: declare.h:79
NDR_API const NdrStringVec & GetSearchURIs() const override
Gets the paths that this plugin is searching for nodes in.
#define NDR_API
Definition: api.h:40
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1346
PXR_NAMESPACE_OPEN_SCOPE TF_DECLARE_WEAK_AND_REF_PTRS(_NdrFilesystemDiscoveryPlugin)
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:91
rst::
Definition: OpenColorIO.h:1205