CatapultServer  v0.5.0.1 (Elephant)
CatapultCacheView.h
Go to the documentation of this file.
1 
21 #pragma once
22 #include "StateHashInfo.h"
23 #include "SubCachePlugin.h"
24 #include <memory>
25 
26 namespace catapult {
27  namespace cache {
28  class CacheHeightView;
29  class ReadOnlyCatapultCache;
30  }
31 }
32 
33 namespace catapult { namespace cache {
34 
37  public:
39  CatapultCacheView(CacheHeightView&& cacheHeightView, std::vector<std::unique_ptr<const SubCacheView>>&& subViews);
40 
43 
44  public:
45  // make this class move only (the definitions are in the source file in order to allow forward declarations)
48 
49  public:
51  template<typename TCache>
52  const typename TCache::CacheViewType& sub() const {
53  return *static_cast<const typename TCache::CacheViewType*>(m_subViews[TCache::Id]->get());
54  }
55 
56  public:
59 
61  Height height() const;
62 
63  public:
66 
67  private:
68  std::unique_ptr<CacheHeightView> m_pCacheHeight; // use a unique_ptr to allow fwd declare
69  std::vector<std::unique_ptr<const SubCacheView>> m_subViews;
70  };
71 }}
StateHashInfo.h
catapult::cache::CatapultCacheView::height
Height height() const
Gets the cache height associated with the read lock.
Definition: CatapultCache.cpp:108
Id
NamespaceId Id
Definition: RootNamespaceHistorySerializer.cpp:100
catapult::utils::BaseValue< uint64_t, Height_tag >
catapult::cache::StateHashInfo
Information about a cache state hash.
Definition: StateHashInfo.h:28
catapult::cache::CatapultCacheView::toReadOnly
ReadOnlyCatapultCache toReadOnly() const
Creates a read-only view of this view.
Definition: CatapultCache.cpp:112
catapult::cache::CatapultCacheView::m_subViews
std::vector< std::unique_ptr< const SubCacheView > > m_subViews
Definition: CatapultCacheView.h:69
catapult::cache::CatapultCacheView::m_pCacheHeight
std::unique_ptr< CacheHeightView > m_pCacheHeight
Definition: CatapultCacheView.h:68
catapult::cache::CatapultCacheView
Locked view on top of the catapult cache.
Definition: CatapultCacheView.h:36
catapult::cache::CatapultCacheView::sub
const TCache::CacheViewType & sub() const
Gets a specific sub cache view.
Definition: CatapultCacheView.h:52
SubCachePlugin.h
catapult
Definition: AddressExtractionExtension.cpp:28
catapult::cache::CatapultCacheView::CatapultCacheView
CatapultCacheView(CacheHeightView &&cacheHeightView, std::vector< std::unique_ptr< const SubCacheView >> &&subViews)
Creates a locked catapult cache view from a cache height view (cacheHeightView) and subViews.
Definition: CatapultCache.cpp:93
catapult::cache::CacheHeightView
A read only view on top of a cache height.
Definition: CacheHeight.h:28
catapult::cache::CatapultCacheView::operator=
CatapultCacheView & operator=(CatapultCacheView &&)
catapult::cache::CatapultCacheView::~CatapultCacheView
~CatapultCacheView()
Releases the read lock.
catapult::cache::ReadOnlyCatapultCache
A read-only overlay on top of a catapult cache.
Definition: ReadOnlyCatapultCache.h:27
catapult::cache::CatapultCacheView::calculateStateHash
StateHashInfo calculateStateHash() const
Calculates the cache state hash.
Definition: CatapultCache.cpp:104