libDwm-0.9.45
Dwm::Descriptor Class Reference

This class encapsulates UNIX file and socket descriptors. More...

#include <DwmDescriptor.hh>

Public Member Functions

 Descriptor ()
 Constructor.
 
 Descriptor (const Descriptor &d)
 Copy constructor. Will dup() the descriptor of d.
 
 Descriptor (int d)
 
Descriptoroperator= (const Descriptor &d)
 operator = (assignment operator).
 
virtual ~Descriptor ()
 Destructor. Note this will close the underlying UNIX descriptor.
 
virtual bool Close ()
 Closes the Descriptor. Returns true on success, false on failure.
 
virtual bool Attach (int fd)
 Associates the Descriptor with an existing UNIX descriptor fd.
 
virtual bool Detach ()
 Disassociates the Descriptor from the underlying UNIX descriptor.
 
virtual bool SetNonBlocking ()
 Sets the Descriptor to non-blocking.
 
virtual bool SetBlocking ()
 Sets the soccket to blocking.
 
virtual operator int () const
 This completely blows encapsulation, but is needed so that Descriptor may be used in place of a UNIX descriptor in retrofitted code.
 
virtual bool FdSet (fd_set &fdSet)
 If Descriptor is valid, sets it in fdSet and returns true.
 
virtual bool FdClr (fd_set &fdSet)
 If Descriptor is valid, clears it in fdSet and returns true.
 
virtual bool FdIsSet (fd_set &fdSet)
 If Descriptor is valid and is set in fdSet, returns true.
 
virtual bool ReadWouldBlock ()
 

Protected Attributes

int _fd
 

Detailed Description

This class encapsulates UNIX file and socket descriptors.

It only abstracts those functions which have common interfaces, so that applications may use this interface to handle both file and socket descriptor I/O in the same place.

Member Function Documentation

◆ Attach()

virtual bool Dwm::Descriptor::Attach ( int fd)
virtual

Associates the Descriptor with an existing UNIX descriptor fd.

Note this will cause the Descriptor to automatically close fd when destructed. Returns true if fd is a valid descriptor, else returns false.

◆ Detach()

virtual bool Dwm::Descriptor::Detach ( )
virtual

Disassociates the Descriptor from the underlying UNIX descriptor.

Returns true on success, false on failure.

◆ FdClr()

virtual bool Dwm::Descriptor::FdClr ( fd_set & fdSet)
virtual

If Descriptor is valid, clears it in fdSet and returns true.

Else returns false.

◆ FdIsSet()

virtual bool Dwm::Descriptor::FdIsSet ( fd_set & fdSet)
virtual

If Descriptor is valid and is set in fdSet, returns true.

Else returns false.

◆ FdSet()

virtual bool Dwm::Descriptor::FdSet ( fd_set & fdSet)
virtual

If Descriptor is valid, sets it in fdSet and returns true.

Else returns false.

◆ operator=()

Descriptor & Dwm::Descriptor::operator= ( const Descriptor & d)

operator = (assignment operator).

Will close this and then dup() the descriptor of d.

◆ SetBlocking()

virtual bool Dwm::Descriptor::SetBlocking ( )
virtual

Sets the soccket to blocking.

Returns true on success, false on failure.

◆ SetNonBlocking()

virtual bool Dwm::Descriptor::SetNonBlocking ( )
virtual

Sets the Descriptor to non-blocking.

Returns true on success, false on failure.


The documentation for this class was generated from the following file: