libDwm-0.9.45
DwmASIOCapable.hh
Go to the documentation of this file.
1//===========================================================================
2// @(#) $DwmPath$
3//===========================================================================
4// Copyright (c) Daniel W. McRobb 2021, 2023, 2024
5// All rights reserved.
6//
7// Redistribution and use in source and binary forms, with or without
8// modification, are permitted provided that the following conditions
9// are met:
10//
11// 1. Redistributions of source code must retain the above copyright
12// notice, this list of conditions and the following disclaimer.
13// 2. Redistributions in binary form must reproduce the above copyright
14// notice, this list of conditions and the following disclaimer in the
15// documentation and/or other materials provided with the distribution.
16// 3. The names of the authors and copyright holders may not be used to
17// endorse or promote products derived from this software without
18// specific prior written permission.
19//
20// IN NO EVENT SHALL DANIEL W. MCROBB BE LIABLE TO ANY PARTY FOR
21// DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES,
22// INCLUDING LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE,
23// EVEN IF DANIEL W. MCROBB HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
24// DAMAGE.
25//
26// THE SOFTWARE PROVIDED HEREIN IS ON AN "AS IS" BASIS, AND
27// DANIEL W. MCROBB HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT,
28// UPDATES, ENHANCEMENTS, OR MODIFICATIONS. DANIEL W. MCROBB MAKES NO
29// REPRESENTATIONS AND EXTENDS NO WARRANTIES OF ANY KIND, EITHER
30// IMPLIED OR EXPRESS, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
31// WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE,
32// OR THAT THE USE OF THIS SOFTWARE WILL NOT INFRINGE ANY PATENT,
33// TRADEMARK OR OTHER RIGHTS.
34//===========================================================================
35
36//---------------------------------------------------------------------------
44//---------------------------------------------------------------------------
45
46#ifndef _DWMASIOCAPABLE_HH_
47#define _DWMASIOCAPABLE_HH_
48
49#include <boost/asio.hpp>
50
51namespace Dwm {
52
53 //--------------------------------------------------------------------------
57 //--------------------------------------------------------------------------
58 template <typename T>
59 concept HasAsioTcpRead = requires(T & t, boost::asio::ip::tcp::socket & s,
60 boost::system::error_code & ec) {
61 { t.Read(s, ec) } -> std::same_as<bool>;
62 };
63
64 //--------------------------------------------------------------------------
68 //--------------------------------------------------------------------------
69 template <typename T>
70 concept HasAsioTcpWrite = requires(const T & t,
71 boost::asio::ip::tcp::socket & s,
72 boost::system::error_code & ec) {
73 { t.Write(s, ec) } -> std::same_as<bool>;
74 };
75
76 //--------------------------------------------------------------------------
80 //--------------------------------------------------------------------------
81 template <typename T>
83 requires(T & t, boost::asio::local::stream_protocol::socket & s,
84 boost::system::error_code & ec) {
85 { t.Read(s, ec) } -> std::same_as<bool>;
86 };
87
88 //--------------------------------------------------------------------------
92 //--------------------------------------------------------------------------
93 template <typename T>
95 requires(const T & t, boost::asio::local::stream_protocol::socket & s,
96 boost::system::error_code & ec) {
97 { t.Write(s, ec) } -> std::same_as<bool>;
98 };
99
100 //--------------------------------------------------------------------------
104 //--------------------------------------------------------------------------
105 template <typename T>
107 requires(T & t, boost::asio::generic::stream_protocol::socket & s,
108 boost::system::error_code & ec) {
109 { t.Read(s, ec) } -> std::same_as<bool>;
110 };
111
112 //--------------------------------------------------------------------------
116 //--------------------------------------------------------------------------
117 template <typename T>
119 requires(const T & t, boost::asio::generic::stream_protocol::socket & s,
120 boost::system::error_code & ec) {
121 { t.Write(s, ec) } -> std::same_as<bool>;
122 };
123
124 //--------------------------------------------------------------------------
126 //--------------------------------------------------------------------------
127 template <typename T>
131
132 //--------------------------------------------------------------------------
134 //--------------------------------------------------------------------------
135 template <typename T>
139
140 //--------------------------------------------------------------------------
143 //--------------------------------------------------------------------------
145 {
146 public:
147 //------------------------------------------------------------------------
151 //------------------------------------------------------------------------
152 virtual bool Read(boost::asio::ip::tcp::socket & s,
153 boost::system::error_code & ec) = 0;
154
155 //------------------------------------------------------------------------
159 //------------------------------------------------------------------------
160 virtual bool Read(boost::asio::local::stream_protocol::socket & s,
161 boost::system::error_code & ec) = 0;
162
163 //------------------------------------------------------------------------
165 //------------------------------------------------------------------------
166 virtual bool Read(boost::asio::generic::stream_protocol::socket & s,
167 boost::system::error_code & ec) = 0;
168 };
169
170 //--------------------------------------------------------------------------
172 //--------------------------------------------------------------------------
174 {
175 public:
176 //------------------------------------------------------------------------
180 //------------------------------------------------------------------------
181 virtual bool Write(boost::asio::ip::tcp::socket & s,
182 boost::system::error_code & ec) const = 0;
183
184 //------------------------------------------------------------------------
188 //------------------------------------------------------------------------
189 virtual bool Write(boost::asio::local::stream_protocol::socket & s,
190 boost::system::error_code & ec) const = 0;
191
192 //------------------------------------------------------------------------
194 //------------------------------------------------------------------------
195 virtual bool Write(boost::asio::generic::stream_protocol::socket & s,
196 boost::system::error_code & ec) const = 0;
197
198 };
199
200 //--------------------------------------------------------------------------
203 //--------------------------------------------------------------------------
205 : public ASIOReadable, public ASIOWritable
206 {};
207
208} // namespace Dwm
209
210#endif // _DWMASIOCAPABLE_HH_
Interface for classes that can read/write their contents from/to a boost::asio::ip::tcp::socket.
Definition DwmASIOCapable.hh:206
Interface for classes that wish to be readable via Dwm::ASIO.
Definition DwmASIOCapable.hh:145
virtual bool Read(boost::asio::ip::tcp::socket &s, boost::system::error_code &ec)=0
Should read the class from the given socket s and return true on success, false on failure.
virtual bool Read(boost::asio::local::stream_protocol::socket &s, boost::system::error_code &ec)=0
Should read the class from the given socket s and return true on success, false on failure.
Interface for classes that wish to be writable via Dwm::ASIO.
Definition DwmASIOCapable.hh:174
virtual bool Write(boost::asio::local::stream_protocol::socket &s, boost::system::error_code &ec) const =0
Should write the class to the given socket s and return true on success, false on failure.
virtual bool Write(boost::asio::ip::tcp::socket &s, boost::system::error_code &ec) const =0
Should write the class to the given socket s and return true on success, false on failure.
T has a Read(boost::asio::generic::stream_protocol::socket &, boost::system::error_code &) method...
Definition DwmASIOCapable.hh:106
T has a Write(boost::asio::generic::stream_protocol::socket &, boost::system::error_code &) cons...
Definition DwmASIOCapable.hh:118
T has a Read(boost::asio::local::stream_protocol::socket &, boost::system::error_code &) method t...
Definition DwmASIOCapable.hh:82
T has a Write(boost::asio::local::stream_protocol::socket &, boost::system::error_code &) const ...
Definition DwmASIOCapable.hh:94
T has asio read members.
Definition DwmASIOCapable.hh:128
T has a Read(boost::asio::ip::tcp::socket &, boost::system::error_code &) method that returns bool.
Definition DwmASIOCapable.hh:59
T has a Write(boost::asio::ip::tcp::socket &, boost::system::error_code &) method that returns bool.
Definition DwmASIOCapable.hh:70
T has asio write members.
Definition DwmASIOCapable.hh:136