root/isimud/exchanges/FIX/common/processing_rules_impl.hpp

/* [<][>][^][v][top][bottom][index][help] */

INCLUDED FROM


DEFINITIONS

This source file includes following definitions.
  1. process_msg
  2. to_string
  3. process_msg
  4. to_string
  5. process_msg
  6. to_string

   1 /******************************************************************************
   2 ** $Header: svn+ssh://jmmcg@svn.code.sf.net/p/libjmmcg/code/trunk/libjmmcg/isimud/exchanges/FIX/common/processing_rules_impl.hpp 2334 2018-09-30 20:28:43Z jmmcg $
   3 **
   4 ** Copyright (c) 2016 by J.M.McGuiness, isimud@hussar.me.uk
   5 **
   6 ** This library is free software; you can redistribute it and/or
   7 ** modify it under the terms of the GNU Lesser General Public
   8 ** License as published by the Free Software Foundation; either
   9 ** version 2.1 of the License, or (at your option) any later version.
  10 **
  11 ** This library is distributed in the hope that it will be useful,
  12 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  13 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14 ** Lesser General Public License for more details.
  15 **
  16 ** You should have received a copy of the GNU Lesser General Public
  17 ** License along with this library; if not, write to the Free Software
  18 ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  19 */
  20 
  21 #include <functional>
  22 
  23 namespace isimud { namespace exchanges { namespace FIX { namespace common {
  24 
  25 template<class SrcMsgDetails, class DestMsgDetails, class SktT>
  26 struct client_to_exchange_transformations<SrcMsgDetails, DestMsgDetails, SktT>::state_machine_t : jmmcg::msm::unroll::state_transition_table<state_machine_t> {
  27         using msm_base_t=jmmcg::msm::unroll::state_transition_table<state_machine_t>;
  28         using row_t=jmmcg::msm::unroll::row_types<typename src_msg_details_t::ExgchgMsgTypes, typename dest_msg_details_t::MsgTypes_t>;
  29         using transition_table=typename msm_base_t::template rows<
  30 // TODO finish implementing this...
  31                 /// Reject any message that has not been recognised.
  32                 typename row_t::template row<
  33                         src_msg_details_t::MatchAll,
  34                         typename base_t::template send_reject<typename src_msg_details_t::Reject, false>,
  35                         dest_msg_details_t::Reject::type_const
  36                 >
  37         >;
  38 };
  39 
  40 template<class SrcMsgDetails, class DestMsgDetails, class SktT>
  41 inline bool
  42 client_to_exchange_transformations<SrcMsgDetails, DestMsgDetails, SktT>::process_msg(typename src_msg_details_t::msg_buffer_t const &buff, socket_t &client_skt) {
  43         typename src_msg_details_t::Header_t const &hdr=reinterpret_cast<typename src_msg_details_t::Header_t const &>(buff);
  44         const auto last_state=msm.process(hdr.type(), buff, client_skt);
  45         return last_state==msg_details_t::Exit;
  46 }
  47 
  48 template<class SrcMsgDetails, class DestMsgDetails, class SktT> inline std::string
  49 client_to_exchange_transformations<SrcMsgDetails, DestMsgDetails, SktT>::to_string() const noexcept(false) {
  50         return base_t::to_string();
  51 }
  52 
  53 template<class SrcMsgDetails, class DestMsgDetails, class SktT> inline std::ostream &
  54 operator<<(std::ostream &os, client_to_exchange_transformations<SrcMsgDetails, DestMsgDetails, SktT> const &ec) noexcept(false) {
  55         os<<ec.to_string();
  56         return os;
  57 }
  58 
  59 template<class SrcMsgDetails, class DestMsgDetails, class SktT>
  60 struct exchange_to_client_transformations<SrcMsgDetails, DestMsgDetails, SktT>::state_machine_t : jmmcg::msm::unroll::state_transition_table<state_machine_t> {
  61         using msm_base_t=jmmcg::msm::unroll::state_transition_table<state_machine_t>;
  62         using row_t=jmmcg::msm::unroll::row_types<typename src_msg_details_t::MsgTypes_t, typename dest_msg_details_t::ExgchgMsgTypes>;
  63         using transition_table=typename msm_base_t::template rows<
  64                 /**
  65                         The response to a server Heartbeat is a Heartbeat.
  66                 */
  67                 typename row_t::template row<
  68                         src_msg_details_t::ServerHeartbeat::type_const,
  69                         typename base_t::template just_send_to_exchg<typename src_msg_details_t::ClientHeartbeat>,
  70                         src_msg_details_t::ClientHeartbeat::type_const
  71                 >,
  72                 typename row_t::template row<
  73                         src_msg_details_t::Logout::type_const,
  74                         typename msm_base_t::no_op, // TODO
  75                         dest_msg_details_t::Exit
  76                 >,
  77 // TODO finish implementing this...
  78                 /// Reject any message that has not been recognised.
  79                 typename row_t::template row<
  80                         src_msg_details_t::MatchAll,
  81                         typename base_t::template send_reject<typename dest_msg_details_t::Reject, true>,
  82                         dest_msg_details_t::Reject::type_const
  83                 >
  84         >;
  85 };
  86 
  87 template<class SrcMsgDetails, class DestMsgDetails, class SktT>
  88 inline bool
  89 exchange_to_client_transformations<SrcMsgDetails, DestMsgDetails, SktT>::process_msg(typename src_msg_details_t::msg_buffer_t const &buff, socket_t &client_skt) {
  90         typename src_msg_details_t::Header_t const &hdr=reinterpret_cast<typename src_msg_details_t::Header_t const &>(buff);
  91         const auto last_state=msm.process(hdr.type(), buff, client_skt);
  92         return last_state==dest_msg_details_t::Exit;
  93 }
  94 
  95 template<class SrcMsgDetails, class DestMsgDetails, class SktT> inline std::string
  96 exchange_to_client_transformations<SrcMsgDetails, DestMsgDetails, SktT>::to_string() const noexcept(false) {
  97         return base_t::to_string();
  98 }
  99 
 100 template<class SrcMsgDetails, class DestMsgDetails, class SktT> inline std::ostream &
 101 operator<<(std::ostream &os, exchange_to_client_transformations<SrcMsgDetails, DestMsgDetails, SktT> const &ec) noexcept(false) {
 102         os<<ec.to_string();
 103         return os;
 104 }
 105 
 106 template<class SrcMsgDetails, class SktT>
 107 struct simulator_responses<SrcMsgDetails, SktT>::state_machine_t : jmmcg::msm::unroll::state_transition_table<state_machine_t> {
 108         using msm_base_t=jmmcg::msm::unroll::state_transition_table<state_machine_t>;
 109         using row_t=jmmcg::msm::unroll::row_types<typename src_msg_details_t::ExgchgMsgTypes, typename msg_details_t::ExgchgMsgTypes>;
 110         using transition_table=typename msm_base_t::template rows<
 111                 /**
 112                         The response to a Heartbeat is nothing.
 113                 */
 114                 typename row_t::template row<
 115                         src_msg_details_t::ClientHeartbeat::type_const,
 116                         typename msm_base_t::no_op,
 117                         msg_details_t::ServerHeartbeat::type_const
 118                 >,
 119 // TODO finish implementing this...
 120                 /// Reject any message that has not been recognised.
 121                 typename row_t::template row<
 122                         src_msg_details_t::MatchAll,
 123                         typename base_t::template send_reject<typename msg_details_t::Reject, true>,
 124                         msg_details_t::Reject::type_const
 125                 >
 126         >;
 127 };
 128 
 129 template<class SrcMsgDetails, class SktT>
 130 inline bool
 131 simulator_responses<SrcMsgDetails, SktT>::process_msg(typename src_msg_details_t::msg_buffer_t const &buff, socket_t &exchg_skt, socket_t &client_skt) {
 132         ++(this->sequenceNumber);
 133         typename src_msg_details_t::Header_t const &hdr=reinterpret_cast<typename src_msg_details_t::Header_t const &>(buff);
 134         const auto last_state=msm.process(hdr.type(), buff, exchg_skt, client_skt);
 135         return last_state==msg_details_t::Exit;
 136 }
 137 
 138 template<class SrcMsgDetails, class SktT> inline std::string
 139 simulator_responses<SrcMsgDetails, SktT>::to_string() const noexcept(false) {
 140         return base_t::to_string();
 141 }
 142 
 143 template<class SrcMsgDetails, class SktT> inline std::ostream &
 144 operator<<(std::ostream &os, simulator_responses<SrcMsgDetails, SktT> const &ec) noexcept(false) {
 145         os<<ec.to_string();
 146         return os;
 147 }
 148 
 149 } } } }

/* [<][>][^][v][top][bottom][index][help] */