CARMA C++
sza::util::Pipe Class Reference

A class to encapsulate a pipe. More...

#include <carma/szautil/Pipe.h>

Inheritance diagram for sza::util::Pipe:
sza::util::PipeQueue

Classes

struct  PipeFd
 Define a struct to encapsulate a file descriptor associated with either end of a pipe. More...
 

Public Member Functions

int fd ()
 Return the file descriptor associated with this pipe. More...
 
 Pipe ()
 Constructor. More...
 
virtual PipeState read (void *buffer, size_t nbyte, long timeout=0)
 Read from the pipe. More...
 
int readFd ()
 
virtual void readPipe (void *buffer, size_t nbyte, long timeout)
 Read from the pipe. More...
 
fd_set rfds ()
 Return an intialized set of readable file descriptors associated with this queue. More...
 
virtual PipeState write (void *buffer, size_t nbyte, long timeout=0)
 Write to the pipe. More...
 
int writeFd ()
 
virtual void writePipe (void *buffer, size_t nbyte, long timeout)
 Write to the pipe. More...
 
virtual ~Pipe ()
 Destructor. More...
 

Protected Member Functions

void getTimeOfDay (struct timespec *ts)
 Get the current time of day. More...
 

Protected Attributes

pthread_mutex_t guard_
 A mutex guard for the pipe. More...
 
bool guardIsReady_
 True when the guard mutex has been initialized. More...
 
size_t nread_
 The number of bytes in buffer[]. More...
 
PipeFd readfd_
 File descriptor corresponding to the read end of the pipe. More...
 
char unread_ [PIPE_BUF]
 
PipeFd writefd_
 File descriptor corresponding to the write end of the pipe. More...
 

Detailed Description

A class to encapsulate a pipe.

Definition at line 49 of file Pipe.h.

Constructor & Destructor Documentation

sza::util::Pipe::Pipe ( )

Constructor.

Exceptions
Exception
virtual sza::util::Pipe::~Pipe ( )
virtual

Destructor.

Exceptions
Exception

Member Function Documentation

int sza::util::Pipe::fd ( )

Return the file descriptor associated with this pipe.

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

Get the current time of day.

Used by read/writePipe() for timeouts.

Exceptions
Exception
virtual PipeState sza::util::Pipe::read ( void *  buffer,
size_t  nbyte,
long  timeout = 0 
)
virtual

Read from the pipe.

Exceptions
Exception

Reimplemented in sza::util::PipeQueue.

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

Read from the pipe.

Exceptions
Exception
fd_set sza::util::Pipe::rfds ( )

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

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

Write to the pipe.

Exceptions
Exception

Reimplemented in sza::util::PipeQueue.

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

Write to the pipe.

Exceptions
Exception

Member Data Documentation

pthread_mutex_t sza::util::Pipe::guard_
protected

A mutex guard for the pipe.

Definition at line 108 of file Pipe.h.

bool sza::util::Pipe::guardIsReady_
protected

True when the guard mutex has been initialized.

Definition at line 120 of file Pipe.h.

size_t sza::util::Pipe::nread_
protected

The number of bytes in buffer[].

Definition at line 185 of file Pipe.h.

PipeFd sza::util::Pipe::readfd_
protected

File descriptor corresponding to the read end of the pipe.

Definition at line 165 of file Pipe.h.

PipeFd sza::util::Pipe::writefd_
protected

File descriptor corresponding to the write end of the pipe.

Definition at line 170 of file Pipe.h.


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