SocketProtocol.cti
Go to the documentation of this file.
1 //
2 // Copyright (c) 2020 Fraunhofer Institute for Applied Information Technology (FIT)
3 // Network Research Group (NET)
4 // Schloss Birlinghoven, 53754 Sankt Augustin, GERMANY
5 // Contact: support@wiback.org
6 //
7 // This file is part of the SENF code tree.
8 // It is licensed under the 3-clause BSD License (aka New BSD License).
9 // See LICENSE.txt in the top level directory for details or visit
10 // https://opensource.org/licenses/BSD-3-Clause
11 //
12 
13 
14 /** \file
15  \brief SocketProtocol and ConcreteSocketProtocol inline template implementation
16  */
17 
18 //#include "SocketProtocol.ih"
19 
20 // Custom includes
21 #include "SocketHandle.hh"
22 
23 #define prefix_ inline
24 //-/////////////////////////////////////////////////////////////////////////////////////////////////
25 
26 //-/////////////////////////////////////////////////////////////////////////////////////////////////
27 // senf::ConcreteSocketProtocol<SocketPolicy,Self>
28 
29 template <class SocketPolicy, class Self>
30 prefix_ senf::ConcreteSocketProtocol<SocketPolicy,Self>::~ConcreteSocketProtocol()
31 {}
32 
33 template <class SocketPolicy, class Self>
34 prefix_ typename senf::ConcreteSocketProtocol<SocketPolicy,Self>::Policy const &
35 senf::ConcreteSocketProtocol<SocketPolicy,Self>::policy()
36  const
37 {
38  return policy_;
39 }
40 
41 template <class SocketPolicy, class Self>
42 prefix_ std::unique_ptr<senf::SocketBody>
43 senf::ConcreteSocketProtocol<SocketPolicy,Self>::clone(bool isServer)
44  const
45 {
46  return std::unique_ptr<SocketBody>(new ProtocolSocketBody<Self>(isServer));
47 }
48 
49 template <class SocketPolicy, class Self>
50 prefix_ std::unique_ptr<senf::SocketBody>
51 senf::ConcreteSocketProtocol<SocketPolicy,Self>::clone(int fd, bool isServer)
52  const
53 {
54  return std::unique_ptr<SocketBody>(new ProtocolSocketBody<Self>(isServer, fd));
55 }
56 
57 template <class SocketPolicy, class Self>
58 prefix_ senf::SocketBody & senf::ConcreteSocketProtocol<SocketPolicy,Self>::body()
59  const
60 {
61  return const_cast< ProtocolSocketBody<Self> &>(
62  static_cast< ProtocolSocketBody<Self> const & >(*this));
63 }
64 
65 //-/////////////////////////////////////////////////////////////////////////////////////////////////
66 // protected members
67 
68 template <class SocketPolicy, class Self>
69 prefix_ senf::ClientSocketHandle<SocketPolicy>
70 senf::ConcreteSocketProtocol<SocketPolicy,Self>::clientHandle()
71  const
72 {
73  return static_socket_cast< ClientSocketHandle<Policy> >(fh());
74 }
75 
76 template <class SocketPolicy, class Self>
77 prefix_ senf::ServerSocketHandle<SocketPolicy>
78 senf::ConcreteSocketProtocol<SocketPolicy,Self>::serverHandle()
79  const
80 {
81  return static_socket_cast< ServerSocketHandle<Policy> >(fh());
82 }
83 
84 //-/////////////////////////////////////////////////////////////////////////////////////////////////
85 #undef prefix_
86 
87 
88 // Local Variables:
89 // mode: c++
90 // fill-column: 100
91 // c-file-style: "senf"
92 // indent-tabs-mode: nil
93 // ispell-local-dictionary: "american"
94 // compile-command: "scons -u test"
95 // comment-column: 40
96 // End: