All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
defaultResolver_v1.h
Go to the documentation of this file.
1 //
2 // Copyright 2016 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 #ifndef PXR_INCLUDED_FROM_AR_DEFAULT_RESOLVER_H
25 #error This file should not be included directly. Include resolverContext.h instead
26 #endif
27 
28 #ifndef PXR_USD_AR_DEFAULT_RESOLVER_V1_H
29 #define PXR_USD_AR_DEFAULT_RESOLVER_V1_H
30 
32 
33 #include "pxr/pxr.h"
34 #include "pxr/usd/ar/api.h"
36 #include "pxr/usd/ar/resolver.h"
37 #include "pxr/usd/ar/threadLocalScopedCache.h"
38 
39 #include <tbb/enumerable_thread_specific.h>
40 
41 #include <memory>
42 #include <string>
43 #include <vector>
44 
45 PXR_NAMESPACE_OPEN_SCOPE
46 
68  : public ArResolver
69 {
70 public:
71  AR_API
73 
74  AR_API
75  virtual ~ArDefaultResolver();
76 
82  AR_API
83  static void SetDefaultSearchPath(
84  const std::vector<std::string>& searchPath);
85 
86  // ArResolver overrides
87 
92  AR_API
93  virtual void ConfigureResolverForAsset(const std::string& path) override;
94 
95  AR_API
96  virtual std::string AnchorRelativePath(
97  const std::string& anchorPath,
98  const std::string& path) override;
99 
100  AR_API
101  virtual bool IsRelativePath(const std::string& path) override;
102 
103  AR_API
104  virtual bool IsRepositoryPath(const std::string& path) override;
105 
106  AR_API
107  virtual bool IsSearchPath(const std::string& path) override;
108 
109  AR_API
110  virtual std::string GetExtension(const std::string& path) override;
111 
112  AR_API
113  virtual std::string ComputeNormalizedPath(const std::string& path) override;
114 
115  AR_API
116  virtual std::string ComputeRepositoryPath(const std::string& path) override;
117 
118  AR_API
119  virtual std::string ComputeLocalPath(const std::string& path) override;
120 
121  AR_API
122  virtual std::string Resolve(const std::string& path) override;
123 
124  AR_API
125  virtual std::string ResolveWithAssetInfo(
126  const std::string& path,
127  ArAssetInfo* assetInfo) override;
128 
129  AR_API
130  virtual void UpdateAssetInfo(
131  const std::string& identifier,
132  const std::string& filePath,
133  const std::string& fileVersion,
134  ArAssetInfo* assetInfo) override;
135 
136  AR_API
138  const std::string& path,
139  const std::string& resolvedPath) override;
140 
141  AR_API
142  virtual bool FetchToLocalResolvedPath(
143  const std::string& path,
144  const std::string& resolvedPath) override;
145 
146  AR_API
147  virtual std::shared_ptr<ArAsset> OpenAsset(
148  const std::string& resolvedPath) override;
149 
150  AR_API
151  virtual bool CreatePathForLayer(
152  const std::string& path) override;
153 
154  AR_API
155  virtual bool CanWriteLayerToPath(
156  const std::string& path,
157  std::string* whyNot) override;
158 
159  AR_API
160  virtual bool CanCreateNewLayerWithIdentifier(
161  const std::string& identifier,
162  std::string* whyNot) override;
163 
164  AR_API
165  virtual ArResolverContext CreateDefaultContext() override;
166 
174  AR_API
176  const std::string& filePath) override;
177 
178  AR_API
179  virtual void RefreshContext(const ArResolverContext& context) override;
180 
181  AR_API
182  virtual ArResolverContext GetCurrentContext() override;
183 
184  AR_API
185  virtual void BeginCacheScope(
186  VtValue* cacheScopeData) override;
187 
188  AR_API
189  virtual void EndCacheScope(
190  VtValue* cacheScopeData) override;
191 
192  AR_API
193  virtual void BindContext(
194  const ArResolverContext& context,
195  VtValue* bindingData) override;
196 
197  AR_API
198  virtual void UnbindContext(
199  const ArResolverContext& context,
200  VtValue* bindingData) override;
201 
202 private:
203  struct _Cache;
205  using _CachePtr = _PerThreadCache::CachePtr;
206  _CachePtr _GetCurrentCache();
207 
208  const ArDefaultResolverContext* _GetCurrentContext();
209 
210  std::string _ResolveNoCache(const std::string& path);
211 
212 private:
213  ArDefaultResolverContext _fallbackContext;
214  ArResolverContext _defaultContext;
215 
216  _PerThreadCache _threadCache;
217 
218  using _ContextStack = std::vector<const ArDefaultResolverContext*>;
219  using _PerThreadContextStack =
220  tbb::enumerable_thread_specific<_ContextStack>;
221  _PerThreadContextStack _threadContextStack;
222 
223 };
224 
225 PXR_NAMESPACE_CLOSE_SCOPE
226 
227 #endif
static AR_API void SetDefaultSearchPath(const std::vector< std::string > &searchPath)
Set the default search path that will be used during asset resolution.
virtual AR_API std::string AnchorRelativePath(const std::string &anchorPath, const std::string &path) override
Returns the path formed by anchoring path to anchorPath.
Default asset resolution implementation used when no plugin implementation is provided.
virtual AR_API VtValue GetModificationTimestamp(const std::string &path, const std::string &resolvedPath) override
Returns a value representing the last time the asset identified by path was modified.
virtual AR_API ArResolverContext CreateDefaultContext() override
Return a default ArResolverContext that may be bound to this resolver to resolve assets when no other...
virtual AR_API bool IsRepositoryPath(const std::string &path) override
Returns true if the given path is a repository path.
virtual AR_API void RefreshContext(const ArResolverContext &context) override
Refresh any caches associated with the given context.
virtual AR_API ArResolverContext GetCurrentContext() override
Returns the currently-bound asset resolver context.
Resolver context object that specifies a search path to use during asset resolution.
virtual AR_API std::string ComputeLocalPath(const std::string &path) override
Returns the local path for the given path.
virtual AR_API bool IsSearchPath(const std::string &path) override
Returns whether this path is a search path.
virtual AR_API void EndCacheScope(VtValue *cacheScopeData) override
Mark the end of a resolution caching scope.
virtual AR_API bool CreatePathForLayer(const std::string &path) override
Create path needed to write a file to the given path.
virtual AR_API bool CanWriteLayerToPath(const std::string &path, std::string *whyNot) override
Returns true if a file may be written to the given path, false otherwise.
virtual AR_API std::shared_ptr< ArAsset > OpenAsset(const std::string &resolvedPath) override
Returns an ArAsset object for the asset located at resolvedPath.
virtual AR_API void ConfigureResolverForAsset(const std::string &path) override
Sets the resolver&#39;s default context (returned by CreateDefaultContext()) to the same context you woul...
virtual AR_API bool FetchToLocalResolvedPath(const std::string &path, const std::string &resolvedPath) override
Fetch the asset identified by path to the filesystem location specified by resolvedPath.
virtual AR_API void BindContext(const ArResolverContext &context, VtValue *bindingData) override
Binds the given context to this resolver.
virtual AR_API bool IsRelativePath(const std::string &path) override
Returns true if the given path is a relative path.
virtual AR_API void BeginCacheScope(VtValue *cacheScopeData) override
Mark the start of a resolution caching scope.
virtual AR_API std::string ResolveWithAssetInfo(const std::string &path, ArAssetInfo *assetInfo) override
Returns the resolved filesystem path for the file identified by path following the same path resoluti...
virtual AR_API std::string Resolve(const std::string &path) override
Returns the resolved filesystem path for the file identified by the given path if it exists...
virtual AR_API ArResolverContext CreateDefaultContextForAsset(const std::string &filePath) override
Creates a context that adds the directory containing filePath as a first directory to be searched...
virtual AR_API std::string ComputeNormalizedPath(const std::string &path) override
Returns a normalized version of the given path.
An asset resolver context allows clients to provide additional data to the resolver for use during re...
virtual AR_API bool CanCreateNewLayerWithIdentifier(const std::string &identifier, std::string *whyNot) override
Returns true if a new file may be created using the given identifier, false otherwise.
virtual AR_API void UnbindContext(const ArResolverContext &context, VtValue *bindingData) override
Unbind the given context from this resolver.
virtual AR_API void UpdateAssetInfo(const std::string &identifier, const std::string &filePath, const std::string &fileVersion, ArAssetInfo *assetInfo) override
Update assetInfo with respect to the given fileVersion .
virtual AR_API std::string ComputeRepositoryPath(const std::string &path) override
Returns the computed repository path using the current resolver.
Provides a container which may hold any type, and provides introspection and iteration over array typ...
Definition: value.h:168
virtual AR_API std::string GetExtension(const std::string &path) override
Returns the normalized extension for the given path.
Interface for the asset resolution system.
Definition: resolver_v1.h:57
Contains information about a resolved asset.
Definition: assetInfo.h:40