CatapultServer  v0.5.0.1 (Elephant)
src/catapult/cache/CacheStorageInclude.h
Go to the documentation of this file.
1 
21 #pragma once
22 #include <utility>
23 
24 namespace catapult {
25  namespace io {
26  class InputStream;
27  class OutputStream;
28  }
29 }
30 
31 namespace catapult { namespace cache {
32 
34  template<typename TDescriptor>
37  using SourceType = typename TDescriptor::CacheViewType;
38 
40  using DestinationType = typename TDescriptor::CacheDeltaType;
41 
43  using KeyType = typename TDescriptor::KeyType;
44 
46  using ValueType = typename TDescriptor::ValueType;
47  };
48 
50  template<typename TDescriptor>
53  static void LoadInto(const typename TDescriptor::ValueType& value, typename TDescriptor::CacheDeltaType& cacheDelta) {
54  cacheDelta.insert(value);
55  }
56 
58  static void Purge(const typename TDescriptor::ValueType& value, typename TDescriptor::CacheDeltaType& cacheDelta) {
59  auto key = TDescriptor::GetKeyFromValue(value);
60  if (cacheDelta.contains(key))
61  cacheDelta.remove(key);
62  }
63  };
64 }}
catapult::cache::CacheStorageForBasicInsertRemoveCache
Defines cache storage for cache with basic insert remove support.
Definition: src/catapult/cache/CacheStorageInclude.h:51
catapult::cache::CacheStorageForBasicInsertRemoveCache::LoadInto
static void LoadInto(const typename TDescriptor::ValueType &value, typename TDescriptor::CacheDeltaType &cacheDelta)
Loads value into cacheDelta.
Definition: src/catapult/cache/CacheStorageInclude.h:53
catapult::cache::CacheStorageFromDescriptor< HashCacheDescriptor >::DestinationType
typename HashCacheDescriptor ::CacheDeltaType DestinationType
Cache delta type.
Definition: src/catapult/cache/CacheStorageInclude.h:40
catapult::cache::CacheStorageForBasicInsertRemoveCache::Purge
static void Purge(const typename TDescriptor::ValueType &value, typename TDescriptor::CacheDeltaType &cacheDelta)
Purges value from cacheDelta.
Definition: src/catapult/cache/CacheStorageInclude.h:58
catapult::cache::CacheStorageFromDescriptor
Defines types for cache storage given a cache descriptor.
Definition: src/catapult/cache/CacheStorageInclude.h:35
catapult
Definition: AddressExtractionExtension.cpp:28
catapult::cache::CacheStorageFromDescriptor< HashCacheDescriptor >::KeyType
typename HashCacheDescriptor ::KeyType KeyType
Cache key type.
Definition: src/catapult/cache/CacheStorageInclude.h:43
catapult::cache::CacheStorageFromDescriptor< HashCacheDescriptor >::ValueType
typename HashCacheDescriptor ::ValueType ValueType
Cache value type.
Definition: src/catapult/cache/CacheStorageInclude.h:46
catapult::cache::CacheStorageFromDescriptor< HashCacheDescriptor >::SourceType
typename HashCacheDescriptor ::CacheViewType SourceType
Cache view type.
Definition: src/catapult/cache/CacheStorageInclude.h:37