libDwm-0.9.45
DwmDescriptorIOCapable.hh
Go to the documentation of this file.
1//===========================================================================
2// @(#) $DwmPath$
3//===========================================================================
4// Copyright (c) Daniel W. McRobb 2020, 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//---------------------------------------------------------------------------
42//---------------------------------------------------------------------------
43
44#ifndef _DWMDESCRIPTORIOCAPABLE_HH_
45#define _DWMDESCRIPTORIOCAPABLE_HH_
46
47extern "C" {
48 #include <sys/types.h>
49}
50
51#include <cstddef>
52
53namespace Dwm {
54
55 //--------------------------------------------------------------------------
58 //--------------------------------------------------------------------------
59 template <typename T>
60 concept HasDescriptorRead = requires (T & t, int fd) {
61 { t.Read(fd) } -> std::same_as<ssize_t>;
62 };
63
64 //--------------------------------------------------------------------------
67 //--------------------------------------------------------------------------
68 template <typename T>
69 concept HasDescriptorWrite = requires (const T & t, int fd) {
70 { t.Write(fd) } -> std::same_as<ssize_t>;
71 };
72
73 //--------------------------------------------------------------------------
76 //--------------------------------------------------------------------------
78 {
79 public:
80 //------------------------------------------------------------------------
82 //------------------------------------------------------------------------
83 virtual ~DescriptorReadable() { }
84
85 //------------------------------------------------------------------------
88 //------------------------------------------------------------------------
89 virtual ssize_t Read(int fd) = 0;
90 };
91
92 //--------------------------------------------------------------------------
95 //--------------------------------------------------------------------------
97 {
98 public:
99 //------------------------------------------------------------------------
101 //------------------------------------------------------------------------
103
104 //------------------------------------------------------------------------
107 //------------------------------------------------------------------------
108 virtual ssize_t Write(int fd) const = 0;
109 };
110
111 //--------------------------------------------------------------------------
114 //--------------------------------------------------------------------------
118
119} // namespace Dwm
120
121#endif // _DWMDESCRIPTORIOCAPABLE_HH_
122
123//---------------------------- emacs settings -----------------------------
124// Local Variables:
125// mode: C++
126// tab-width: 2
127// indent-tabs-mode: nil
128// c-basic-offset: 2
129// End:
130//-------------------------------------------------------------------------
This class defines an interface for classes that can write/read their contents to/from a file descrip...
Definition DwmDescriptorIOCapable.hh:117
This class defines an interface for classes that can read their contents from a file descriptor.
Definition DwmDescriptorIOCapable.hh:78
virtual ~DescriptorReadable()
destructor
Definition DwmDescriptorIOCapable.hh:83
virtual ssize_t Read(int fd)=0
Read from a file descriptor.
This class defines an interface for classes that can write their contents to a file descriptor.
Definition DwmDescriptorIOCapable.hh:97
virtual ~DescriptorWritable()
Destructor.
Definition DwmDescriptorIOCapable.hh:102
virtual ssize_t Write(int fd) const =0
Write to a file descriptor.
T has a Read(int) member that returns ssize_t (number of bytes read on success, -1 on failure).
Definition DwmDescriptorIOCapable.hh:60
T has a Write(int fd) const member that returns ssize_t (number of bytes read on success,...
Definition DwmDescriptorIOCapable.hh:69