unix_fd_buffer Class Reference

This class provides a streambuffer for handling file/socket descriptor resources. More...

#include <unix_buffer.H>

Inheritance diagram for unix_fd_buffer:

Inheritance graph
[legend]
Collaboration diagram for unix_fd_buffer:

Collaboration graph
[legend]

List of all members.

Public Member Functions

int get_descriptor () const
 returns the attached file/socket descriptor
void attach (const int _fd, const bool autoclose=true)
virtual int detach ()
 unix_fd_buffer (void)
 create an unix_fd_buffer that is ready to be connected to a file/socket descriptor
 unix_fd_buffer (const int _fd)
virtual ~unix_fd_buffer ()
 destroy the unix_fd_buffer and close resource (if any was open)

Protected Member Functions

virtual int _get_descriptor () const
virtual int empty_buffer ()
virtual int overflow (int c)
virtual int sync ()
virtual int underflow ()

Protected Attributes

int fd
bool fd_autoclose
char obuffer [buffersize]
char ibuffer [buffersize+pushbacksize]

Static Protected Attributes

static const int buffersize = 4096
static const int pushbacksize = 10


Detailed Description

This class provides a streambuffer for handling file/socket descriptor resources.

Definition at line 732 of file unix_buffer.H.


Constructor & Destructor Documentation

unix_fd_buffer::unix_fd_buffer ( void   )  [inline]

create an unix_fd_buffer that is ready to be connected to a file/socket descriptor

Definition at line 888 of file unix_buffer.H.

unix_fd_buffer::unix_fd_buffer ( const int  _fd  )  [inline, explicit]

create an unix_fd_buffer that is connected to the given file/socket descriptor

Parameters:
_fd descriptor of an already opened connection
Remarks:
- resource will be closed on destruction
  • if you want to reuse the descriptor, you should use the default constructor and attach a descriptor later on with autoclose set to false

Definition at line 903 of file unix_buffer.H.

virtual unix_fd_buffer::~unix_fd_buffer (  )  [inline, virtual]

destroy the unix_fd_buffer and close resource (if any was open)

Definition at line 912 of file unix_buffer.H.


Member Function Documentation

virtual int unix_fd_buffer::_get_descriptor (  )  const [inline, protected, virtual]

Implements Cprovide_descriptor_access.

Reimplemented in unix_buffer.

Definition at line 742 of file unix_buffer.H.

virtual int unix_fd_buffer::empty_buffer (  )  [inline, protected, virtual]

Reimplemented in unix_buffer.

Definition at line 744 of file unix_buffer.H.

References buffersize, cerr, count(), endl(), errno, my_strerror(), obuffer, and PTHREAD_TESTCANCEL.

Referenced by overflow(), and sync().

Here is the call graph for this function:

virtual int unix_fd_buffer::overflow ( int  c  )  [inline, protected, virtual]

Definition at line 787 of file unix_buffer.H.

References empty_buffer().

Here is the call graph for this function:

virtual int unix_fd_buffer::sync (  )  [inline, protected, virtual]

Definition at line 794 of file unix_buffer.H.

References empty_buffer().

Here is the call graph for this function:

virtual int unix_fd_buffer::underflow (  )  [inline, protected, virtual]

Reimplemented in unix_buffer.

Definition at line 799 of file unix_buffer.H.

References buffersize, count(), errno, ibuffer, my_strerror(), PTHREAD_TESTCANCEL, and pushbacksize.

Here is the call graph for this function:

int unix_fd_buffer::get_descriptor (  )  const [inline]

returns the attached file/socket descriptor

Definition at line 833 of file unix_buffer.H.

Referenced by sd_iostream::_get_descriptor(), fd_iostream::_get_descriptor(), and unix_io_stream::_get_descriptor().

void unix_fd_buffer::attach ( const int  _fd,
const bool  autoclose = true 
) [inline]

attach a file / network connection via the given file/socket descriptor

Parameters:
_fd file/socket descriptor to attach
autoclose (optional) whether _fd should be closed on destruction of this object
Remarks:
  • it is not possible to attach more than one connection for a buffer simultaneously
  • you shouldn't close the attached descriptor without destructing the buffer
  • you should use the connection pointed by the descriptor exclusively by this unix_fd_buffer object
  • if you want to reuse the descriptor after destructing this unix_fd_buffer object, you should disable the autoclose feature

Definition at line 850 of file unix_buffer.H.

virtual int unix_fd_buffer::detach (  )  [inline, virtual]

detach the buffer from the file/socket descriptor

Returns:
an open file/socket descriptor or -1 if there was no descriptor or it has been autoclosed
Remarks:
If returnvalue is not -1, it is most possibly open and should not be thrown away.

Reimplemented in unix_buffer.

Definition at line 872 of file unix_buffer.H.


Member Data Documentation

const int unix_fd_buffer::buffersize = 4096 [static, protected]

Definition at line 735 of file unix_buffer.H.

Referenced by unix_buffer::empty_buffer(), empty_buffer(), unix_buffer::underflow(), and underflow().

const int unix_fd_buffer::pushbacksize = 10 [static, protected]

Definition at line 736 of file unix_buffer.H.

Referenced by unix_buffer::underflow(), and underflow().

int unix_fd_buffer::fd [protected]

Definition at line 737 of file unix_buffer.H.

bool unix_fd_buffer::fd_autoclose [protected]

Definition at line 738 of file unix_buffer.H.

char unix_fd_buffer::obuffer[buffersize] [protected]

Definition at line 739 of file unix_buffer.H.

Referenced by unix_buffer::empty_buffer(), and empty_buffer().

char unix_fd_buffer::ibuffer[buffersize+pushbacksize] [protected]

Definition at line 740 of file unix_buffer.H.

Referenced by unix_buffer::underflow(), and underflow().


The documentation for this class was generated from the following file:
Generated on Wed Nov 7 23:32:24 2007 for Qsieve by  doxygen 1.5.4