libjmmcg  build_2783
A C++ library containing an eclectic mix of useful, advanced components.
jmmcg::socket::msg_processor< ProcessingRules > Class Template Reference

Read a message from the source socket, process it according to the supplied rules and write the resultant message(s) to the destination socket. More...

#include <msg_processor.hpp>

Public Types

using proc_rules_t = ProcessingRules
 The processing rules for the particular server instance. More...
 
using socket_t = typename proc_rules_t::socket_t
 
using msg_details_t = typename proc_rules_t::src_msg_details_t
 
using msg_buffer_t = typename msg_details_t::msg_buffer_t
 The buffer into which the incoming messages are received. More...
 

Public Member Functions

 msg_processor (proc_rules_t const &proc_rules)
 
template<class LatencyTimestamps >
std::enable_if< std::is_class< typename LatencyTimestamps::period >::value, bool >::type read_and_process_a_msg (socket_t &src_skt, LatencyTimestamps &ts) noexcept(false)
 Read a message from the source socket, process it and write the resultant message(s) back to the source socket. More...
 
template<class LatencyTimestamps >
std::enable_if< std::is_class< typename LatencyTimestamps::period >::value, bool >::type read_and_process_a_msg (socket_t &src_skt, socket_t &dest_skt, LatencyTimestamps &ts) noexcept(false)
 Read a message from the source socket, process it and write the resultant message(s) to the destination socket. More...
 
std::string to_string () const noexcept(false)
 

Detailed Description

template<class ProcessingRules>
class jmmcg::socket::msg_processor< ProcessingRules >

Read a message from the source socket, process it according to the supplied rules and write the resultant message(s) to the destination socket.

Definition at line 61 of file msg_processor.hpp.

Member Typedef Documentation

◆ msg_buffer_t

template<class ProcessingRules>
using jmmcg::socket::msg_processor< ProcessingRules >::msg_buffer_t = typename msg_details_t::msg_buffer_t

The buffer into which the incoming messages are received.

This should be per-thread, on the stack of the thread, suitably aligned, possibly to 64-bits. For maximum performance it should be a reference to the internal buffer of the network stack or even the hardware buffer in the card (assuming suitable kernel modules). It is not recommended to use GCC <=v4.9.* due to sub-optimal code-generation in std::memcpy() (see the performance graphs of jmmcg::stack_string.

Definition at line 93 of file msg_processor.hpp.

◆ msg_details_t

template<class ProcessingRules>
using jmmcg::socket::msg_processor< ProcessingRules >::msg_details_t = typename proc_rules_t::src_msg_details_t

Definition at line 86 of file msg_processor.hpp.

◆ proc_rules_t

template<class ProcessingRules>
using jmmcg::socket::msg_processor< ProcessingRules >::proc_rules_t = ProcessingRules

The processing rules for the particular server instance.

These rules specify how an input message should be transformed to one, or more, response messages,

Definition at line 84 of file msg_processor.hpp.

◆ socket_t

template<class ProcessingRules>
using jmmcg::socket::msg_processor< ProcessingRules >::socket_t = typename proc_rules_t::socket_t

Definition at line 85 of file msg_processor.hpp.

Constructor & Destructor Documentation

◆ msg_processor()

template<class ProcessingRules >
jmmcg::socket::msg_processor< ProcessingRules >::msg_processor ( proc_rules_t const &  proc_rules)
inlineexplicit

Definition at line 57 of file msg_processor_impl.hpp.

Member Function Documentation

◆ read_and_process_a_msg() [1/2]

template<class ProcessingRules >
template<class LatencyTimestamps >
std::enable_if< std::is_class< typename LatencyTimestamps::period >::value, bool >::type jmmcg::socket::msg_processor< ProcessingRules >::read_and_process_a_msg ( socket_t src_skt,
LatencyTimestamps &  ts 
)
inlinenoexcept

Read a message from the source socket, process it and write the resultant message(s) back to the source socket.

Note that this call will block until sufficient data has been read from the source socket to comprise a complete source message.

Throws: an exception if there has been a socket error (the source socket being cleanly closed is not an error).

Parameters
src_sktThe socket that is source of the messages.
Returns
True if the source socket has been closed, false otherwise.

Definition at line 69 of file msg_processor_impl.hpp.

◆ read_and_process_a_msg() [2/2]

template<class ProcessingRules >
template<class LatencyTimestamps >
std::enable_if< std::is_class< typename LatencyTimestamps::period >::value, bool >::type jmmcg::socket::msg_processor< ProcessingRules >::read_and_process_a_msg ( socket_t src_skt,
socket_t dest_skt,
LatencyTimestamps &  ts 
)
inlinenoexcept

Read a message from the source socket, process it and write the resultant message(s) to the destination socket.

Note that this call will block until sufficient data has been read from the source socket to comprise a complete source message.

Throws: an exception if there has been a socket error (the source socket being cleanly closed is not an error).

Parameters
src_sktThe socket that is source of the messages.
dest_sktThe socket that is destination of the messages, may be the same as src_skt.
Returns
True if the source socket has been closed, false otherwise.
Todo:
  1. We need to write to the dest_skt found using the xdest in the msg in the unordered_tuple of exchg_links_t passed as a template parameter & fn arg.
  2. Pass this up to the client_to_exchange_transformations & link_t.
  3. The client_to_exchange_transformations should contain the unordered_tuple of exchange_to_client_transformations (which contain the connections to the various exchanges).
  4. Will need to add a lock to the client-side socket to prevent multiple exchanges writing to it at once.

Definition at line 89 of file msg_processor_impl.hpp.

◆ to_string()

template<class ProcessingRules >
std::string jmmcg::socket::msg_processor< ProcessingRules >::to_string ( ) const
inlinenoexcept

Definition at line 100 of file msg_processor_impl.hpp.


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