libDwm-0.9.45
DwmDescriptor.hh
Go to the documentation of this file.
1//===========================================================================
2// @(#) $DwmPath$
3//===========================================================================
4// Copyright (c) Daniel W. McRobb 1998-2006, 2016
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//---------------------------------------------------------------------------
39//---------------------------------------------------------------------------
40
41#ifndef _DWMDESCRIPTOR_HH_
42#define _DWMDESCRIPTOR_HH_
43
44extern "C" {
45#include <sys/types.h>
46#include <sys/time.h>
47#include <sys/uio.h>
48#include <unistd.h>
49}
50
51namespace Dwm {
52
53 //--------------------------------------------------------------------------
58 //--------------------------------------------------------------------------
60 {
61 public:
62 //------------------------------------------------------------------------
64 //------------------------------------------------------------------------
66
67 //------------------------------------------------------------------------
69 //------------------------------------------------------------------------
71
72 Descriptor(int d);
73
74 //------------------------------------------------------------------------
77 //------------------------------------------------------------------------
79
80 // Descriptor & operator = (int fd);
81
82 //------------------------------------------------------------------------
84 //------------------------------------------------------------------------
85 virtual ~Descriptor();
86
87 //------------------------------------------------------------------------
89 //------------------------------------------------------------------------
90 virtual bool Close();
91
92 //------------------------------------------------------------------------
97 //------------------------------------------------------------------------
98 virtual bool Attach(int fd);
99
100 //------------------------------------------------------------------------
103 //------------------------------------------------------------------------
104 virtual bool Detach();
105
106 //------------------------------------------------------------------------
109 //------------------------------------------------------------------------
110 virtual bool SetNonBlocking();
111
112 //------------------------------------------------------------------------
115 //------------------------------------------------------------------------
116 virtual bool SetBlocking();
117
118 //------------------------------------------------------------------------
122 //------------------------------------------------------------------------
123 virtual operator int () const
124 {
125 return(this->_fd);
126 }
127
128 //------------------------------------------------------------------------
131 //------------------------------------------------------------------------
132 virtual bool FdSet(fd_set & fdSet);
133
134 //------------------------------------------------------------------------
137 //------------------------------------------------------------------------
138 virtual bool FdClr(fd_set & fdSet);
139
140 //------------------------------------------------------------------------
143 //------------------------------------------------------------------------
144 virtual bool FdIsSet(fd_set & fdSet);
145
146 virtual bool ReadWouldBlock();
147
148 protected:
149 int _fd;
150 };
151
152} // namespace Dwm
153
154#endif // _DWMDESCRIPTOR_HH_
155
156//---------------------------- emacs settings -----------------------------
157// Local Variables:
158// mode: C++
159// tab-width: 2
160// indent-tabs-mode: nil
161// c-basic-offset: 2
162// End:
163//-------------------------------------------------------------------------
This class encapsulates UNIX file and socket descriptors.
Definition DwmDescriptor.hh:60
virtual bool Close()
Closes the Descriptor. Returns true on success, false on failure.
virtual bool SetBlocking()
Sets the soccket to blocking.
virtual bool FdSet(fd_set &fdSet)
If Descriptor is valid, sets it in fdSet and returns true.
virtual bool FdIsSet(fd_set &fdSet)
If Descriptor is valid and is set in fdSet, returns true.
Descriptor & operator=(const Descriptor &d)
operator = (assignment operator).
virtual bool Detach()
Disassociates the Descriptor from the underlying UNIX descriptor.
Descriptor()
Constructor.
virtual bool SetNonBlocking()
Sets the Descriptor to non-blocking.
virtual ~Descriptor()
Destructor. Note this will close the underlying UNIX descriptor.
virtual bool Attach(int fd)
Associates the Descriptor with an existing UNIX descriptor fd.
virtual bool FdClr(fd_set &fdSet)
If Descriptor is valid, clears it in fdSet and returns true.
Descriptor(const Descriptor &d)
Copy constructor. Will dup() the descriptor of d.