diff --git a/pxr/usd/lib/ar/CMakeLists.txt b/pxr/usd/lib/ar/CMakeLists.txt index 989d314e99..34c0618cd8 100644 --- a/pxr/usd/lib/ar/CMakeLists.txt +++ b/pxr/usd/lib/ar/CMakeLists.txt @@ -15,6 +15,7 @@ pxr_shared_library(ar PUBLIC_HEADERS api.h assetInfo.h + defaultResolver.h pyResolverContext.h resolver.h resolverContext.h @@ -25,7 +26,6 @@ pxr_shared_library(ar PRIVATE_HEADERS debugCodes.h - defaultResolver.h CPPFILES assetInfo.cpp diff --git a/pxr/usd/lib/ar/defaultResolver.cpp b/pxr/usd/lib/ar/defaultResolver.cpp index 73760b859b..dcf56b61a7 100644 --- a/pxr/usd/lib/ar/defaultResolver.cpp +++ b/pxr/usd/lib/ar/defaultResolver.cpp @@ -41,14 +41,14 @@ _IsFileRelative(const std::string& path) { } -struct Ar_DefaultResolver::_Cache +struct ArDefaultResolver::_Cache { using _PathToResolvedPathMap = tbb::concurrent_hash_map; _PathToResolvedPathMap _pathToResolvedPathMap; }; -Ar_DefaultResolver::Ar_DefaultResolver() +ArDefaultResolver::ArDefaultResolver() { _searchPath.push_back(ArchGetCwd()); @@ -60,30 +60,30 @@ Ar_DefaultResolver::Ar_DefaultResolver() } } -Ar_DefaultResolver::~Ar_DefaultResolver() +ArDefaultResolver::~ArDefaultResolver() { } void -Ar_DefaultResolver::ConfigureResolverForAsset(const std::string& path) +ArDefaultResolver::ConfigureResolverForAsset(const std::string& path) { // no configuration takes place in search path resolver } bool -Ar_DefaultResolver::IsRelativePath(const std::string& path) +ArDefaultResolver::IsRelativePath(const std::string& path) { return (not path.empty() and path[0] != '/'); } bool -Ar_DefaultResolver::IsRepositoryPath(const std::string& path) +ArDefaultResolver::IsRepositoryPath(const std::string& path) { return false; } std::string -Ar_DefaultResolver::AnchorRelativePath( +ArDefaultResolver::AnchorRelativePath( const std::string& anchorPath, const std::string& path) { @@ -100,25 +100,25 @@ Ar_DefaultResolver::AnchorRelativePath( } bool -Ar_DefaultResolver::IsSearchPath(const std::string& path) +ArDefaultResolver::IsSearchPath(const std::string& path) { return IsRelativePath(path) and not _IsFileRelative(path); } std::string -Ar_DefaultResolver::GetExtension(const std::string& path) +ArDefaultResolver::GetExtension(const std::string& path) { return TfGetExtension(path); } std::string -Ar_DefaultResolver::ComputeNormalizedPath(const std::string& path) +ArDefaultResolver::ComputeNormalizedPath(const std::string& path) { return TfNormPath(path); } std::string -Ar_DefaultResolver::ComputeRepositoryPath(const std::string& path) +ArDefaultResolver::ComputeRepositoryPath(const std::string& path) { return std::string(); } @@ -144,7 +144,7 @@ _Resolve( } std::string -Ar_DefaultResolver::_ResolveNoCache(const std::string& path) +ArDefaultResolver::_ResolveNoCache(const std::string& path) { if (path.empty()) { return path; @@ -176,13 +176,13 @@ Ar_DefaultResolver::_ResolveNoCache(const std::string& path) } std::string -Ar_DefaultResolver::Resolve(const std::string& path) +ArDefaultResolver::Resolve(const std::string& path) { return ResolveWithAssetInfo(path, /* assetInfo = */ nullptr); } std::string -Ar_DefaultResolver::ResolveWithAssetInfo( +ArDefaultResolver::ResolveWithAssetInfo( const std::string& path, ArAssetInfo* assetInfo) { @@ -203,13 +203,13 @@ Ar_DefaultResolver::ResolveWithAssetInfo( } std::string -Ar_DefaultResolver::ComputeLocalPath(const std::string& path) +ArDefaultResolver::ComputeLocalPath(const std::string& path) { return path.empty() ? path : TfAbsPath(path); } void -Ar_DefaultResolver::UpdateAssetInfo( +ArDefaultResolver::UpdateAssetInfo( const std::string& identifier, const std::string& filePath, const std::string& fileVersion, @@ -223,7 +223,7 @@ Ar_DefaultResolver::UpdateAssetInfo( } bool -Ar_DefaultResolver::CanWriteLayerToPath( +ArDefaultResolver::CanWriteLayerToPath( const std::string& path, std::string* whyNot) { @@ -231,7 +231,7 @@ Ar_DefaultResolver::CanWriteLayerToPath( } bool -Ar_DefaultResolver::CanCreateNewLayerWithIdentifier( +ArDefaultResolver::CanCreateNewLayerWithIdentifier( const std::string& identifier, std::string* whyNot) { @@ -239,38 +239,38 @@ Ar_DefaultResolver::CanCreateNewLayerWithIdentifier( } ArResolverContext -Ar_DefaultResolver::CreateDefaultContext() +ArDefaultResolver::CreateDefaultContext() { return ArResolverContext(); } ArResolverContext -Ar_DefaultResolver::CreateDefaultContextForAsset( +ArDefaultResolver::CreateDefaultContextForAsset( const std::string& filePath) { return ArResolverContext(); } ArResolverContext -Ar_DefaultResolver::CreateDefaultContextForDirectory( +ArDefaultResolver::CreateDefaultContextForDirectory( const std::string& fileDirectory) { return ArResolverContext(); } void -Ar_DefaultResolver::RefreshContext(const ArResolverContext& context) +ArDefaultResolver::RefreshContext(const ArResolverContext& context) { } ArResolverContext -Ar_DefaultResolver::GetCurrentContext() +ArDefaultResolver::GetCurrentContext() { return ArResolverContext(); } void -Ar_DefaultResolver::_BeginCacheScope( +ArDefaultResolver::_BeginCacheScope( VtValue* cacheScopeData) { // cacheScopeData is held by ArResolverScopedCache instances @@ -300,7 +300,7 @@ Ar_DefaultResolver::_BeginCacheScope( } void -Ar_DefaultResolver::_EndCacheScope( +ArDefaultResolver::_EndCacheScope( VtValue* cacheScopeData) { _CachePtrStack& cacheStack = _threadCacheStack.local(); @@ -309,22 +309,22 @@ Ar_DefaultResolver::_EndCacheScope( } } -Ar_DefaultResolver::_CachePtr -Ar_DefaultResolver::_GetCurrentCache() +ArDefaultResolver::_CachePtr +ArDefaultResolver::_GetCurrentCache() { _CachePtrStack& cacheStack = _threadCacheStack.local(); return (cacheStack.empty() ? _CachePtr() : cacheStack.back()); } void -Ar_DefaultResolver::_BindContext( +ArDefaultResolver::_BindContext( const ArResolverContext& context, VtValue* bindingData) { } void -Ar_DefaultResolver::_UnbindContext( +ArDefaultResolver::_UnbindContext( const ArResolverContext& context, VtValue* bindingData) { diff --git a/pxr/usd/lib/ar/defaultResolver.h b/pxr/usd/lib/ar/defaultResolver.h index 4f87dcbf44..97f30f64c9 100644 --- a/pxr/usd/lib/ar/defaultResolver.h +++ b/pxr/usd/lib/ar/defaultResolver.h @@ -32,7 +32,7 @@ #include #include -/// \class Ar_DefaultResolver +/// \class ArDefaultResolver /// /// Default asset resolution implementation used when no plugin /// implementation is provided. @@ -47,78 +47,78 @@ /// PXR_AR_DEFAULT_SEARCH_PATH environment variable to a list of /// directories delimited by ':'. /// -class Ar_DefaultResolver +class ArDefaultResolver : public ArResolver { public: - Ar_DefaultResolver(); - virtual ~Ar_DefaultResolver(); + ArDefaultResolver(); + virtual ~ArDefaultResolver(); // ArResolver overrides - virtual void ConfigureResolverForAsset(const std::string& path); + virtual void ConfigureResolverForAsset(const std::string& path) override; virtual std::string AnchorRelativePath( const std::string& anchorPath, - const std::string& path); + const std::string& path) override; - virtual bool IsRelativePath(const std::string& path); - virtual bool IsRepositoryPath(const std::string& path); - virtual bool IsSearchPath(const std::string& path); + virtual bool IsRelativePath(const std::string& path) override; + virtual bool IsRepositoryPath(const std::string& path) override; + virtual bool IsSearchPath(const std::string& path) override; - virtual std::string GetExtension(const std::string& path); + virtual std::string GetExtension(const std::string& path) override; - virtual std::string ComputeNormalizedPath(const std::string& path); + virtual std::string ComputeNormalizedPath(const std::string& path) override; - virtual std::string ComputeRepositoryPath(const std::string& path); + virtual std::string ComputeRepositoryPath(const std::string& path) override; - virtual std::string ComputeLocalPath(const std::string& path); + virtual std::string ComputeLocalPath(const std::string& path) override; - virtual std::string Resolve(const std::string& path); + virtual std::string Resolve(const std::string& path) override; virtual std::string ResolveWithAssetInfo( const std::string& path, - ArAssetInfo* assetInfo); + ArAssetInfo* assetInfo) override; virtual void UpdateAssetInfo( const std::string& identifier, const std::string& filePath, const std::string& fileVersion, - ArAssetInfo* assetInfo); + ArAssetInfo* assetInfo) override; virtual bool CanWriteLayerToPath( const std::string& path, - std::string* whyNot); + std::string* whyNot) override; virtual bool CanCreateNewLayerWithIdentifier( const std::string& identifier, - std::string* whyNot); + std::string* whyNot) override; - virtual ArResolverContext CreateDefaultContext(); + virtual ArResolverContext CreateDefaultContext() override; virtual ArResolverContext CreateDefaultContextForAsset( - const std::string& filePath); + const std::string& filePath) override; virtual ArResolverContext CreateDefaultContextForDirectory( - const std::string& fileDirectory); + const std::string& fileDirectory) override; - virtual void RefreshContext(const ArResolverContext& context); + virtual void RefreshContext(const ArResolverContext& context) override; - virtual ArResolverContext GetCurrentContext(); + virtual ArResolverContext GetCurrentContext() override; protected: virtual void _BeginCacheScope( - VtValue* cacheScopeData); + VtValue* cacheScopeData) override; virtual void _EndCacheScope( - VtValue* cacheScopeData); + VtValue* cacheScopeData) override; virtual void _BindContext( const ArResolverContext& context, - VtValue* bindingData); + VtValue* bindingData) override; virtual void _UnbindContext( const ArResolverContext& context, - VtValue* bindingData); + VtValue* bindingData) override; private: struct _Cache; diff --git a/pxr/usd/lib/ar/overview.dox b/pxr/usd/lib/ar/overview.dox index 5e072cd9ec..2964f877bb 100644 --- a/pxr/usd/lib/ar/overview.dox +++ b/pxr/usd/lib/ar/overview.dox @@ -21,7 +21,7 @@ and over again, we also provide an RAII ArResolverScopedCache that can greatly speed up asset resolution by caching results. Finally, if no custom implementation of ArResolver is found, we will fall back -to a Ar_DefaultResolver, which performs simple searchpath-based +to a ArDefaultResolver, which performs simple searchpath-based resolution, based on an environment variable PXR_AR_DEFAULT_SEARCH_PATH that is expected to hold a colon-separated list of filesystem paths to search. diff --git a/pxr/usd/lib/ar/resolver.cpp b/pxr/usd/lib/ar/resolver.cpp index 7863dfb873..60670379f3 100644 --- a/pxr/usd/lib/ar/resolver.cpp +++ b/pxr/usd/lib/ar/resolver.cpp @@ -88,7 +88,7 @@ namespace struct _ResolverHolder { _ResolverHolder() - : resolver(new Ar_DefaultResolver) + : resolver(new ArDefaultResolver) { if (TfGetEnvSetting(PXR_AR_DISABLE_PLUGIN_RESOLVER)) { TF_DEBUG(AR_RESOLVER_INIT).Msg(