FX::QLocalPipe Class Reference
[Synchronous i/o devices]

#include <QLocalPipe.h>

Inheritance diagram for FX::QLocalPipe:

Inheritance graph
[legend]

List of all members.


Detailed Description

A process-local pipe.

This is a synchronous pipe i/o device operated completely within the local process and is intended as the primary method for threads to communicate with each other. It is extremely efficient, threadsafe and has no effective pipe buffer length as it uses the freestore.

See FX::QPipe for more information about how such objects work. One difference that there is no create(), instead there is an otherEnd() method which returns an instance of QLocalPipe reflecting the other end of the local pipe.

Note that on some platforms FX::QLocalPipe can appear to be slower than a system pipe (the i/o test shows this). I can't explain this except to say that if you set the granularity to 512Kb you get the same speed but at 1Mb sequential performance suddenly doubles - so I'm assuming that the MSVC6 STL <vector> implementation is crossing over some boundary where it reallocates every time. One thing my tests do confirm is that QLocalPipe has a much lower latency than FX::QPipe which means anything working without a sliding window will benefit a lot.

Public Types

enum  CRLFType { Default, Unix, MacOS, MSDOS }
enum  UnicodeType {
  NoTranslation, UTF8, UTF16, UTF16LE,
  UTF32, UTF32LE
}
typedef FXfval Offset

Public Member Functions

 QLocalPipe ()
 QLocalPipe (const QLocalPipe &o)
FXuval granularity () const
void setGranularity (FXuval newval)
QLocalPipe clientEnd () const
bool create (FXuint mode=IO_ReadWrite)
bool open (FXuint mode=IO_ReadWrite)
void close ()
void flush ()
bool atEnd () const
FXfval size () const
void truncate (FXfval size)
FXfval at () const
bool at (FXfval newpos)
FXuval readBlock (char *data, FXuval maxlen)
FXuval writeBlock (const char *data, FXuval maxlen)
int ungetch (int)
virtual bool isSynchronous () const
virtual FXuval readBlockFrom (char *data, FXuval maxlen, FXfval pos)
FXuval readBlockFrom (FXuchar *data, FXuval maxlen, FXfval pos)
virtual FXuval writeBlockTo (FXfval pos, const char *data, FXuval maxlen)
FXuval writeBlockTo (FXfval pos, const FXuchar *data, FXuval maxlen)
FXuint flags () const
FXuint mode () const
FXuint state () const
CRLFType crlfFormat () const
void setCRLFFormat (CRLFType type)
UnicodeType unicodeTranslation () const
void setUnicodeTranslation (UnicodeType type)
bool isBuffered () const
bool isRaw () const
bool isTranslated () const
bool isUTF16Translated () const
bool isUTF32Translated () const
bool isReadable () const
bool isWriteable () const
bool isWritable () const
bool isReadWrite () const
bool isClosed () const
bool isInactive () const
bool isOpen () const
virtual const FXACLpermissions () const
virtual void setPermissions (const FXACL &)
FXuval readBlock (FXuchar *data, FXuval maxlen)
FXuval writeBlock (const FXuchar *data, FXuval maxlen)
virtual FXuval readLine (char *data, FXuval maxlen)
virtual int getch ()
virtual int putch (int c)
FXfval shredData (FXfval offset, FXfval len=(FXfval)-1)

Static Public Member Functions

static bool waitForData (QIODeviceS **signalled, FXuint no, QIODeviceS **list, FXuint waitfor=FXINFINITE)
static FXuint waitForDataMax () throw ()
static UnicodeType determineUnicodeType (FXuchar *data, FXuval len) throw ()
static FXuval applyCRLF (FXuchar *FXRESTRICT output, const FXuchar *FXRESTRICT input, FXuval outputlen, FXuval &inputlen, CRLFType crlftype=Default, UnicodeType utftype=NoTranslation)
static FXuval removeCRLF (FXuchar *FXRESTRICT output, const FXuchar *FXRESTRICT input, FXuval outputlen, FXuval &inputlen, UnicodeType utftype=NoTranslation)

Protected Member Functions

void setFlags (int f)
void setMode (int m)
void setState (int s)

Protected Attributes

FXfval ioIndex

Friends

struct QLocalPipePrivate
FXAPI FXStreamoperator<< (FXStream &s, QIODevice &i)
FXAPI FXStreamoperator>> (FXStream &s, QIODevice &i)


Member Enumeration Documentation

enum FX::QIODevice::CRLFType [inherited]

The type of CR/LF encoding you want.

Enumerator:
Default  Uses the host OS format.
Unix  Uses ASCII 10 to delimit lines.
MacOS  Uses ASCII 13 to delimit lines.
MSDOS  Uses ASCII 13,10 to delimit lines.

enum FX::QIODevice::UnicodeType [inherited]

The type of unicode translation you want.

Enumerator:
NoTranslation  Performs no translation.
UTF8  Outputs in native UTF-8.
UTF16  Converts between native (UTF-8) and UTF-16 big endian.
UTF16LE  Converts between native (UTF-8) and UTF-16 little endian.
UTF32  Converts between native (UTF-8) and UTF-32 big endian.
UTF32LE  Converts between native (UTF-8) and UTF-32 little endian.


Constructor & Destructor Documentation

FX::QLocalPipe::QLocalPipe (  ) 

Constructs a process-local pipe.

FX::QLocalPipe::QLocalPipe ( const QLocalPipe o  ) 

The copy is the other end of the pipe ie; effectively the same as clientEnd().


Member Function Documentation

FXuval FX::QLocalPipe::granularity (  )  const

Returns the granularity of memory allocation. The default is 64Kb.

void FX::QLocalPipe::setGranularity ( FXuval  newval  ) 

Sets the granularity of memory allocation. Set only when the device is closed.

QLocalPipe FX::QLocalPipe::clientEnd (  )  const [inline]

Returns an instance of this local pipe reflecting the client end of the local pipe.

bool FX::QLocalPipe::create ( FXuint  mode = IO_ReadWrite  )  [inline, virtual]

Opens the local pipe for usage.

Implements FX::QIODeviceS.

bool FX::QLocalPipe::open ( FXuint  mode = IO_ReadWrite  )  [virtual]

Creates the client side of the device.

Implements FX::QIODeviceS.

void FX::QLocalPipe::close (  )  [virtual]

Closes the connection. Note that any data still waiting to be read is lost (use flush() before if you don't want this).

Implements FX::QIODevice.

void FX::QLocalPipe::flush (  )  [virtual]

Flushes any data currently waiting to be transferred.

Implements FX::QIODevice.

bool FX::QLocalPipe::atEnd (  )  const [virtual]

Returns true if no more data to be read.

Reimplemented from FX::QIODeviceS.

FXfval FX::QLocalPipe::size (  )  const [virtual]

Returns the amount of data waiting to be read.

Implements FX::QIODevice.

void FX::QLocalPipe::truncate ( FXfval  size  )  [virtual]

Does nothing as pipes can't be truncated.

Reimplemented from FX::QIODeviceS.

FXfval FX::QLocalPipe::at (  )  const [virtual]

Returns 0 because pipes don't have a current file pointer.

Reimplemented from FX::QIODeviceS.

bool FX::QLocalPipe::at ( FXfval  newpos  )  [virtual]

Returns false because you can't set the current file pointer on a pipe.

Reimplemented from FX::QIODeviceS.

FXuval FX::QLocalPipe::readBlock ( char *  data,
FXuval  maxlen 
) [virtual]

Returns:
The number of bytes read (which may be less than requested)
Parameters:
data Pointer to buffer to receive data
maxlen Maximum number of bytes to read
Reads a block of data from the pipe into the given buffer. Will wait forever until requested amount of data has been read if necessary. Is compatible with thread cancellation in FX::QThread on all platforms.

Implements FX::QIODevice.

FXuval FX::QLocalPipe::writeBlock ( const char *  data,
FXuval  maxlen 
) [virtual]

Returns:
The number of bytes written.
Parameters:
data Pointer to buffer of data to send
maxlen Number of bytes to send
Writes a block of data from the given buffer to the pipe. This is instantaneous.

Implements FX::QIODevice.

int FX::QLocalPipe::ungetch ( int   )  [virtual]

Tries to unread a character. Unsupported for pipes.

Implements FX::QIODevice.

virtual bool FX::QIODeviceS::isSynchronous (  )  const [inline, virtual, inherited]

Returns true if this device is a synchronous device.

Reimplemented from FX::QIODevice.

Reimplemented in FX::QSSLDevice.

virtual FXuval FX::QIODeviceS::readBlockFrom ( char *  data,
FXuval  maxlen,
FXfval  pos 
) [virtual, inherited]

Default implementation throws an exception.

Implements FX::QIODevice.

Reimplemented in FX::QSSLDevice.

virtual FXuval FX::QIODeviceS::writeBlockTo ( FXfval  pos,
const char *  data,
FXuval  maxlen 
) [virtual, inherited]

Default implementation throws an exception.

Implements FX::QIODevice.

Reimplemented in FX::QSSLDevice.

static bool FX::QIODeviceS::waitForData ( QIODeviceS **  signalled,
FXuint  no,
QIODeviceS **  list,
FXuint  waitfor = FXINFINITE 
) [static, inherited]

Waits for more data to become available for reading on any one or more of an array of QIODeviceS's specified by list. Precisely which are those left in the array signalled if it's not NULL with empty members being zero.

Warning:
Beware race conditions caused by waiting on i/o devices which can be read asynchronously by other threads
Note:
This is a thread cancellation point

static FXuint FX::QIODeviceS::waitForDataMax (  )  throw () [static, inherited]

Returns the maximum number of QIODeviceS's which can be waited for at once.

FXuint FX::QIODevice::flags (  )  const [inline, inherited]

Returns the flags of this device.

FXuint FX::QIODevice::mode (  )  const [inline, inherited]

Returns the mode of this device

See also:
QIODeviceOpenFlags

FXuint FX::QIODevice::state (  )  const [inline, inherited]

Returns the state of this device

See also:
QIODeviceStateFlags

CRLFType FX::QIODevice::crlfFormat (  )  const [inline, inherited]

Returns the CR/LF format of this device.

void FX::QIODevice::setCRLFFormat ( CRLFType  type  )  [inline, inherited]

Sets the CR/LF format for output of this device.

UnicodeType FX::QIODevice::unicodeTranslation (  )  const [inline, inherited]

Returns the unicode translation of this device.

void FX::QIODevice::setUnicodeTranslation ( UnicodeType  type  )  [inline, inherited]

Sets the unicode translation of this device.

bool FX::QIODevice::isBuffered (  )  const [inline, inherited]

Returns true if the device is buffered.

bool FX::QIODevice::isRaw (  )  const [inline, inherited]

Returns true if the device is unbuffered.

bool FX::QIODevice::isTranslated (  )  const [inline, inherited]

Returns true if the device is LR/CF translated.

bool FX::QIODevice::isUTF16Translated (  )  const [inline, inherited]

Returns true if the device is UTF-16 translated.

bool FX::QIODevice::isUTF32Translated (  )  const [inline, inherited]

Returns true if the device is UTF-32 translated.

bool FX::QIODevice::isReadable (  )  const [inline, inherited]

Returns true if the device is readable.

bool FX::QIODevice::isWriteable (  )  const [inline, inherited]

Returns true if the device is writeable.

bool FX::QIODevice::isReadWrite (  )  const [inline, inherited]

Returns true if the device is readable & writeable.

bool FX::QIODevice::isClosed (  )  const [inline, inherited]

Returns true if the device is closed.

bool FX::QIODevice::isOpen (  )  const [inline, inherited]

Returns true if the device is opened.

virtual const FXACL& FX::QIODevice::permissions (  )  const [virtual, inherited]

Returns the ACL for this device.

Reimplemented in FX::QBlkSocket, FX::QFile, FX::QMemMap, FX::QPipe, and FX::QSSLDevice.

virtual void FX::QIODevice::setPermissions ( const FXACL  )  [virtual, inherited]

Sets the ACL for this device.

Reimplemented in FX::QFile, FX::QMemMap, FX::QPipe, and FX::QSSLDevice.

virtual FXuval FX::QIODevice::readLine ( char *  data,
FXuval  maxlen 
) [virtual, inherited]

Reads data until an end-of-line or maxlen is exceeded.

virtual int FX::QIODevice::getch (  )  [virtual, inherited]

Reads a single byte. Returns -1 for no data found.

Reimplemented in FX::QBuffer, FX::QBZip2Device, FX::QGZipDevice, and FX::QMemMap.

virtual int FX::QIODevice::putch ( int  c  )  [virtual, inherited]

Writes a single byte.

Reimplemented in FX::QBuffer, FX::QBZip2Device, FX::QGZipDevice, and FX::QMemMap.

static UnicodeType FX::QIODevice::determineUnicodeType ( FXuchar *  data,
FXuval  len 
) throw () [static, inherited]

Looks at a sample of data and determines what kind of Unicode text it is, returning UnicodeType::NoTranslation if it isn't text. This routine isn't foolproof, but it's a good guess

static FXuval FX::QIODevice::applyCRLF ( FXuchar *FXRESTRICT  output,
const FXuchar *FXRESTRICT  input,
FXuval  outputlen,
FXuval &  inputlen,
CRLFType  crlftype = Default,
UnicodeType  utftype = NoTranslation 
) [static, inherited]

Applies CR/LF and optional UTF-x translation returning bytes output. If outputlen would run out before inputlen can be exhausted it will return early (eg; if mid newline, or mid UTF-x sequence). You should rewind processing to the difference between entrant inputlen and returned inputlen.

static FXuval FX::QIODevice::removeCRLF ( FXuchar *FXRESTRICT  output,
const FXuchar *FXRESTRICT  input,
FXuval  outputlen,
FXuval &  inputlen,
UnicodeType  utftype = NoTranslation 
) [static, inherited]

Removes CR/LF translation intelligently (ie; self-adjusts to MS-DOS, Unix and MacOS formats or any mixture of these) and can perform optional UTF-x translation, returning bytes output. If outputlen would run out before inputlen can be exhausted it will return early (eg; if mid newline, or mid UTF-x sequence). You should rewind processing to the difference between entrant inputlen and returned inputlen.

FXfval FX::QIODevice::shredData ( FXfval  offset,
FXfval  len = (FXfval)-1 
) [inherited]

Destroys the len bytes of data from offset offset into the file. Restores the file pointer afterwards and returns how much data was shredded before end of file if encountered. You must have the device open for both reading and writing for this call to succeed.

void FX::QIODevice::setFlags ( int  f  )  [inline, protected, inherited]

Sets the flags.

void FX::QIODevice::setMode ( int  m  )  [inline, protected, inherited]

Sets the mode.

void FX::QIODevice::setState ( int  s  )  [inline, protected, inherited]

Sets the state.


Friends And Related Function Documentation

FXAPI FXStream& operator<< ( FXStream s,
QIODevice i 
) [friend, inherited]

Appends the contents of an i/o device to stream s

Warning:
This operation is not thread-safe

FXAPI FXStream& operator>> ( FXStream s,
QIODevice i 
) [friend, inherited]

Reads all available contents of the stream s to an i/o device, replacing its current contents and resetting the file pointer to the start

Warning:
This operation is not thread-safe


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

(C) 2002-2008 Niall Douglas. Some parts (C) to assorted authors.
Generated on Fri Jun 13 22:28:11 2008 for TnFOX by doxygen v1.5.6