CatapultServer  v0.5.0.1 (Elephant)
NamespaceCache.h
Go to the documentation of this file.
1 
21 #pragma once
22 #include "NamespaceCacheDelta.h"
23 #include "NamespaceCacheStorage.h"
24 #include "NamespaceCacheView.h"
26 
27 namespace catapult { namespace cache {
28 
29  using NamespaceBasicCache = BasicCache<
30  NamespaceCacheDescriptor,
33  const NamespaceSizes&>;
34 
37  public:
40  : BasicNamespaceCache(config, options, std::make_unique<NamespaceSizes>())
41  {}
42 
43  private:
45  const CacheConfiguration& config,
46  const NamespaceCacheTypes::Options& options,
47  std::unique_ptr<NamespaceSizes>&& pSizes)
48  : NamespaceBasicCache(config, NamespaceCacheTypes::Options(options), *pSizes)
49  , m_pSizes(std::move(pSizes))
50  {}
51 
52  public:
54  void init(size_t activeSize, size_t deepSize) {
55  *m_pSizes = { activeSize, deepSize };
56  }
57 
60  void commit(const CacheDeltaType& delta) {
62  *m_pSizes = { delta.activeSize(), delta.deepSize() };
63  }
64 
65  private:
66  // unique pointer to allow reference to be valid after moves of this cache
67  std::unique_ptr<NamespaceSizes> m_pSizes;
68  };
69 
71  class NamespaceCache : public SynchronizedCacheWithInit<BasicNamespaceCache> {
72  public:
74 
75  public:
77  explicit NamespaceCache(const CacheConfiguration& config, const NamespaceCacheTypes::Options& options)
79  {}
80  };
81 }}
NamespaceCacheView.h
catapult::cache::SynchronizedCacheWithInit
Decorator that synchronizes access to a cache and allows custom cache initialization.
Definition: SynchronizedCache.h:277
catapult::cache::BasicNamespaceCache
Cache composed of namespace information.
Definition: NamespaceCache.h:36
DEFINE_CACHE_CONSTANTS
#define DEFINE_CACHE_CONSTANTS(NAME)
Defines cache constants for a cache with NAME.
Definition: CacheConstants.h:42
catapult::cache::BasicNamespaceCache::BasicNamespaceCache
BasicNamespaceCache(const CacheConfiguration &config, const NamespaceCacheTypes::Options &options, std::unique_ptr< NamespaceSizes > &&pSizes)
Definition: NamespaceCache.h:44
catapult::cache::NamespaceCache
Synchronized cache composed of namespace information.
Definition: NamespaceCache.h:71
catapult::cache::BasicCache::commit
void commit(const CacheDeltaType &delta)
Commits all pending changes from delta to the underlying storage.
Definition: BasicCache.h:64
catapult::cache::BasicNamespaceCache::m_pSizes
std::unique_ptr< NamespaceSizes > m_pSizes
Definition: NamespaceCache.h:67
catapult::cache::NamespaceBasicCache
BasicCache< NamespaceCacheDescriptor, NamespaceCacheTypes::BaseSets, NamespaceCacheTypes::Options, const NamespaceSizes & > NamespaceBasicCache
Definition: NamespaceCache.h:33
catapult::tools::Options
boost::program_options::variables_map Options
Provides access to parsed options.
Definition: Options.h:34
catapult::cache::BasicNamespaceCache::init
void init(size_t activeSize, size_t deepSize)
Initializes the cache with activeSize and deepSize.
Definition: NamespaceCache.h:54
BasicCache.h
NamespaceCacheDelta.h
catapult::cache::BasicNamespaceCache::commit
void commit(const CacheDeltaType &delta)
Definition: NamespaceCache.h:60
catapult::cache::NamespaceCache::NamespaceCache
NamespaceCache(const CacheConfiguration &config, const NamespaceCacheTypes::Options &options)
Creates a cache around config and options.
Definition: NamespaceCache.h:77
catapult::cache::NamespaceCacheTypes
Namespace cache types.
Definition: NamespaceCacheTypes.h:78
catapult::cache::BasicNamespaceCache::BasicNamespaceCache
BasicNamespaceCache(const CacheConfiguration &config, const NamespaceCacheTypes::Options &options)
Creates a cache around config and options.
Definition: NamespaceCache.h:39
catapult::cache::BasicCache
Definition: BasicCache.h:32
catapult::cache::BasicCache::CacheDeltaType
typename TCacheDescriptor::CacheDeltaType CacheDeltaType
Definition: BasicCache.h:36
catapult::cache::CacheConfiguration
Cache configuration.
Definition: CacheConfiguration.h:37
catapult
Definition: AddressExtractionExtension.cpp:28
catapult::cache::NamespaceCacheTypes::BaseSets
NamespaceBaseSets BaseSets
Definition: NamespaceCacheTypes.h:129
catapult::cache::NamespaceCacheTypes::Options
Custom sub view options.
Definition: NamespaceCacheTypes.h:87
catapult::cache::NamespaceSizes
Extended namespace sizes.
Definition: NamespaceCacheMixins.h:30
catapult::cache::CacheId::Namespace
NamespaceCacheStorage.h