rad  3.0.0
Public Types | Public Member Functions | List of all members
rad::MsgReplier Class Reference

#include <msgReplier.hpp>

Public Types

using MsgHandler_t = std::function< void(const std::string &, const std::string &, const void *, size_t)>
 
using MsgHandlerMap_t = std::unordered_map< std::string, MsgHandler_t >
 
using MsgHandler_t = std::function< void(const std::string &, const std::string &, const void *, size_t)>
 
using MsgHandlerMap_t = std::unordered_map< std::string, MsgHandler_t >
 

Public Member Functions

 MsgReplier (const std::string &endpoint, boost::asio::io_service &ios, std::unique_ptr< MsgHandler > &&fallback_handler)
 
virtual ~MsgReplier ()
 
 MsgReplier (MsgReplier &&)=default
 
void Start ()
 
void Stop ()
 
void AddMsgHandler (const std::string &request_name, MsgHandler_t handler)
 
size_t Send (const std::string &identity, const std::string &reply_type, const std::string &reply_payload)
 
template<typename REPLY >
size_t Send (const std::string &identity, const REPLY &reply_payload)
 
 MsgReplier (const MsgReplier &)=delete
 
MsgReplieroperator= (const MsgReplier &)=delete
 
 MsgReplier (const std::string &endpoint, boost::asio::io_service &ios, std::unique_ptr< MsgHandler > &&fallback_handler)
 
virtual ~MsgReplier ()
 
 MsgReplier (MsgReplier &&)=default
 
void Start ()
 
void Stop ()
 
void AddMsgHandler (const std::string &request_name, MsgHandler_t handler)
 
size_t Send (const std::string &identity, const std::string &reply_type, const std::string &reply_payload)
 
template<typename REPLY >
size_t Send (const std::string &identity, const REPLY &reply_payload)
 
 MsgReplier (const MsgReplier &)=delete
 
MsgReplieroperator= (const MsgReplier &)=delete
 
template<typename TYPEREP >
size_t Send (const std::string &identity, const TYPEREP &reply_payload)
 

Detailed Description

Class to receive requests and send replies.

Member Typedef Documentation

◆ MsgHandler_t [1/2]

using rad::MsgReplier::MsgHandler_t = std::function<void(const std::string&, const std::string&, const void*, size_t)>

◆ MsgHandler_t [2/2]

using rad::MsgReplier::MsgHandler_t = std::function<void(const std::string&, const std::string&, const void*, size_t)>

◆ MsgHandlerMap_t [1/2]

using rad::MsgReplier::MsgHandlerMap_t = std::unordered_map<std::string, MsgHandler_t>

◆ MsgHandlerMap_t [2/2]

using rad::MsgReplier::MsgHandlerMap_t = std::unordered_map<std::string, MsgHandler_t>

Constructor & Destructor Documentation

◆ MsgReplier() [1/6]

MsgReplier::MsgReplier ( const std::string &  endpoint,
boost::asio::io_service &  ios,
std::unique_ptr< MsgHandler > &&  fallback 
)

Configure socket and bind the socket to the given endpoint (IP address and port).

Parameters
[in]endpointAddress and port to be used to receive requests.
[in]iosReference to the event loop.
[in]fallbackMap of handlers for given requests used if no other handlers are provided (e.g. via the AddMsgHandler() method).

◆ ~MsgReplier() [1/2]

MsgReplier::~MsgReplier ( )
virtual

Destructor

◆ MsgReplier() [2/6]

rad::MsgReplier::MsgReplier ( MsgReplier &&  )
default

◆ MsgReplier() [3/6]

rad::MsgReplier::MsgReplier ( const MsgReplier )
delete

◆ MsgReplier() [4/6]

rad::MsgReplier::MsgReplier ( const std::string &  endpoint,
boost::asio::io_service &  ios,
std::unique_ptr< MsgHandler > &&  fallback_handler 
)

◆ ~MsgReplier() [2/2]

virtual rad::MsgReplier::~MsgReplier ( )
virtual

◆ MsgReplier() [5/6]

rad::MsgReplier::MsgReplier ( MsgReplier &&  )
default

◆ MsgReplier() [6/6]

rad::MsgReplier::MsgReplier ( const MsgReplier )
delete

Member Function Documentation

◆ AddMsgHandler() [1/2]

void MsgReplier::AddMsgHandler ( const std::string &  request_name,
MsgHandler_t  handler 
)

Add a handler for a given request name.

Parameters
[in]request_nameRequest to handle.
[in]handlerHandler for the given request name.

◆ AddMsgHandler() [2/2]

void rad::MsgReplier::AddMsgHandler ( const std::string &  request_name,
MsgHandler_t  handler 
)

◆ operator=() [1/2]

MsgReplier& rad::MsgReplier::operator= ( const MsgReplier )
delete

◆ operator=() [2/2]

MsgReplier& rad::MsgReplier::operator= ( const MsgReplier )
delete

◆ Send() [1/5]

template<typename REPLY >
size_t rad::MsgReplier::Send ( const std::string &  identity,
const REPLY &  reply_payload 
)

◆ Send() [2/5]

template<typename REPLY >
size_t rad::MsgReplier::Send ( const std::string &  identity,
const REPLY &  reply_payload 
)

◆ Send() [3/5]

size_t MsgReplier::Send ( const std::string &  identity,
const std::string &  reply_type,
const std::string &  reply_payload 
)

Method to reply to a request.

Parameters
[in]identityIdentity of the originator of the request to reply to.
[in]reply_typeType of the payload to be sent with the reply.
[in]reply_payloadPayload to be sent with the reply.
Returns
the number of bytes sent with the reply.

◆ Send() [4/5]

size_t rad::MsgReplier::Send ( const std::string &  identity,
const std::string &  reply_type,
const std::string &  reply_payload 
)

◆ Send() [5/5]

template<typename TYPEREP >
size_t rad::MsgReplier::Send ( const std::string &  identity,
const TYPEREP &  reply_payload 
)

◆ Start() [1/2]

void MsgReplier::Start ( )

Register callback to the socket.

◆ Start() [2/2]

void rad::MsgReplier::Start ( )

◆ Stop() [1/2]

void MsgReplier::Stop ( )

Stop processing requests.

◆ Stop() [2/2]

void rad::MsgReplier::Stop ( )

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