CatapultServer  v0.5.0.1 (Elephant)
CacheHandlers.h
Go to the documentation of this file.
1 
21 #pragma once
22 #include "PluginManager.h"
26 
27 namespace catapult { namespace plugins {
28 
30  template<typename TCacheDescriptor>
31  class CacheHandlers {
32  public:
34  template<model::FacilityCode FacilityCode>
35  static void Register(PluginManager& pluginManager) {
36  using KeyType = typename TCacheDescriptor::KeyType;
37  using CacheType = typename TCacheDescriptor::CacheType;
38  using CachePacketTypes = CachePacketTypesT<FacilityCode>;
39 
40  pluginManager.addHandlerHook([](auto& handlers, const cache::CatapultCache& cache) {
42  handlers::RegisterStatePathHandler<PacketType>(handlers, cache.sub<CacheType>());
43  });
44 
45  pluginManager.addDiagnosticHandlerHook([](auto& handlers, const cache::CatapultCache& cache) {
48  handlers,
50  });
51  }
52 
53  private:
54  template<model::FacilityCode FacilityCode>
56  static constexpr auto State_Path = static_cast<ionet::PacketType>(800 + static_cast<uint8_t>(FacilityCode));
57  static constexpr auto Diagnostic_Infos = static_cast<ionet::PacketType>(1200 + static_cast<uint8_t>(FacilityCode));
58  };
59 
60  template<ionet::PacketType PacketType, typename TKey>
63 
64  TKey Key;
65  };
66 
67  template<ionet::PacketType PacketType, typename TKey>
70 
71  using RequestStructureType = TKey;
72  };
73  };
74 }}
catapult::plugins::CacheHandlers::BatchHandlerFactoryTraits::Packet_Type
static constexpr ionet::PacketType Packet_Type
Definition: CacheHandlers.h:69
catapult::ionet::Packet
A packet header with a data payload.
Definition: Packet.h:32
catapult::plugins::PluginManager::addDiagnosticHandlerHook
void addDiagnosticHandlerHook(const HandlerHook &hook)
Adds a diagnostic handler hook.
Definition: PluginManager.cpp:114
catapult::plugins::CacheHandlers::BatchHandlerFactoryTraits::RequestStructureType
TKey RequestStructureType
Definition: CacheHandlers.h:71
catapult::plugins::CacheHandlers::StatePathRequestPacket
Definition: CacheHandlers.h:61
catapult::plugins::CacheHandlers
Utility class for registering cache-dependent handlers.
Definition: CacheHandlers.h:31
catapult::plugins::PluginManager
A manager for registering plugins.
Definition: PluginManager.h:51
catapult::plugins::CacheHandlers::StatePathRequestPacket::Packet_Type
static constexpr ionet::PacketType Packet_Type
Definition: CacheHandlers.h:62
catapult::plugins::CacheHandlers::StatePathRequestPacket::Key
TKey Key
Definition: CacheHandlers.h:64
catapult::plugins::CacheHandlers::BatchHandlerFactoryTraits
Definition: CacheHandlers.h:68
catapult::plugins::CacheHandlers::CachePacketTypesT::State_Path
static constexpr auto State_Path
Definition: CacheHandlers.h:56
catapult::model::FacilityCode
FacilityCode
Possible facility codes.
Definition: model/FacilityCode.h:27
catapult::ionet::PacketType
PacketType
An enumeration of known packet types.
Definition: PacketType.h:171
catapult::handlers::CacheEntryInfosProducerFactory
Cache entry infos producer factory.
Definition: CacheEntryInfosProducerFactory.h:36
catapult::cache::CatapultCache
Central cache holding all sub caches.
Definition: CatapultCache.h:40
catapult::plugins::CacheHandlers::CachePacketTypesT
Definition: CacheHandlers.h:55
CacheEntryInfosProducerFactory.h
PluginManager.h
catapult::cache::CatapultCache::sub
const TCache & sub() const
Gets a specific sub cache.
Definition: CatapultCache.h:56
catapult::plugins::CacheHandlers::Register
static void Register(PluginManager &pluginManager)
Registers all cache handlers in pluginManager for cache with specified facility code.
Definition: CacheHandlers.h:35
catapult
Definition: AddressExtractionExtension.cpp:28
HandlerFactory.h
catapult::handlers::BatchHandlerFactory::RegisterOne
static void RegisterOne(ionet::ServerPacketHandlers &handlers, TResultsProducerFactory resultsProducerFactory)
Definition: HandlerFactory.h:54
StatePathHandlerFactory.h
catapult::plugins::CacheHandlers::CachePacketTypesT::Diagnostic_Infos
static constexpr auto Diagnostic_Infos
Definition: CacheHandlers.h:57
catapult::plugins::PluginManager::addHandlerHook
void addHandlerHook(const HandlerHook &hook)
Adds a (non-diagnostic) handler hook.
Definition: PluginManager.cpp:102