All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
resolver.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 AR_RESOLVER_H
25 #define AR_RESOLVER_H
26 
28 
29 #include "pxr/pxr.h"
30 #include "pxr/usd/ar/api.h"
31 #include <memory>
32 #include <string>
33 #include <vector>
34 
35 PXR_NAMESPACE_OPEN_SCOPE
36 
37 class ArAsset;
38 class ArAssetInfo;
39 class ArResolverContext;
40 class TfType;
41 class VtValue;
42 
53 class ArResolver
54 {
55 public:
56  AR_API
57  virtual ~ArResolver();
58 
59  // Disallow copies
60  ArResolver(const ArResolver&) = delete;
61  ArResolver& operator=(const ArResolver&) = delete;
62 
63  // --------------------------------------------------------------------- //
68  // --------------------------------------------------------------------- //
69 
71  AR_API
72  virtual void ConfigureResolverForAsset(const std::string& path) = 0;
73 
85  AR_API
86  virtual std::string AnchorRelativePath(
87  const std::string& anchorPath,
88  const std::string& path) = 0;
89 
91  AR_API
92  virtual bool IsRelativePath(const std::string& path) = 0;
93 
95  AR_API
96  virtual bool IsRepositoryPath(const std::string& path) = 0;
97 
99  AR_API
100  virtual bool IsSearchPath(const std::string& path) = 0;
101 
103  AR_API
104  virtual std::string GetExtension(const std::string& path) = 0;
105 
107  AR_API
108  virtual std::string ComputeNormalizedPath(const std::string& path) = 0;
109 
111  AR_API
112  virtual std::string ComputeRepositoryPath(const std::string& path) = 0;
113 
115  AR_API
116  virtual std::string ComputeLocalPath(const std::string& path) = 0;
117 
121  AR_API
122  virtual std::string Resolve(const std::string& path) = 0;
123 
125 
126  // --------------------------------------------------------------------- //
131  // --------------------------------------------------------------------- //
132 
139  AR_API
140  virtual void BindContext(
141  const ArResolverContext& context,
142  VtValue* bindingData) = 0;
143 
150  AR_API
151  virtual void UnbindContext(
152  const ArResolverContext& context,
153  VtValue* bindingData) = 0;
154 
160  AR_API
162 
169  AR_API
171  const std::string& filePath) = 0;
172 
174  AR_API
175  virtual void RefreshContext(const ArResolverContext& context) = 0;
176 
180  AR_API
181  virtual ArResolverContext GetCurrentContext() = 0;
182 
184 
185  // --------------------------------------------------------------------- //
190  // --------------------------------------------------------------------- //
191 
202  AR_API
203  virtual std::string ResolveWithAssetInfo(
204  const std::string& path,
205  ArAssetInfo* assetInfo) = 0;
206 
210  AR_API
211  virtual void UpdateAssetInfo(
212  const std::string& identifier,
213  const std::string& filePath,
214  const std::string& fileVersion,
215  ArAssetInfo* assetInfo) = 0;
216 
228  AR_API
230  const std::string& path,
231  const std::string& resolvedPath) = 0;
232 
247  AR_API
248  virtual bool FetchToLocalResolvedPath(
249  const std::string& path,
250  const std::string& resolvedPath) = 0;
251 
263  AR_API
264  virtual std::shared_ptr<ArAsset> OpenAsset(
265  const std::string& resolvedPath) = 0;
266 
272  AR_API
273  virtual bool CanWriteLayerToPath(
274  const std::string& path,
275  std::string* whyNot) = 0;
276 
282  AR_API
283  virtual bool CanCreateNewLayerWithIdentifier(
284  const std::string& identifier,
285  std::string* whyNot) = 0;
286 
288 
289  // --------------------------------------------------------------------- //
318  // --------------------------------------------------------------------- //
319 
330  AR_API
331  virtual void BeginCacheScope(
332  VtValue* cacheScopeData) = 0;
333 
343  AR_API
344  virtual void EndCacheScope(
345  VtValue* cacheScopeData) = 0;
346 
348 
349 protected:
350  AR_API
351  ArResolver();
352 };
353 
379 AR_API
381 
393 AR_API
394 void ArSetPreferredResolver(const std::string& resolverTypeName);
395 
403 
412 AR_API
414 
431 AR_API
432 std::vector<TfType> ArGetAvailableResolvers();
433 
451 AR_API
452 std::unique_ptr<ArResolver> ArCreateResolver(const TfType& resolverType);
453 
455 
456 PXR_NAMESPACE_CLOSE_SCOPE
457 
458 #endif // AR_RESOLVER_H
virtual AR_API std::string ComputeLocalPath(const std::string &path)=0
Returns the local path for the given path.
AR_API std::unique_ptr< ArResolver > ArCreateResolver(const TfType &resolverType)
Construct an instance of the ArResolver subclass specified by resolverType.
virtual AR_API bool CanCreateNewLayerWithIdentifier(const std::string &identifier, std::string *whyNot)=0
Returns true if a new file may be created using the given identifier, false otherwise.
virtual AR_API void EndCacheScope(VtValue *cacheScopeData)=0
Mark the end of a resolution caching scope.
virtual AR_API void RefreshContext(const ArResolverContext &context)=0
Refresh any caches associated with the given context.
virtual AR_API std::string Resolve(const std::string &path)=0
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)=0
Return a default ArResolverContext that may be bound to this resolver to resolve the asset located at...
virtual AR_API std::string GetExtension(const std::string &path)=0
Returns the normalized extension for the given path.
Interface for accessing the contents of an asset.
Definition: asset.h:43
virtual AR_API ArResolverContext GetCurrentContext()=0
Returns the currently-bound asset resolver context.
virtual AR_API bool IsRepositoryPath(const std::string &path)=0
Returns true if the given path is a repository path.
virtual AR_API bool FetchToLocalResolvedPath(const std::string &path, const std::string &resolvedPath)=0
Fetch the asset identified by path to the filesystem location specified by resolvedPath.
virtual AR_API void UnbindContext(const ArResolverContext &context, VtValue *bindingData)=0
Unbind the given context from this resolver.
virtual AR_API bool IsRelativePath(const std::string &path)=0
Returns true if the given path is a relative path.
virtual AR_API void BeginCacheScope(VtValue *cacheScopeData)=0
Mark the start of a resolution caching scope.
AR_API ArResolver & ArGetResolver()
Returns the configured asset resolver.
virtual AR_API bool IsSearchPath(const std::string &path)=0
Returns whether this path is a search path.
virtual AR_API std::string ComputeNormalizedPath(const std::string &path)=0
Returns a normalized version of the given path.
virtual AR_API std::string ComputeRepositoryPath(const std::string &path)=0
Returns the computed repository path using the current resolver.
virtual AR_API bool CanWriteLayerToPath(const std::string &path, std::string *whyNot)=0
Returns true if a file may be written to the given path, false otherwise.
AR_API void ArSetPreferredResolver(const std::string &resolverTypeName)
Set the preferred ArResolver subclass used by ArGetResolver.
virtual AR_API void ConfigureResolverForAsset(const std::string &path)=0
Configures the resolver for a given asset path.
AR_API std::vector< TfType > ArGetAvailableResolvers()
Returns list of TfTypes for available ArResolver subclasses.
virtual AR_API std::string ResolveWithAssetInfo(const std::string &path, ArAssetInfo *assetInfo)=0
Returns the resolved filesystem path for the file identified by path following the same path resoluti...
virtual AR_API void UpdateAssetInfo(const std::string &identifier, const std::string &filePath, const std::string &fileVersion, ArAssetInfo *assetInfo)=0
Update assetInfo with respect to the given fileVersion .
virtual AR_API std::string AnchorRelativePath(const std::string &anchorPath, const std::string &path)=0
Returns the path formed by anchoring path to anchorPath.
virtual AR_API VtValue GetModificationTimestamp(const std::string &path, const std::string &resolvedPath)=0
Returns a value representing the last time the asset identified by path was modified.
virtual AR_API void BindContext(const ArResolverContext &context, VtValue *bindingData)=0
Binds the given context to this resolver.
AR_API ArResolver & ArGetUnderlyingResolver()
Returns the underlying ArResolver instance used by ArGetResolver.
TfType represents a dynamic runtime type.
Definition: type.h:70
virtual AR_API std::shared_ptr< ArAsset > OpenAsset(const std::string &resolvedPath)=0
Returns an ArAsset object for the asset located at resolvedPath.
An asset resolver context allows clients to provide additional data to the resolver for use during re...
Provides a container which may hold any type, and provides introspection and iteration over array typ...
Definition: value.h:182
virtual AR_API ArResolverContext CreateDefaultContext()=0
Return a default ArResolverContext that may be bound to this resolver to resolve assets when no other...
Interface for the asset resolution system.
Definition: resolver.h:53
Contains information about a resolved asset.
Definition: assetInfo.h:40