TARAXA
taraxa::network::tarcap::PacketsHandler Class Reference

Generic PacketsHandler that contains all specific packet handlers. More...

#include <packets_handler.hpp>

Public Member Functions

const std::shared_ptr< PacketHandler > & getSpecificHandler (SubprotocolPacketType packet_type) const
 Factory method for getting specific packet handler based on packet type. More...
 
template<typename PacketHandlerType >
std::shared_ptr< PacketHandlerType > getSpecificHandler ()
 templated getSpecificHandler method for getting specific packet handler based on PacketHandlerType::kPacketType_ More...
 
template<typename PacketHandlerType , typename... Args>
void registerHandler (Args &&... args)
 Registers packet handler. More...
 

Private Attributes

std::unordered_map< SubprotocolPacketType, std::shared_ptr< PacketHandler > > packets_handlers_
 

Detailed Description

Generic PacketsHandler that contains all specific packet handlers.

Member Function Documentation

◆ getSpecificHandler() [1/2]

template<typename PacketHandlerType >
std::shared_ptr< PacketHandlerType > taraxa::network::tarcap::PacketsHandler::getSpecificHandler

templated getSpecificHandler method for getting specific packet handler based on PacketHandlerType::kPacketType_

Template Parameters
PacketHandlerType
Returns
std::shared_ptr<PacketHandlerType>

◆ getSpecificHandler() [2/2]

const std::shared_ptr< PacketHandler > & taraxa::network::tarcap::PacketsHandler::getSpecificHandler ( SubprotocolPacketType  packet_type) const

Factory method for getting specific packet handler based on packet type.

Note
reference to pointer is returned, it is user's responsibility to decide if he makes a copy to independently control the lifetime of the object or not.
Parameters
packet_type
Returns
reference to std::shared_ptr<PacketsHandler>

◆ registerHandler()

template<typename PacketHandlerType , typename... Args>
void taraxa::network::tarcap::PacketsHandler::registerHandler ( Args &&...  args)

Registers packet handler.

Template Parameters
PacketHandlerType
Args
Parameters
argsto be forwarded to the PacketHandlerType ctor

Member Data Documentation

◆ packets_handlers_

std::unordered_map<SubprotocolPacketType, std::shared_ptr<PacketHandler> > taraxa::network::tarcap::PacketsHandler::packets_handlers_
private

The documentation for this class was generated from the following files: