AYON Usd Resolver  0.1.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 <filesystem>
5#include <optional>
6#include <shared_mutex>
7#include <string>
8#include <unordered_map>
9
10#include "AyonCppApi.h"
11#include "../cache/assetIdentDef.h"
12#include <nlohmann/json.hpp>
13
15
17
19 public:
20 pinningFileHandler(const std::string &pinningFilePath,
21 const std::unordered_map<std::string, std::string> &rootReplaceData);
23
24 assetIdent getAssetData(const std::string &resolveKey);
25
26 private:
27 std::filesystem::path m_pinningFilePath;
28 nlohmann::json m_pinningFileData;
29
30 std::unordered_map<std::string, std::string> m_rootReplaceData;
31};
32
39 public:
42
50 void insert(assetIdent &sourceAssetIdent);
51
57
65 assetIdent getAsset(const std::string &assetIdentifier, const cacheName &selectedCache, const bool &isAyonPath);
66
72 void setCacheFromPinningFile(const std::string &pinningFilePath);
73
79 void removeCachedObject(const std::string &key);
80
88 void removeCachedObject(const std::string &key, const cacheName &selectedCache);
89
93 void clearCache();
94
98 void printCache() const;
99
100 bool isCacheStatic() const;
101
102 private:
103 std::unordered_set<assetIdent, assetIdentHash> m_PreCache;
104 std::unordered_set<assetIdent, assetIdentHash> m_AyonCache;
105 std::unordered_set<assetIdent, assetIdentHash> m_CommonCache;
106
107 mutable std::shared_mutex m_PreCachesharedMutex;
108 mutable std::shared_mutex m_AyonCachesharedMutex;
109 mutable std::shared_mutex m_CommonCachesharedMutex;
110
111 std::optional<AyonApi> m_ayon;
113
114 std::optional<pinningFileHandler> m_pinningFileHandler;
115};
116
117#endif // AR_AYONUSDRESOLVER_RESOLVER_CONTEXT_CACHE_H
cache element class used to represent an Usd asset in cache for the resolver
Definition: assetIdentDef.h:16
Definition: resolverContextCache.h:18
std::unordered_map< std::string, std::string > m_rootReplaceData
Definition: resolverContextCache.h:30
std::filesystem::path m_pinningFilePath
Definition: resolverContextCache.h:27
assetIdent getAssetData(const std::string &resolveKey)
return assetIdent populated with root rootReplaceData from the pinning file using the pinning file da...
Definition: resolverContextCache.cpp:66
~pinningFileHandler()=default
nlohmann::json m_pinningFileData
Definition: resolverContextCache.h:28
this class handles everything related to asset caching
Definition: resolverContextCache.h:38
bool isCacheStatic() const
Definition: resolverContextCache.cpp:367
std::optional< AyonApi > m_ayon
Definition: resolverContextCache.h:111
std::unordered_set< assetIdent, assetIdentHash > m_CommonCache
Definition: resolverContextCache.h:105
bool m_static_cache
Definition: resolverContextCache.h:112
void printCache() const
print out every object in the cache for debugging
Definition: resolverContextCache.cpp:112
std::optional< pinningFileHandler > m_pinningFileHandler
Definition: resolverContextCache.h:114
std::shared_mutex m_CommonCachesharedMutex
Definition: resolverContextCache.h:109
resolverContextCache()
Definition: resolverContextCache.cpp:88
void insert(assetIdent &sourceAssetIdent)
move the pair into the preCache by using the move operator it will also check if there is enough spac...
Definition: resolverContextCache.cpp:141
void migratePreCacheIntoAyonCache()
move the precache into the AyonCache in order to free the precache
Definition: resolverContextCache.cpp:155
assetIdent getAsset(const std::string &assetIdentifier, const cacheName &selectedCache, const bool &isAyonPath)
return a struct by first searching through the selected cacheName if no cache hit.
Definition: resolverContextCache.cpp:166
~resolverContextCache()
Definition: resolverContextCache.cpp:106
std::shared_mutex m_PreCachesharedMutex
Definition: resolverContextCache.h:107
void setCacheFromPinningFile(const std::string &pinningFilePath)
set up the cache from a pinning file
void removeCachedObject(const std::string &key)
this function allows the deletion of an entry in the cache
Definition: resolverContextCache.cpp:261
std::unordered_set< assetIdent, assetIdentHash > m_PreCache
Definition: resolverContextCache.h:103
std::unordered_set< assetIdent, assetIdentHash > m_AyonCache
Definition: resolverContextCache.h:104
std::shared_mutex m_AyonCachesharedMutex
Definition: resolverContextCache.h:108
void clearCache()
clear the complete cache
Definition: resolverContextCache.cpp:355
Definition: wrapResolverTokens.cpp:14
cacheName
Definition: resolverContextCache.h:16
@ COMMONCACHE
Definition: resolverContextCache.h:16
@ AYONCACHE
Definition: resolverContextCache.h:16