CatapultServer  v0.5.0.1 (Elephant)
SingleSetCacheTypesAdapter.h
Go to the documentation of this file.
1 
21 #pragma once
22 #include "CacheDatabaseMixin.h"
23 #include "CachePatriciaTree.h"
25 #include <type_traits>
26 
27 namespace catapult { namespace cache {
28 
30  template<typename TPrimaryTypes, typename IsOrderedFlag = std::false_type>
32  public:
33  using PrimaryTypes = TPrimaryTypes;
34 
35  public:
38  typename TPrimaryTypes::BaseSetDeltaPointerType pPrimary;
39  };
40 
42  struct BaseSets : public CacheDatabaseMixin {
43  public:
45  using IsOrderedSet = IsOrderedFlag;
46 
47  private:
49 
50  public:
52  explicit BaseSets(const CacheConfiguration& config)
53  : CacheDatabaseMixin(config, { "default" }, PruningMode)
54  , Primary(GetContainerMode(config), database(), 0)
55  {}
56 
57  public:
58  typename TPrimaryTypes::BaseSetType Primary;
59 
60  public:
63  return { Primary.rebase() };
64  }
65 
69  return { Primary.rebaseDetached() };
70  }
71 
74  template<typename... TArgs>
75  void commit(TArgs&&... args) {
76  Primary.commit(std::forward<TArgs>(args)...);
77  flush();
78  }
79  };
80  };
81 
83  template<typename TPrimaryTypes, typename TPatriciaTree>
85  public:
88  typename TPrimaryTypes::BaseSetDeltaPointerType pPrimary;
89  std::shared_ptr<typename TPatriciaTree::DeltaType> pPatriciaTree;
90  };
91 
93  template<typename TBaseSetDeltaPointers>
94  struct BaseSets : public CacheDatabaseMixin {
95  public:
97  using IsOrderedSet = std::false_type;
98 
99  public:
101  explicit BaseSets(const CacheConfiguration& config)
102  : CacheDatabaseMixin(config, { "default" })
103  , Primary(GetContainerMode(config), database(), 0)
105  {}
106 
107  public:
108  typename TPrimaryTypes::BaseSetType Primary;
110 
111  public:
113  TBaseSetDeltaPointers rebase() {
114  TBaseSetDeltaPointers deltaPointers;
115  deltaPointers.pPrimary = Primary.rebase();
116  deltaPointers.pPatriciaTree = PatriciaTree.rebase();
117  return deltaPointers;
118  }
119 
122  TBaseSetDeltaPointers rebaseDetached() const {
123  TBaseSetDeltaPointers deltaPointers;
124  deltaPointers.pPrimary = Primary.rebaseDetached();
125  deltaPointers.pPatriciaTree = PatriciaTree.rebaseDetached();
126  return deltaPointers;
127  }
128 
130  void commit() {
131  Primary.commit();
133  flush();
134  }
135  };
136  };
137 }}
ConditionalContainer.h
catapult::cache::detail::OrderedMemorySetAdapter
Defines cache types for an ordered, memory backed set based cache.
Definition: CacheDescriptorAdapters.h:108
catapult::cache::SingleSetCacheTypesAdapter::BaseSets::commit
void commit(TArgs &&... args)
Definition: SingleSetCacheTypesAdapter.h:75
SimpleValidator.Line
Definition: SimpleValidator.py:1
catapult::cache::SingleSetCacheTypesAdapter::BaseSets::BaseSets
BaseSets(const CacheConfiguration &config)
Creates base sets around config.
Definition: SingleSetCacheTypesAdapter.h:52
CachePatriciaTree.h
catapult::cache::CacheDatabaseMixin::hasPatriciaTreeSupport
bool hasPatriciaTreeSupport() const
Returns true if patricia tree support is enabled.
Definition: CacheDatabaseMixin.h:50
SimpleValidator.SimpleValidator.finalize
def finalize(self)
Definition: SimpleValidator.py:24
catapult::cache::SingleSetCacheTypesAdapter::BaseSets::IsOrderedSet
IsOrderedFlag IsOrderedSet
Indicates the set is ordered (used for capability detection in templates).
Definition: SingleSetCacheTypesAdapter.h:45
SimpleValidator.Line.line
line
Definition: SimpleValidator.py:4
catapult::cache::SingleSetAndPatriciaTreeCacheTypesAdapter::BaseSets< AccountRestrictionBaseSetDeltaPointers >::IsOrderedSet
std::false_type IsOrderedSet
Indicates the set is not ordered.
Definition: SingleSetCacheTypesAdapter.h:97
SimpleValidator.SimpleValidator
Definition: SimpleValidator.py:9
catapult::cache::CacheDatabaseMixin::GetContainerMode
static deltaset::ConditionalContainerMode GetContainerMode(const CacheConfiguration &config)
Gets the container mode specified by config.
Definition: CacheDatabaseMixin.h:61
catapult::cache::SingleSetAndPatriciaTreeCacheTypesAdapter::BaseSetDeltaPointers::pPatriciaTree
std::shared_ptr< typename TPatriciaTree::DeltaType > pPatriciaTree
Definition: SingleSetCacheTypesAdapter.h:89
SimpleValidator.SimpleValidator.__init__
def __init__(self, errorReporter)
Definition: SimpleValidator.py:10
catapult::cache::SingleSetCacheTypesAdapter::BaseSets::rebase
BaseSetDeltaPointers rebase()
Returns a delta based on the same original elements as this set.
Definition: SingleSetCacheTypesAdapter.h:62
SimpleValidator.Line.lineno
lineno
Definition: SimpleValidator.py:5
catapult::cache::CacheDatabaseMixin
Mixin that owns a cache database.
Definition: CacheDatabaseMixin.h:30
catapult::cache::SingleSetAndPatriciaTreeCacheTypesAdapter::BaseSets::PatriciaTree
CachePatriciaTree< TPatriciaTree > PatriciaTree
Definition: SingleSetCacheTypesAdapter.h:109
catapult::cache::SingleSetAndPatriciaTreeCacheTypesAdapter
A cache types adapter for a cache composed of a single set and a patricia tree.
Definition: SingleSetCacheTypesAdapter.h:84
catapult::cache::FilterPruningMode::Enabled
Enabled, allocate underlying filter implementation.
SimpleValidator.SimpleValidator.errorReporter
errorReporter
Definition: SimpleValidator.py:11
catapult::cache::SingleSetAndPatriciaTreeCacheTypesAdapter::BaseSets::BaseSets
BaseSets(const CacheConfiguration &config)
Creates base sets around config.
Definition: SingleSetCacheTypesAdapter.h:101
catapult::cache::CachePatriciaTree::commit
void commit()
Commits all changes in the rebased tree.
Definition: CachePatriciaTree.h:56
catapult::cache::SingleSetCacheTypesAdapter::BaseSets
Wrapper around single set.
Definition: SingleSetCacheTypesAdapter.h:42
catapult::cache::SingleSetAndPatriciaTreeCacheTypesAdapter::BaseSets::commit
void commit()
Commits all changes in the rebased cache.
Definition: SingleSetCacheTypesAdapter.h:130
catapult::cache::CachePatriciaTree::rebaseDetached
auto rebaseDetached() const
Definition: CachePatriciaTree.h:51
SimpleValidator.Line.kind
kind
Definition: SimpleValidator.py:6
catapult::cache::FilterPruningMode::Disabled
Disabled, skip allocation of underlying filter implementation.
catapult::cache::SingleSetAndPatriciaTreeCacheTypesAdapter::BaseSetDeltaPointers
Wrapper around single delta set and patricia tree.
Definition: SingleSetCacheTypesAdapter.h:87
catapult::cache::CachePatriciaTree::rebase
auto rebase()
Returns a delta based on the same data source as this tree.
Definition: CachePatriciaTree.h:45
catapult::cache::SingleSetCacheTypesAdapter::BaseSets::Primary
TPrimaryTypes::BaseSetType Primary
Definition: SingleSetCacheTypesAdapter.h:58
catapult::cache::SingleSetCacheTypesAdapter::BaseSets::PruningMode
static constexpr auto PruningMode
Definition: SingleSetCacheTypesAdapter.h:48
CacheDatabaseMixin.h
SimpleValidator.SimpleValidator.path
path
Definition: SimpleValidator.py:22
catapult::cache::SingleSetCacheTypesAdapter::BaseSetDeltaPointers::pPrimary
TPrimaryTypes::BaseSetDeltaPointerType pPrimary
Definition: SingleSetCacheTypesAdapter.h:38
catapult::cache::SingleSetAndPatriciaTreeCacheTypesAdapter::BaseSets::rebase
TBaseSetDeltaPointers rebase()
Returns a delta based on the same original elements as this set.
Definition: SingleSetCacheTypesAdapter.h:113
SimpleValidator.Line.__init__
def __init__(self, path, line, lineno, kind='')
Definition: SimpleValidator.py:2
catapult::cache::CacheDatabaseMixin::database
CacheDatabase & database()
Gets the database.
Definition: CacheDatabaseMixin.h:55
catapult::cache::SingleSetCacheTypesAdapter::BaseSetDeltaPointers
Wrapper around single delta set.
Definition: SingleSetCacheTypesAdapter.h:37
catapult::cache::SingleSetAndPatriciaTreeCacheTypesAdapter::BaseSets
Wrapper around single set and patricia tree.
Definition: SingleSetCacheTypesAdapter.h:94
SimpleValidator.Line.path
path
Definition: SimpleValidator.py:3
catapult::cache::CacheConfiguration
Cache configuration.
Definition: CacheConfiguration.h:37
catapult::cache::SingleSetAndPatriciaTreeCacheTypesAdapter::BaseSets::Primary
TPrimaryTypes::BaseSetType Primary
Definition: SingleSetCacheTypesAdapter.h:108
catapult
Definition: AddressExtractionExtension.cpp:28
catapult::cache::SingleSetCacheTypesAdapter::BaseSets::rebaseDetached
BaseSetDeltaPointers rebaseDetached() const
Definition: SingleSetCacheTypesAdapter.h:68
catapult::cache::CacheDatabaseMixin::flush
void flush()
Flushes the database.
Definition: CacheDatabaseMixin.h:68
catapult::cache::SingleSetAndPatriciaTreeCacheTypesAdapter::BaseSets::rebaseDetached
TBaseSetDeltaPointers rebaseDetached() const
Definition: SingleSetCacheTypesAdapter.h:122
catapult::cache::CachePatriciaTree< TPatriciaTree >
SimpleValidator.SimpleValidator.reset
def reset(self, path)
Definition: SimpleValidator.py:21
catapult::cache::SingleSetCacheTypesAdapter
A cache types adapter for a cache composed of a single set.
Definition: SingleSetCacheTypesAdapter.h:31
catapult::cache::SingleSetAndPatriciaTreeCacheTypesAdapter::BaseSetDeltaPointers::pPrimary
TPrimaryTypes::BaseSetDeltaPointerType pPrimary
Definition: SingleSetCacheTypesAdapter.h:88