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

#include <defaultResolver.h>

+ Inheritance diagram for ArDefaultResolver:

Public Member Functions

AR_API ArDefaultResolver ()
 
virtual AR_API ~ArDefaultResolver ()
 
- Public Member Functions inherited from ArResolver
virtual AR_API ~ArResolver ()
 
 ArResolver (const ArResolver &)=delete
 
ArResolveroperator= (const ArResolver &)=delete
 
AR_API std::string CreateIdentifier (const std::string &assetPath, const ArResolvedPath &anchorAssetPath=ArResolvedPath()) const
 
AR_API std::string CreateIdentifierForNewAsset (const std::string &assetPath, const ArResolvedPath &anchorAssetPath=ArResolvedPath()) const
 
AR_API ArResolvedPath Resolve (const std::string &assetPath) const
 
AR_API ArResolvedPath ResolveForNewAsset (const std::string &assetPath) const
 
AR_API void BindContext (const ArResolverContext &context, VtValue *bindingData)
 
AR_API void UnbindContext (const ArResolverContext &context, VtValue *bindingData)
 
AR_API ArResolverContext CreateDefaultContext () const
 
AR_API ArResolverContext CreateDefaultContextForAsset (const std::string &assetPath) const
 
AR_API ArResolverContext CreateContextFromString (const std::string &contextStr) const
 
AR_API ArResolverContext CreateContextFromString (const std::string &uriScheme, const std::string &contextStr) const
 
AR_API ArResolverContext CreateContextFromStrings (const std::vector< std::pair< std::string, std::string >> &contextStrs) const
 
AR_API void RefreshContext (const ArResolverContext &context)
 
AR_API ArResolverContext GetCurrentContext () const
 
AR_API bool IsContextDependentPath (const std::string &assetPath) const
 
AR_API void BeginCacheScope (VtValue *cacheScopeData)
 
AR_API void EndCacheScope (VtValue *cacheScopeData)
 
AR_API bool IsRepositoryPath (const std::string &path) const
 
AR_API std::string GetExtension (const std::string &assetPath) const
 
AR_API ArAssetInfo GetAssetInfo (const std::string &assetPath, const ArResolvedPath &resolvedPath) const
 
AR_API ArTimestamp GetModificationTimestamp (const std::string &assetPath, const ArResolvedPath &resolvedPath) const
 
AR_API std::shared_ptr< ArAssetOpenAsset (const ArResolvedPath &resolvedPath) const
 
AR_API std::shared_ptr
< ArWritableAsset
OpenAssetForWrite (const ArResolvedPath &resolvedPath, WriteMode writeMode) const
 
AR_API bool CanWriteAssetToPath (const ArResolvedPath &resolvedPath, std::string *whyNot=nullptr) const
 

Static Public Member Functions

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

Protected Member Functions

AR_API std::string _CreateIdentifier (const std::string &assetPath, const ArResolvedPath &anchorAssetPath) const override
 
AR_API std::string _CreateIdentifierForNewAsset (const std::string &assetPath, const ArResolvedPath &anchorAssetPath) const override
 
AR_API ArResolvedPath _Resolve (const std::string &assetPath) const override
 
AR_API ArResolvedPath _ResolveForNewAsset (const std::string &assetPath) const override
 
AR_API ArResolverContext _CreateDefaultContext () const override
 
AR_API ArResolverContext _CreateDefaultContextForAsset (const std::string &assetPath) const override
 
AR_API ArResolverContext _CreateContextFromString (const std::string &contextStr) const override
 
AR_API bool _IsContextDependentPath (const std::string &assetPath) const override
 
AR_API ArTimestamp _GetModificationTimestamp (const std::string &path, const ArResolvedPath &resolvedPath) const override
 
AR_API std::shared_ptr< ArAsset_OpenAsset (const ArResolvedPath &resolvedPath) const override
 
AR_API std::shared_ptr
< ArWritableAsset
_OpenAssetForWrite (const ArResolvedPath &resolvedPath, WriteMode writeMode) const override
 
- Protected Member Functions inherited from ArResolver
AR_API ArResolver ()
 
virtual AR_API bool _IsRepositoryPath (const std::string &path) const
 
virtual AR_API void _BindContext (const ArResolverContext &context, VtValue *bindingData)
 
virtual AR_API void _UnbindContext (const ArResolverContext &context, VtValue *bindingData)
 
virtual AR_API void _RefreshContext (const ArResolverContext &context)
 
virtual AR_API ArResolverContext _GetCurrentContext () const
 
virtual AR_API std::string _GetExtension (const std::string &assetPath) const
 
virtual AR_API ArAssetInfo _GetAssetInfo (const std::string &assetPath, const ArResolvedPath &resolvedPath) const
 
virtual AR_API bool _CanWriteAssetToPath (const ArResolvedPath &resolvedPath, std::string *whyNot) const
 
virtual AR_API void _BeginCacheScope (VtValue *cacheScopeData)
 
virtual AR_API void _EndCacheScope (VtValue *cacheScopeData)
 
template<class ContextObj >
const ContextObj * _GetCurrentContextObject () const
 
abs path to model * ArResolvedPath ("/abs/path/to/shot.usd"))*
 

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):

ArDefaultResolver supports creating an ArDefaultResolverContext via ArResolver::CreateContextFromString by passing a list of directories delimited by the platform's standard path separator.

Definition at line 64 of file defaultResolver.h.

Constructor & Destructor Documentation

AR_API ArDefaultResolver::ArDefaultResolver ( )
virtual AR_API ArDefaultResolver::~ArDefaultResolver ( )
virtual

Member Function Documentation

AR_API ArResolverContext ArDefaultResolver::_CreateContextFromString ( const std::string contextStr) const
overrideprotectedvirtual

Creates an ArDefaultResolverContext from contextStr. This string is expected to be a list of directories delimited by the platform's standard path separator.

Reimplemented from ArResolver.

AR_API ArResolverContext ArDefaultResolver::_CreateDefaultContext ( ) const
overrideprotectedvirtual

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

When CreateDefaultContext is called on the configured asset resolver, Ar will call this method on the primary resolver and all URI/IRI resolvers and merge the results into a single ArResolverContext that will be returned to the consumer.

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

The default implementation returns a default-constructed ArResolverContext.

Example uses:

  • UsdStage will call CreateDefaultContext when creating a new stage with an anonymous root layer and without a given context. The returned context will be bound when resolving asset paths on that stage.

Reimplemented from ArResolver.

AR_API ArResolverContext ArDefaultResolver::_CreateDefaultContextForAsset ( const std::string assetPath) const
overrideprotectedvirtual

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

See Also
ArResolverContextBinder).

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

Reimplemented from ArResolver.

AR_API std::string ArDefaultResolver::_CreateIdentifier ( const std::string assetPath,
const ArResolvedPath anchorAssetPath 
) const
overrideprotected
AR_API std::string ArDefaultResolver::_CreateIdentifierForNewAsset ( const std::string assetPath,
const ArResolvedPath anchorAssetPath 
) const
overrideprotectedvirtual

Return an identifier for a new asset at the given assetPath.

This is similar to _CreateIdentifier but is used to create identifiers for assets that may not exist yet and are being created.

Example uses:

  • When creating a new layer via SdfLayer::CreateNew, CreateIdentifierForNewAsset will be called with the asset path given to the function. The result will be used as the new layer's identifier.

Implements ArResolver.

AR_API ArTimestamp ArDefaultResolver::_GetModificationTimestamp ( const std::string assetPath,
const ArResolvedPath resolvedPath 
) const
overrideprotectedvirtual

Return an ArTimestamp representing the last time the asset at assetPath was modified. resolvedPath is the resolved path computed for the given assetPath. If a timestamp cannot be retrieved, return an invalid ArTimestamp.

The default implementation returns an invalid ArTimestamp.

Example uses:

  • SdfLayer will call GetModificationTimestamp when opening a layer and store the returned timestamp. When SdfLayer::Reload is called on that layer, this method will be called again. If the returned timestamp differs from the stored timestamp, or if it is invalid, the layer will be reloaded.

Reimplemented from ArResolver.

AR_API bool ArDefaultResolver::_IsContextDependentPath ( const std::string assetPath) const
overrideprotectedvirtual

Return true if the result of resolving the given assetPath may differ depending on the asset resolver context that is bound when Resolve is called, false otherwise.

The default implementation returns false.

Example uses:

  • SdfLayer will call this function to check if the identifier given to SdfLayer::Find or SdfLayer::FindOrOpen is context-dependent. If it is and a layer exists with the same identifier, SdfLayer can return it without resolving the identifier. If it is not, SdfLayer must resolve the identifier and search for a layer with the same resolved path, even if a layer exists with the same identifier.

Reimplemented from ArResolver.

AR_API std::shared_ptr<ArAsset> ArDefaultResolver::_OpenAsset ( const ArResolvedPath resolvedPath) const
overrideprotectedvirtual

Return an ArAsset object for the asset located at resolvedPath. Return an invalid std::shared_ptr if object could not be created (for example, if the asset at the given path could not be opened).

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.

AR_API std::shared_ptr<ArWritableAsset> ArDefaultResolver::_OpenAssetForWrite ( const ArResolvedPath resolvedPath,
WriteMode  writeMode 
) const
overrideprotectedvirtual

Creates an ArFilesystemWriteableAsset for the asset at the given resolvedPath.

Implements ArResolver.

AR_API ArResolvedPath ArDefaultResolver::_Resolve ( const std::string assetPath) const
overrideprotectedvirtual

Return the resolved path for the given assetPath or an empty ArResolvedPath if no asset exists at that path.

Implements ArResolver.

AR_API ArResolvedPath ArDefaultResolver::_ResolveForNewAsset ( const std::string assetPath) const
overrideprotectedvirtual

Return the resolved path for the given assetPath that may be used to create a new asset or an empty ArResolvedPath if such a path cannot be computed.

Implements ArResolver.

static AR_API void ArDefaultResolver::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


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