libjmmcg  release_579_6_g8cffd
A C++ library containing an eclectic mix of useful, advanced components.
socket_server_manager.hpp
Go to the documentation of this file.
1 #ifndef LIBJMMCG_CORE_SOCKET_SERVER_MANAGER_HPP
2 #define LIBJMMCG_CORE_SOCKET_SERVER_MANAGER_HPP
3 
4 /******************************************************************************
5 ** Copyright © 2015 by J.M.McGuiness, coder@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 
25 
26 namespace jmmcg { namespace LIBJMMCG_VER_NAMESPACE { namespace socket { namespace server_manager {
27 
28 /// A simple TCP/IP socket wrapper using a wrapped socket for servers.
29 template<class SktT>
30 class manager;
31 template<class LkT>
32 class manager<socket::asio::socket_wrapper<LkT>> : public asio::manager<LkT> {
33 public:
34  using base_t=asio::manager<LkT>;
35  using socket_t=typename base_t::socket_t;
36  using base_t::manager;
37 };
38 template<class LkT>
39 class manager<socket::glibc::client::wrapper<LkT>> : public glibc::manager<LkT> {
40 public:
41  using base_t=glibc::manager<LkT>;
42  using socket_t=typename base_t::socket_t;
43  using base_t::manager;
44 };
45 
46 /// A simple TCP/IP socket wrapper using wrapped socket for loop-back servers.
47 template<class SvrHBs, class SktT>
48 class loopback;
49 template<class SvrHBs, class LkT>
50 class loopback<SvrHBs, socket::asio::socket_wrapper<LkT>> final : public asio::loopback<SvrHBs, LkT> {
51 public:
52  using base_t=asio::loopback<SvrHBs, LkT>;
53  using server_to_client_flow_t=typename base_t::server_to_client_flow_t;
54  using socket_t=typename base_t::socket_t;
55  using socket_priority=typename base_t::socket_priority;
56 
57  loopback(boost::asio::ip::address const &addr, unsigned short port_num, std::size_t min_message_size, std::size_t max_message_size, unsigned short timeout, socket_priority priority, std::size_t incoming_cpu, server_to_client_flow_t &&server_to_client_flow)
58  : base_t(addr, port_num, min_message_size, max_message_size, timeout, priority, incoming_cpu, std::move(server_to_client_flow)) {}
59 };
60 template<class SvrHBs, class LkT>
61 class loopback<SvrHBs, socket::glibc::client::wrapper<LkT>> final : public glibc::loopback<SvrHBs, LkT> {
62 public:
63  using base_t=glibc::loopback<SvrHBs, LkT>;
64  using server_to_client_flow_t=typename base_t::server_to_client_flow_t;
65  using socket_t=typename base_t::socket_t;
66  using socket_priority=typename base_t::socket_priority;
67 
68  loopback(boost::asio::ip::address const &addr, unsigned short port_num, std::size_t min_message_size, std::size_t max_message_size, unsigned short timeout, socket_priority priority, std::size_t incoming_cpu, server_to_client_flow_t &&server_to_client_flow)
69  : base_t(addr, port_num, min_message_size, max_message_size, timeout, priority, incoming_cpu, std::move(server_to_client_flow)) {}
70 };
71 
72 /// A simple TCP/IP socket wrapper using a wrapped socket for forwarding servers.
73 template<class SktT>
74 class forwarding;
75 template<class LkT>
76 class forwarding<socket::asio::socket_wrapper<LkT>> final : public asio::forwarding<LkT> {
77 public:
78  using base_t=asio::forwarding<LkT>;
79  using server_to_client_flow_t=typename base_t::server_to_client_flow_t;
80  using socket_t=typename base_t::socket_t;
81  using base_t::forwarding;
82 };
83 template<class LkT>
84 class forwarding<socket::glibc::client::wrapper<LkT>> final : public glibc::forwarding<LkT> {
85 public:
86  using base_t=glibc::forwarding<LkT>;
87  using server_to_client_flow_t=typename base_t::server_to_client_flow_t;
88  using socket_t=typename base_t::socket_t;
89  using base_t::forwarding;
90 };
91 
92 } } } }
93 
94 #endif