libjmmcg  release_579_6_g8cffd
A C++ library containing an eclectic mix of useful, advanced components.
jmmcg::LIBJMMCG_VER_NAMESPACE::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 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 SktT , class LatencyTimestamps >
std::enable_if< std::is_class< typename LatencyTimestamps::period >::value, bool >::type read_and_process_a_msg (SktT &src_skt, SktT &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...
 
template<class SktT , class ClientCxn , class LatencyTimestamps >
std::enable_if< std::is_class< typename LatencyTimestamps::period >::value, bool >::type read_and_process_a_msg (SktT &src_skt, ClientCxn &dest_cxn, LatencyTimestamps &ts) noexcept(false)
 Read a message from the source socket, process it and write the resultant message(s) to the destination socket, if it is valid, otherwise write back to the src_skt. More...
 
std::string to_string () const noexcept(false)
 

Detailed Description

template<class ProcessingRules>
class jmmcg::LIBJMMCG_VER_NAMESPACE::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 26 of file msg_processor.hpp.

Member Typedef Documentation

◆ msg_buffer_t

template<class ProcessingRules >
using jmmcg::LIBJMMCG_VER_NAMESPACE::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 libjmmcg::stack_string.

Definition at line 40 of file msg_processor.hpp.

◆ msg_details_t

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

Definition at line 33 of file msg_processor.hpp.

◆ proc_rules_t

template<class ProcessingRules >
using jmmcg::LIBJMMCG_VER_NAMESPACE::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 32 of file msg_processor.hpp.

Constructor & Destructor Documentation

◆ msg_processor()

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

Definition at line 22 of file msg_processor_impl.hpp.

Member Function Documentation

◆ read_and_process_a_msg() [1/2]

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

Read a message from the source socket, process it and write the resultant message(s) to the destination socket, if it is valid, otherwise write back to the src_skt.

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.

Definition at line 49 of file msg_processor_impl.hpp.

◆ read_and_process_a_msg() [2/2]

template<class ProcessingRules >
template<class SktT , class LatencyTimestamps >
std::enable_if< std::is_class< typename LatencyTimestamps::period >::value, bool >::type jmmcg::LIBJMMCG_VER_NAMESPACE::socket::msg_processor< ProcessingRules >::read_and_process_a_msg ( SktT &  src_skt,
SktT &  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.

Definition at line 36 of file msg_processor_impl.hpp.

◆ to_string()

template<class ProcessingRules >
std::string jmmcg::LIBJMMCG_VER_NAMESPACE::socket::msg_processor< ProcessingRules >::to_string
inlinenoexcept

Definition at line 60 of file msg_processor_impl.hpp.


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