My Project
 All Classes Files Functions Variables Enumerations Enumerator Friends Macros Pages
gcp::util::Pipe Class Reference

#include <Pipe.h>

Inheritance diagram for gcp::util::Pipe:
gcp::util::PipeQueue

Classes

struct  PipeFd
 

Public Member Functions

 Pipe ()
 
virtual ~Pipe ()
 
virtual void readPipe (void *buffer, size_t nbyte, long timeout)
 
virtual void writePipe (void *buffer, size_t nbyte, long timeout)
 
virtual PipeState read (void *buffer, size_t nbyte, long timeout=PIPE_NOWAIT)
 
virtual PipeState write (void *buffer, size_t nbyte, long timeout=PIPE_NOWAIT)
 
int fd ()
 
fd_set rfds ()
 
int readFd ()
 
int writeFd ()
 

Protected Member Functions

void getTimeOfDay (struct timespec *ts)
 

Protected Attributes

pthread_mutex_t guard_
 
bool guardIsReady_
 
PipeFd readfd_
 
PipeFd writefd_
 
char unread_ [PIPE_BUF]
 
size_t nread_
 

Detailed Description

A class to encapsulate a pipe

Constructor & Destructor Documentation

Pipe::Pipe ( )

Constructor.

Exceptions
Exception....................................................................... Pipe constructor function
Pipe::~Pipe ( )
virtual

Destructor.

Exceptions
Exception....................................................................... Pipe destructor function

Member Function Documentation

int Pipe::fd ( )

Return the file descriptor associated with this pipe.

....................................................................... Return the readable fd associated with this pipe. For use in select()

void Pipe::getTimeOfDay ( struct timespec *  ts)
protected

Get the current time of day. Used by read/writePipe() for timeouts.

Exceptions
Exception....................................................................... Get the current time of day. Used by read/writePipe() for timeouts
PipeState Pipe::read ( void *  buffer,
size_t  nbyte,
long  timeout = PIPE_NOWAIT 
)
virtual

Read from the pipe.

Exceptions
Exception....................................................................... Read from the Pipe

Reimplemented in gcp::util::PipeQueue.

void Pipe::readPipe ( void *  buffer,
size_t  nbyte,
long  timeout 
)
virtual

Read from the pipe.

Exceptions
Exception....................................................................... Read from the Pipe
fd_set Pipe::rfds ( )

Return an intialized set of readable file descriptors associated with this queue.

....................................................................... Return an intialized set of readable file descriptors associated with this pipe.

The history of this is that macros like FD_ZERO and FD_SET cannot be used in template class definitions (for instance GenericTask.h, where this method is used), because gcc 2.95 has a bug that will cause it to choke on the 'volatile' keyword in bits/select.h where these macros are defined. Not clear that this bug has been resolved, but there's one note I found indicating that it was fixed in gcc 3.3.

PipeState Pipe::write ( void *  buffer,
size_t  nbyte,
long  timeout = PIPE_NOWAIT 
)
virtual

Write to the pipe.

Exceptions
Exception....................................................................... Write to a Pipe

Reimplemented in gcp::util::PipeQueue.

void Pipe::writePipe ( void *  buffer,
size_t  nbyte,
long  timeout 
)
virtual

Write to the pipe.

Exceptions
Exception....................................................................... Write to a Pipe

Member Data Documentation

pthread_mutex_t gcp::util::Pipe::guard_
protected

A mutex guard for the pipe.

bool gcp::util::Pipe::guardIsReady_
protected

True when the guard mutex has been initialized.

size_t gcp::util::Pipe::nread_
protected

The number of bytes in buffer[]

PipeFd gcp::util::Pipe::readfd_
protected

File descriptor corresponding to the read end of the pipe.

PipeFd gcp::util::Pipe::writefd_
protected

File descriptor corresponding to the write end of the pipe.


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