AYON Usd Resolver  1.0.0
Loading...
Searching...
No Matches
resolverContextCache.h
Go to the documentation of this file.
1#ifndef AR_AYONUSDRESOLVER_RESOLVER_CONTEXT_CACHE_H
2#define AR_AYONUSDRESOLVER_RESOLVER_CONTEXT_CACHE_H
3
4#include "../cache/assetIdentifierDef.h"
5#include "AyonCppApi.h"
6
7#include <nlohmann/json.hpp>
8
9#include <filesystem>
10#include <memory>
11#include <optional>
12#include <shared_mutex>
13#include <string>
14#include <unordered_map>
15
16PXR_NAMESPACE_USING_DIRECTIVE
17
19
21 public:
22 PinningFileHandler(const std::string &pinningFilePath,
23 const std::unordered_map<std::string, std::string> &rootReplaceData);
25
26 AssetIdentifier getAssetData(const std::string &resolveKey);
27
28 private:
29 std::filesystem::path m_pinningFilePath;
30 nlohmann::json m_pinningFileData;
31
32 std::unordered_map<std::string, std::string> m_rootReplaceData;
33};
34
35
41 public:
44
50 void insert(AssetIdentifier &sourceAssetIdent);
51
56
65 AssetIdentifier getAsset(const std::string &assetIdentifier, const CacheName selectedCache, const bool isAyonPath);
66
71 void setCacheFromPinningFile(const std::string &pinningFilePath);
72
77 void removeCachedObject(const std::string &key);
78
84 void removeCachedObject(const std::string &key, const CacheName selectedCache);
85
89 void ClearCache();
90
94 void printCache() const;
95
99 bool isCacheStatic() const;
100
101 private:
102 std::unordered_set<AssetIdentifier, AssetIdentifierHash> m_PreCache;
103 std::unordered_set<AssetIdentifier, AssetIdentifierHash> m_AyonCache;
104 std::unordered_set<AssetIdentifier, AssetIdentifierHash> m_CommonCache;
105
106 mutable std::shared_mutex m_PreCacheSharedMutex;
107 mutable std::shared_mutex m_AyonCacheSharedMutex;
108 mutable std::shared_mutex m_CommonCacheSharedMutex;
109
110 std::optional<std::unique_ptr<AyonApi>> m_ayon;
112
113 std::optional<PinningFileHandler> m_pinningFileHandler;
114};
115
116#endif // AR_AYONUSDRESOLVER_RESOLVER_CONTEXT_CACHE_H
cache element class used to represent an Usd asset in cache for the resolver
Definition: assetIdentifierDef.h:17
Definition: resolverContextCache.h:20
nlohmann::json m_pinningFileData
Definition: resolverContextCache.h:30
std::unordered_map< std::string, std::string > m_rootReplaceData
Definition: resolverContextCache.h:32
AssetIdentifier getAssetData(const std::string &resolveKey)
return AssetIdentifier populated with root rootReplaceData from the pinning file using the pinning fi...
Definition: resolverContextCache.cpp:68
~PinningFileHandler()=default
std::filesystem::path m_pinningFilePath
Definition: resolverContextCache.h:29
Handles everything related to asset caching.
Definition: resolverContextCache.h:40
void insert(AssetIdentifier &sourceAssetIdent)
Move the asset into the preCache.
Definition: resolverContextCache.cpp:142
void removeCachedObject(const std::string &key)
Delete an entry from the cache.
Definition: resolverContextCache.cpp:263
bool isCacheStatic() const
Check if cache is static (no dynamic resolution)
Definition: resolverContextCache.cpp:369
std::unordered_set< AssetIdentifier, AssetIdentifierHash > m_AyonCache
Definition: resolverContextCache.h:103
void printCache() const
Print every object in the cache for debugging.
Definition: resolverContextCache.cpp:113
bool m_staticCache
Definition: resolverContextCache.h:111
void migratePreCacheIntoAyonCache()
Move the precache into the AyonCache to free the precache.
Definition: resolverContextCache.cpp:156
std::shared_mutex m_AyonCacheSharedMutex
Definition: resolverContextCache.h:107
std::shared_mutex m_CommonCacheSharedMutex
Definition: resolverContextCache.h:108
ResolverContextCache()
Definition: resolverContextCache.cpp:87
std::unordered_set< AssetIdentifier, AssetIdentifierHash > m_CommonCache
Definition: resolverContextCache.h:104
~ResolverContextCache()
Definition: resolverContextCache.cpp:107
std::optional< PinningFileHandler > m_pinningFileHandler
Definition: resolverContextCache.h:113
std::optional< std::unique_ptr< AyonApi > > m_ayon
Definition: resolverContextCache.h:110
std::unordered_set< AssetIdentifier, AssetIdentifierHash > m_PreCache
Definition: resolverContextCache.h:102
std::shared_mutex m_PreCacheSharedMutex
Definition: resolverContextCache.h:106
void ClearCache()
Clear the complete cache.
Definition: resolverContextCache.cpp:357
void setCacheFromPinningFile(const std::string &pinningFilePath)
Set up the cache from a pinning file.
AssetIdentifier getAsset(const std::string &assetIdentifier, const CacheName selectedCache, const bool isAyonPath)
Return an asset by searching the selected cache.
Definition: resolverContextCache.cpp:167
CacheName
Definition: resolverContextCache.h:18