libjmmcg  release_579_6_g8cffd
A C++ library containing an eclectic mix of useful, advanced components.
exchange_to_client_processor.hpp
Go to the documentation of this file.
1 #ifndef ISIMUD_EXCHANGES_COMMON_EXCHANGE_TO_CLIENT_PROCESSOR_HPP
2 #define ISIMUD_EXCHANGES_COMMON_EXCHANGE_TO_CLIENT_PROCESSOR_HPP
3 
4 /******************************************************************************
5 ** Copyright © 2016 by J.M.McGuiness, isimud@hussar.me.uk
6 **
7 ** This library is free software; you can redistribute it and/or
8 ** modify it under the terms of the GNU Lesser General Public
9 ** License as published by the Free Software Foundation; either
10 ** version 2.1 of the License, or (at your option) any later version.
11 **
12 ** This library is distributed in the hope that it will be useful,
13 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
14 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 ** Lesser General Public License for more details.
16 **
17 ** You should have received a copy of the GNU Lesser General Public
18 ** License along with this library; if not, write to the Free Software
19 ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 */
21 
22 #include "core/jthread.hpp"
23 #include "core/ttypes.hpp"
24 
25 #include <boost/exception_ptr.hpp>
26 #include <boost/mpl/assert.hpp>
27 
28 #include <atomic>
29 
30 namespace isimud { namespace ISIMUD_VER_NAMESPACE { namespace exchanges { namespace common {
31 
32 /**
33 * \todo
34 * -# We need to write to the dest_skt found using the xdest in the msg in the unordered_tuple of exchange_to_client_processor passed as a template parameter & fn arg.
35 * -# Pass this up to the client_to_exchange_transformations & link_t.
36 * -# The client_to_exchange_transformations should contain the unordered_tuple of exchange_to_client_transformations (which contain the connections to the various exchanges).
37 */
38 template<class ClientCxnPtr, class EchgCxn>
39 class exchange_to_client_processor final {
40 public:
41  using client_connection_t=ClientCxnPtr;
42  using exchg_link_t=EchgCxn;
43  using conn_pol_t=typename exchg_link_t::conn_pol_t;
44  using exchange_msg_details_t=typename exchg_link_t::msg_details_t;
45  using proc_rules_t=typename exchg_link_t::proc_rules_t;
46  using socket_t=typename exchg_link_t::socket_t;
47  using socket_priority=typename exchg_link_t::socket_priority;
48  using ctor_args=typename exchg_link_t::ctor_args;
49 
50  template<class LatencyTimestamps>
51  exchange_to_client_processor(std::atomic<bool> &e, ctor_args const &exchange_cxn_details, socket_priority to_exchg_priority, proc_rules_t const &proc_rules, LatencyTimestamps &timestamps);
52 
53  bool is_logged_on() const noexcept(true);
54  void connect_client(client_connection_t client_connection) noexcept(true);
55  socket_t &socket() noexcept(true);
56  std::string to_string() const noexcept(false);
57 
58 private:
59  /**
60  * This class manages sending messages received from the exchange, translating them and returning them to the connected client. Naturally this is done on a separate, single thread.
61  */
62  class flow;
63 
64  exchg_link_t exchg_link;
65  flow exchange_to_client;
66 };
67 
68 template<class ClientCxnPtr, class ServerCxn>
69 inline std::ostream &
70 operator<<(std::ostream &os, exchange_to_client_processor<ClientCxnPtr, ServerCxn> const &s) noexcept(false);
71 
72 } } } }
73 
75 
76 #endif