All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ArDefaultResolver Class Reference

Default asset resolution implementation used when no plugin implementation is provided. More...

+ Inheritance diagram for ArDefaultResolver:

Public Member Functions

virtual AR_API void ConfigureResolverForAsset (const std::string &path) override
 Sets the resolver's default context (returned by CreateDefaultContext()) to the same context you would get by calling CreateDefaultContextForAsset(). More...
 
virtual AR_API std::string AnchorRelativePath (const std::string &anchorPath, const std::string &path) override
 Returns the path formed by anchoring path to anchorPath. More...
 
virtual AR_API bool IsRelativePath (const std::string &path) override
 Returns true if the given path is a relative path. More...
 
virtual AR_API bool IsRepositoryPath (const std::string &path) override
 Returns true if the given path is a repository path. More...
 
virtual AR_API bool IsSearchPath (const std::string &path) override
 Returns whether this path is a search path. More...
 
virtual AR_API std::string GetExtension (const std::string &path) override
 Returns the normalized extension for the given path. More...
 
virtual AR_API std::string ComputeNormalizedPath (const std::string &path) override
 Returns a normalized version of the given path. More...
 
virtual AR_API std::string ComputeRepositoryPath (const std::string &path) override
 Returns the computed repository path using the current resolver. More...
 
virtual AR_API std::string ComputeLocalPath (const std::string &path) override
 Returns the local path for the given path. More...
 
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. More...
 
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 resolution behavior as in Resolve(const std::string&). More...
 
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 . More...
 
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. More...
 
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. More...
 
virtual AR_API std::shared_ptr
< ArAsset
OpenAsset (const std::string &resolvedPath) override
 Returns an ArAsset object for the asset located at resolvedPath. More...
 
virtual AR_API bool CreatePathForLayer (const std::string &path) override
 Create path needed to write a file to the given path. More...
 
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. More...
 
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. More...
 
virtual AR_API ArResolverContext CreateDefaultContext () override
 Return a default ArResolverContext that may be bound to this resolver to resolve assets when no other context is explicitly specified. More...
 
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, when the resulting context is bound (. More...
 
virtual AR_API void RefreshContext (const ArResolverContext &context) override
 Refresh any caches associated with the given context. More...
 
virtual AR_API ArResolverContext GetCurrentContext () override
 Returns the currently-bound asset resolver context. More...
 
virtual AR_API void BeginCacheScope (VtValue *cacheScopeData) override
 Mark the start of a resolution caching scope. More...
 
virtual AR_API void EndCacheScope (VtValue *cacheScopeData) override
 Mark the end of a resolution caching scope. More...
 
virtual AR_API void BindContext (const ArResolverContext &context, VtValue *bindingData) override
 Binds the given context to this resolver. More...
 
virtual AR_API void UnbindContext (const ArResolverContext &context, VtValue *bindingData) override
 Unbind the given context from this resolver. More...
 
- Public Member Functions inherited from ArResolver
 ArResolver (const ArResolver &)=delete
 
ArResolveroperator= (const ArResolver &)=delete
 

Static Public Member Functions

static AR_API void SetDefaultSearchPath (const std::vector< std::string > &searchPath)
 Set the default search path that will be used during asset resolution. More...
 

Detailed Description

Default asset resolution implementation used when no plugin implementation is provided.

In order to resolve assets specified by relative paths, this resolver implements a simple "search path" scheme. The resolver will anchor the relative path to a series of directories and return the first absolute path where the asset exists.

The first directory will always be the current working directory. The resolver will then examine the directories specified via the following mechanisms (in order):

Definition at line 67 of file defaultResolver_v1.h.

Member Function Documentation

virtual AR_API std::string AnchorRelativePath ( const std::string &  anchorPath,
const std::string &  path 
)
overridevirtual

Returns the path formed by anchoring path to anchorPath.

If anchorPath ends with a trailing '/', it is treated as a directory to which path will be anchored. Otherwise, it is treated as a file and path will be anchored to its containing directory.

If anchorPath is empty, path will be returned as-is.

If path is empty or not a relative path, it will be returned as-is.

Implements ArResolver.

virtual AR_API void BeginCacheScope ( VtValue cacheScopeData)
overridevirtual

Mark the start of a resolution caching scope.

Clients should generally use ArResolverScopedCache instead of calling this function directly.

Resolvers may fill cacheScopeData with arbitrary data. Clients may also pass in a cacheScopeData populated by an earlier call to BeginCacheScope to allow the resolver access to that information.

See Also
ArResolverScopedCache

Implements ArResolver.

virtual AR_API void BindContext ( const ArResolverContext context,
VtValue bindingData 
)
overridevirtual

Binds the given context to this resolver.

Clients should generally use ArResolverContextBinder instead of calling this function directly.

See Also
ArResolverContextBinder

Implements ArResolver.

virtual AR_API bool CanCreateNewLayerWithIdentifier ( const std::string &  identifier,
std::string *  whyNot 
)
overridevirtual

Returns true if a new file may be created using the given identifier, false otherwise.

If this function returns false and whyNot is not nullptr, it will be filled in with an explanation.

Implements ArResolver.

virtual AR_API bool CanWriteLayerToPath ( const std::string &  path,
std::string *  whyNot 
)
overridevirtual

Returns true if a file may be written to the given path, false otherwise.

In practice, when writing a layer, CanWriteLayerToPath will be called first to check if writing is permitted. If this returns true, then CreatePathForLayer will be called before writing the layer out.

If this function returns false and whyNot is not nullptr, it will be filled in with an explanation.

Implements ArResolver.

virtual AR_API std::string ComputeLocalPath ( const std::string &  path)
overridevirtual

Returns the local path for the given path.

Implements ArResolver.

virtual AR_API std::string ComputeNormalizedPath ( const std::string &  path)
overridevirtual

Returns a normalized version of the given path.

Implements ArResolver.

virtual AR_API std::string ComputeRepositoryPath ( const std::string &  path)
overridevirtual

Returns the computed repository path using the current resolver.

Implements ArResolver.

virtual AR_API void ConfigureResolverForAsset ( const std::string &  path)
overridevirtual

Sets the resolver's default context (returned by CreateDefaultContext()) to the same context you would get by calling CreateDefaultContextForAsset().

Has no other effect on the resolver's configuration.

Implements ArResolver.

virtual AR_API ArResolverContext CreateDefaultContext ( )
overridevirtual

Return a default ArResolverContext that may be bound to this resolver to resolve assets when no other context is explicitly specified.

This function should not automatically bind this context, but should create one that may be used later.

Implements ArResolver.

virtual AR_API ArResolverContext CreateDefaultContextForAsset ( const std::string &  filePath)
overridevirtual

Creates a context that adds the directory containing filePath as a first directory to be searched, when the resulting context is bound (.

See Also
ArResolverContextBinder).

If filePath is empty, returns an empty context; otherwise, if filePath is not an absolute filesystem path, it will first be anchored to the process's current working directory.

Implements ArResolver.

virtual AR_API bool CreatePathForLayer ( const std::string &  path)
overridevirtual

Create path needed to write a file to the given path.

For example:

  • A filesystem-based resolver might create the directories specified in path.
  • A database-based resolver might create a new table, or it might ignore this altogether.

In practice, when writing a layer, CanWriteLayerToPath will be called first to check if writing is permitted. If this returns true, then CreatePathForLayer will be called before writing the layer out.

Returns true on success, false otherwise.

Implements ArResolver.

virtual AR_API void EndCacheScope ( VtValue cacheScopeData)
overridevirtual

Mark the end of a resolution caching scope.

Clients should generally use ArResolverScopedCache instead of calling this function directly.

cacheScopeData should contain the data that was populated by the previous corresponding call to BeginCacheScope.

See Also
ArResolverScopedCache

Implements ArResolver.

virtual AR_API bool FetchToLocalResolvedPath ( const std::string &  path,
const std::string &  resolvedPath 
)
overridevirtual

Fetch the asset identified by path to the filesystem location specified by resolvedPath.

resolvedPath is the resolved path that results from calling Resolve or ResolveWithAssetInfo on path.

This method provides a way for consumers that expect assets to exist as physical files on disk to retrieve data from systems that store data in external data stores, e.g. databases, etc.

Returns true if the asset was successfully fetched to the specified resolvedPath or if no fetching was required. If resolvedPath is not a local path or the asset could not be fetched to that path, returns false.

Implements ArResolver.

virtual AR_API ArResolverContext GetCurrentContext ( )
overridevirtual

Returns the currently-bound asset resolver context.

See Also
ArResolver::BindContext, ArResolver::UnbindContext

Implements ArResolver.

virtual AR_API std::string GetExtension ( const std::string &  path)
overridevirtual

Returns the normalized extension for the given path.

Implements ArResolver.

virtual AR_API VtValue GetModificationTimestamp ( const std::string &  path,
const std::string &  resolvedPath 
)
overridevirtual

Returns a value representing the last time the asset identified by path was modified.

resolvedPath is the resolved path of the asset.

Implementations may use whatever value is most appropriate for this timestamp. The value must be equality comparable, and this function must return a different timestamp whenever an asset has been modified. For instance, if an asset is stored as a file on disk, the timestamp may simply be that file's mtime.

If a timestamp cannot be retrieved, returns an empty VtValue.

Implements ArResolver.

virtual AR_API bool IsRelativePath ( const std::string &  path)
overridevirtual

Returns true if the given path is a relative path.

Implements ArResolver.

virtual AR_API bool IsRepositoryPath ( const std::string &  path)
overridevirtual

Returns true if the given path is a repository path.

Implements ArResolver.

virtual AR_API bool IsSearchPath ( const std::string &  path)
overridevirtual

Returns whether this path is a search path.

Implements ArResolver.

virtual AR_API std::shared_ptr<ArAsset> OpenAsset ( const std::string &  resolvedPath)
overridevirtual

Returns an ArAsset object for the asset located at resolvedPath.

Returns an invalid std::shared_ptr if object could not be created.

The returned ArAsset object provides functions for accessing the contents of the specified asset.

Note that clients may still be using the data associated with this object even after the last shared_ptr has been destroyed. For example, a client may have created a memory mapping using the FILE* presented in the ArAsset object; this would preclude truncating or overwriting any of the contents of that file.

Implements ArResolver.

virtual AR_API void RefreshContext ( const ArResolverContext context)
overridevirtual

Refresh any caches associated with the given context.

Implements ArResolver.

virtual AR_API std::string Resolve ( const std::string &  path)
overridevirtual

Returns the resolved filesystem path for the file identified by the given path if it exists.

If the file does not exist, returns an empty string.

Implements ArResolver.

virtual AR_API std::string ResolveWithAssetInfo ( const std::string &  path,
ArAssetInfo assetInfo 
)
overridevirtual

Returns the resolved filesystem path for the file identified by path following the same path resolution behavior as in Resolve(const std::string&).

If the file identified by path represents an asset and assetInfo is not nullptr, the resolver should populate assetInfo with whatever additional metadata it knows or can reasonably compute about the asset without actually opening it.

See Also
Resolve(const std::string&).

Implements ArResolver.

static AR_API void SetDefaultSearchPath ( const std::vector< std::string > &  searchPath)
static

Set the default search path that will be used during asset resolution.

This must be called before the first call to ArGetResolver. The specified paths will be searched in addition to, and before paths specified via the environment variable PXR_AR_DEFAULT_SEARCH_PATH

virtual AR_API void UnbindContext ( const ArResolverContext context,
VtValue bindingData 
)
overridevirtual

Unbind the given context from this resolver.

Clients should generally use ArResolverContextBinder instead of calling this function directly.

See Also
ArResolverContextBinder

Implements ArResolver.

virtual AR_API void UpdateAssetInfo ( const std::string &  identifier,
const std::string &  filePath,
const std::string &  fileVersion,
ArAssetInfo assetInfo 
)
overridevirtual

Update assetInfo with respect to the given fileVersion .

Note
This API is currently in flux. In general, you should prefer to call ResolveWithAssetInfo()

Implements ArResolver.


The documentation for this class was generated from the following file: