CatapultServer  v0.5.0.1 (Elephant)
SummaryAwareSubCachePluginAdapter.h
Go to the documentation of this file.
1 
21 #pragma once
22 #include "SubCachePluginAdapter.h"
23 
24 namespace catapult { namespace cache {
25 
27  template<typename TCache>
29  public:
31  explicit SummaryCacheStorage(TCache& cache)
32  : m_cache(cache)
33  , m_name(std::string(TCache::Name) + "_summary")
34  {}
35 
36  public:
37  const std::string& name() const override {
38  return m_name;
39  }
40 
41  protected:
43  const TCache& cache() const {
44  return m_cache;
45  }
46 
48  TCache& cache() {
49  return m_cache;
50  }
51 
52  private:
53  TCache& m_cache;
54  std::string m_name;
55  };
56 
58  template<typename TCache, typename TStorageTraits, typename TSummaryCacheStorage>
59  class SummaryAwareSubCachePluginAdapter : public SubCachePluginAdapter<TCache, TStorageTraits> {
60  private:
62 
63  public:
64  using BaseType::BaseType;
65 
66  public:
67  std::unique_ptr<CacheStorage> createStorage() override {
68  auto pStorage = BaseType::createStorage();
69  return pStorage ? std::move(pStorage) : std::make_unique<TSummaryCacheStorage>(this->cache());
70  }
71  };
72 }}
catapult::cache::SummaryCacheStorage::name
const std::string & name() const override
Gets the cache name.
Definition: SummaryAwareSubCachePluginAdapter.h:37
catapult::cache::SubCachePluginAdapter::createStorage
std::unique_ptr< CacheStorage > createStorage() override
Returns a cache storage based on this cache.
Definition: SubCachePluginAdapter.h:79
catapult::cache::SummaryCacheStorage
CacheStorage implementation for saving and loading summary cache data.
Definition: SummaryAwareSubCachePluginAdapter.h:28
catapult::cache::SummaryCacheStorage::SummaryCacheStorage
SummaryCacheStorage(TCache &cache)
Creates a storage around cache.
Definition: SummaryAwareSubCachePluginAdapter.h:31
catapult::cache::SubCachePluginAdapter::cache
TCache & cache()
Gets a typed reference to the underlying cache.
Definition: SubCachePluginAdapter.h:91
catapult::cache::SummaryCacheStorage::cache
const TCache & cache() const
Gets a typed const reference to the underlying cache.
Definition: SummaryAwareSubCachePluginAdapter.h:43
catapult::cache::CacheStorage
Interface for loading and saving cache data.
Definition: CacheStorage.h:35
SubCachePluginAdapter.h
catapult::cache::SummaryAwareSubCachePluginAdapter::createStorage
std::unique_ptr< CacheStorage > createStorage() override
Returns a cache storage based on this cache.
Definition: SummaryAwareSubCachePluginAdapter.h:67
Name
static constexpr auto Name
Definition: PtSynchronizer.cpp:31
catapult::cache::SummaryCacheStorage::cache
TCache & cache()
Gets a typed reference to the underlying cache.
Definition: SummaryAwareSubCachePluginAdapter.h:48
catapult::cache::SummaryCacheStorage::m_cache
TCache & m_cache
Definition: SummaryAwareSubCachePluginAdapter.h:53
catapult
Definition: AddressExtractionExtension.cpp:28
catapult::cache::SummaryCacheStorage::m_name
std::string m_name
Definition: SummaryAwareSubCachePluginAdapter.h:54
catapult::cache::SummaryAwareSubCachePluginAdapter
Specialized sub cache plugin adapter that provides proper handling of summary cache state.
Definition: SummaryAwareSubCachePluginAdapter.h:59
catapult::cache::SubCachePluginAdapter
A SubCachePlugin implementation that wraps a SynchronizedCache.
Definition: SubCachePluginAdapter.h:32