All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
resolver_v1.h
Go to the documentation of this file.
1 //
2 // Copyright 2020 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 INCLUDE_AR_RESOLVER
25 #error This file should not be included directly. Include resolver.h instead.
26 #endif
27 
28 #ifndef PXR_USD_AR_RESOLVER_V1_H
29 #define PXR_USD_AR_RESOLVER_V1_H
30 
32 
33 #include "pxr/pxr.h"
34 #include "pxr/usd/ar/api.h"
35 #include <memory>
36 #include <string>
37 #include <vector>
38 
39 PXR_NAMESPACE_OPEN_SCOPE
40 
41 class ArAsset;
42 class ArAssetInfo;
43 class ArResolverContext;
44 class TfType;
45 class VtValue;
46 
57 class ArResolver
58 {
59 public:
60  AR_API
61  virtual ~ArResolver();
62 
63  // Disallow copies
64  ArResolver(const ArResolver&) = delete;
65  ArResolver& operator=(const ArResolver&) = delete;
66 
67  // --------------------------------------------------------------------- //
72  // --------------------------------------------------------------------- //
73 
75  AR_API
76  virtual void ConfigureResolverForAsset(const std::string& path) = 0;
77 
89  AR_API
90  virtual std::string AnchorRelativePath(
91  const std::string& anchorPath,
92  const std::string& path) = 0;
93 
95  AR_API
96  virtual bool IsRelativePath(const std::string& path) = 0;
97 
99  AR_API
100  virtual bool IsRepositoryPath(const std::string& path) = 0;
101 
103  AR_API
104  virtual bool IsSearchPath(const std::string& path) = 0;
105 
107  AR_API
108  virtual std::string GetExtension(const std::string& path) = 0;
109 
111  AR_API
112  virtual std::string ComputeNormalizedPath(const std::string& path) = 0;
113 
115  AR_API
116  virtual std::string ComputeRepositoryPath(const std::string& path) = 0;
117 
119  AR_API
120  virtual std::string ComputeLocalPath(const std::string& path) = 0;
121 
125  AR_API
126  virtual std::string Resolve(const std::string& path) = 0;
127 
129 
130  // --------------------------------------------------------------------- //
135  // --------------------------------------------------------------------- //
136 
143  AR_API
144  virtual void BindContext(
145  const ArResolverContext& context,
146  VtValue* bindingData) = 0;
147 
154  AR_API
155  virtual void UnbindContext(
156  const ArResolverContext& context,
157  VtValue* bindingData) = 0;
158 
164  AR_API
166 
173  AR_API
175  const std::string& filePath) = 0;
176 
178  AR_API
179  virtual void RefreshContext(const ArResolverContext& context) = 0;
180 
184  AR_API
185  virtual ArResolverContext GetCurrentContext() = 0;
186 
188 
189  // --------------------------------------------------------------------- //
194  // --------------------------------------------------------------------- //
195 
206  AR_API
207  virtual std::string ResolveWithAssetInfo(
208  const std::string& path,
209  ArAssetInfo* assetInfo) = 0;
210 
214  AR_API
215  virtual void UpdateAssetInfo(
216  const std::string& identifier,
217  const std::string& filePath,
218  const std::string& fileVersion,
219  ArAssetInfo* assetInfo) = 0;
220 
232  AR_API
234  const std::string& path,
235  const std::string& resolvedPath) = 0;
236 
251  AR_API
252  virtual bool FetchToLocalResolvedPath(
253  const std::string& path,
254  const std::string& resolvedPath) = 0;
255 
267  AR_API
268  virtual std::shared_ptr<ArAsset> OpenAsset(
269  const std::string& resolvedPath) = 0;
270 
284  AR_API
285  virtual bool CreatePathForLayer(
286  const std::string& path) = 0;
287 
297  AR_API
298  virtual bool CanWriteLayerToPath(
299  const std::string& path,
300  std::string* whyNot) = 0;
301 
307  AR_API
308  virtual bool CanCreateNewLayerWithIdentifier(
309  const std::string& identifier,
310  std::string* whyNot) = 0;
311 
313 
314  // --------------------------------------------------------------------- //
343  // --------------------------------------------------------------------- //
344 
355  AR_API
356  virtual void BeginCacheScope(
357  VtValue* cacheScopeData) = 0;
358 
368  AR_API
369  virtual void EndCacheScope(
370  VtValue* cacheScopeData) = 0;
371 
373 
374 protected:
375  AR_API
376  ArResolver();
377 };
378 
404 AR_API
406 
418 AR_API
419 void ArSetPreferredResolver(const std::string& resolverTypeName);
420 
428 
437 AR_API
439 
456 AR_API
457 std::vector<TfType> ArGetAvailableResolvers();
458 
476 AR_API
477 std::unique_ptr<ArResolver> ArCreateResolver(const TfType& resolverType);
478 
480 
481 PXR_NAMESPACE_CLOSE_SCOPE
482 
483 #endif
virtual AR_API std::string ComputeLocalPath(const std::string &path)=0
Returns the local path for the given path.
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.
AR_API ArResolver & ArGetUnderlyingResolver()
Returns the underlying ArResolver instance used by ArGetResolver.
virtual AR_API void EndCacheScope(VtValue *cacheScopeData)=0
Mark the end of a resolution caching scope.
AR_API std::vector< TfType > ArGetAvailableResolvers()
Returns list of TfTypes for available ArResolver subclasses.
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_v1.h:47
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.
AR_API void ArSetPreferredResolver(const std::string &resolverTypeName)
Set the preferred ArResolver subclass used by ArGetResolver.
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.
virtual AR_API void ConfigureResolverForAsset(const std::string &path)=0
Configures the resolver for a given asset path.
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 bool CreatePathForLayer(const std::string &path)=0
Create path needed to write a file to the given path.
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.
TfType represents a dynamic runtime type.
Definition: type.h:64
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...
AR_API std::unique_ptr< ArResolver > ArCreateResolver(const TfType &resolverType)
Construct an instance of the ArResolver subclass specified by resolverType.
Provides a container which may hold any type, and provides introspection and iteration over array typ...
Definition: value.h:168
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_v1.h:57
Contains information about a resolved asset.
Definition: assetInfo.h:40