All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ArPackageResolver Class Referenceabstract

Interface for resolving assets within package assets. More...

Inherited by Usd_UsdzResolver.

Public Member Functions

 ArPackageResolver (const ArPackageResolver &)=delete
 
ArPackageResolveroperator= (const ArPackageResolver &)=delete
 
Packaged Path Resolution Operations
virtual AR_API std::string Resolve (const std::string &resolvedPackagePath, const std::string &packagedPath)=0
 Returns the resolved path for the asset located at packagedPath in the package specified by resolvedPackagePath if it exists. More...
 
Asset-specific Operations
virtual AR_API std::shared_ptr
< ArAsset
OpenAsset (const std::string &resolvedPackagePath, const std::string &resolvedPackagedPath)=0
 Returns an ArAsset object for the asset at resolvedPackagedPath located in the package asset at resolvedPackagePath. More...
 

Scoped Resolution Cache

These functions are called when scoped resolution caches are enabled via ArResolver.

See Also
Scoped Resolution Cache
virtual AR_API void BeginCacheScope (VtValue *cacheScopeData)=0
 Mark the start of a resolution caching scope. More...
 
virtual AR_API void EndCacheScope (VtValue *cacheScopeData)=0
 Mark the end of a resolution caching scope. More...
 
AR_API ArPackageResolver ()
 

Detailed Description

Interface for resolving assets within package assets.

A package resolver is responsible for processing particular package asset formats and resolving information about assets stored within that package.

Each package resolver is associated with particular file formats and is invoked by asset resolution when handling package-relative paths involving those formats. ArPackageResolver instances are only used internally by Ar and are not directly exposed to clients.

Implementing a Package Resolver

To implement a package resolver, users must create a plugin containing a subclass of ArPackageResolver and register it with the plugin system so that it can be discovered and instantiated at runtime.

  • Implement an ArPackageResolver subclass
    * class CustomPackageResolver : public ArPackageResolver {
    * // ...
    * }
    *
  • In its implementation, register the ArPackageResolver subclass using AR_DEFINE_PACKAGE_RESOLVER
    * # custom resolver's .cpp file
    * AR_DEFINE_PACKAGE_RESOLVER(CustomPackageResolver, ArPackageResolver);
    *
  • Declare the ArPackageResolver subclass in the plugin's plugInfo.json file. Note that the entry for the subclass must declare the file format it handles in the 'extensions' metadata.
    * # plugInfo.json
    * {
    * "Plugins": [
    * {
    * "Info": {
    * "Types" : {
    * "CustomPackageResolver" : {
    * "bases": [ "ArPackageResolver" ],
    * "extensions": [ "pack" ]
    * }
    * }
    * },
    * ...
    * },
    * ...
    * ]
    *
    * }
    *

Definition at line 95 of file packageResolver.h.

Member Function Documentation

virtual AR_API void BeginCacheScope ( VtValue cacheScopeData)
pure virtual

Mark the start of a resolution caching scope.

See Also
ArResolver::BeginCacheScope
virtual AR_API void EndCacheScope ( VtValue cacheScopeData)
pure virtual

Mark the end of a resolution caching scope.

See Also
ArResolver::EndCacheScope
virtual AR_API std::shared_ptr<ArAsset> OpenAsset ( const std::string &  resolvedPackagePath,
const std::string &  resolvedPackagedPath 
)
pure virtual

Returns an ArAsset object for the asset at resolvedPackagedPath located in the package asset at resolvedPackagePath.

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

See Also
ArResolver::OpenAsset
virtual AR_API std::string Resolve ( const std::string &  resolvedPackagePath,
const std::string &  packagedPath 
)
pure virtual

Returns the resolved path for the asset located at packagedPath in the package specified by resolvedPackagePath if it exists.

If the asset does not exist in the package, returns an empty string.

When ArResolver::Resolve is invoked on a package-relative path, the path will be parsed into the outermost package path, and the inner packaged path. The outermost package path will be resolved by the primary resolver. ArPackageResolver::Resolve will then be called on the corresponding package resolver with that resolved path and the inner packaged path. If the inner packaged path is itself a package-relative path, this process recurses until all paths have been resolved.

See Also
ArResolver::Resolve

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