7 #ifndef RETDEC_LLVMIR2HLL_SUPPORT_CACHING_H
8 #define RETDEC_LLVMIR2HLL_SUPPORT_CACHING_H
10 #include <unordered_map>
49 template<
typename CachedKey,
typename CachedValue,
50 typename HashFunc = std::hash<CachedKey>>
103 void addToCache(
const CachedKey &key,
const CachedValue &value) {
120 auto it =
cache.find(key);
121 if (it !=
cache.end()) {
136 using Cache = std::unordered_map<CachedKey, CachedValue, HashFunc>;
A mixin for enabling caching of computed results.
Definition: caching.h:51
Cache cache
Cache for storing cached results.
Definition: caching.h:143
void enableCaching()
Enables caching.
Definition: caching.h:60
void clearCache()
Clears the cache of the already cached results.
Definition: caching.h:78
void disableCaching()
Disables caching.
Definition: caching.h:70
bool isCachingEnabled() const
Returns true if caching is enabled, false otherwise.
Definition: caching.h:95
Caching(bool enableCaching)
Definition: caching.h:53
bool getCachedResult(const CachedKey &key, CachedValue &value) const
If caching is enabled, stores the value associated with key into value.
Definition: caching.h:118
std::unordered_map< CachedKey, CachedValue, HashFunc > Cache
Container for storing cached results.
Definition: caching.h:136
void removeFromCache(const CachedKey &key)
Removes the value corresponding to the given key from the cache.
Definition: caching.h:88
bool cachingEnabled
Is caching enabled?
Definition: caching.h:140
void addToCache(const CachedKey &key, const CachedValue &value)
If caching is enabled, associates the given value with key.
Definition: caching.h:103
A library providing API for working with back-end IR.
Definition: archive_wrapper.h:19