Logo Search packages:      
Sourcecode: pwlib version File versions  Download package

PQueueChannel Class Reference

#include <qchannel.h>

Inheritance diagram for PQueueChannel:

PChannel PObject

List of all members.

Detailed Description

Class for implementing a serial queue channel in memory. This implements a simple memory based First In First Out queue. Data written to an instance of the class may be read from the same instance at some later time.

The queue will block the read for the Read Timeout if the queue is empty. Similarly a write will be clocked for Write Timeout if the queue is full.

If there is any data to be read then it returns immediately with those bytes, so you must check the GetLastReadCount() to determine the actual number of bytes read and not rely on the count being passed into the read function.

Definition at line 65 of file qchannel.h.

Miscellaneous functions

void AbortCommandString ()
BOOL SendCommandString (const PString &command)
BOOL SetBufferSize (PINDEX newSize)
virtual BOOL Shutdown (ShutdownValue option)
enum  ShutdownValue { ShutdownRead = 0, ShutdownWrite = 1, ShutdownReadAndWrite = 2 }

Comparison functions

virtual Comparison CompareObjectMemoryDirect (const PObject &obj) const
bool operator!= (const PObject &obj) const
bool operator< (const PObject &obj) const
bool operator<= (const PObject &obj) const
bool operator== (const PObject &obj) const
bool operator> (const PObject &obj) const
bool operator>= (const PObject &obj) const
enum  Comparison { LessThan = -1, EqualTo = 0, GreaterThan = 1 }

Run Time Type functions

virtual const char * GetClass (unsigned=0) const
virtual BOOL InternalIsDescendant (const char *clsName) const
BOOL IsClass (const char *cls) const
static const char * Class ()

Error functions

Errors GetErrorCode (ErrorGroup group=NumErrorGroups) const
int GetErrorNumber (ErrorGroup group=NumErrorGroups) const
virtual PString GetErrorText (ErrorGroup group=NumErrorGroups) const
enum  ErrorGroup { LastReadError, LastWriteError, LastGeneralError, NumErrorGroups }
enum  Errors {
  NoError, NotFound, FileExists, DiskFull,
  AccessDenied, DeviceInUse, BadParameter, NoMemory,
  NotOpen, Timeout, Interrupted, BufferTooSmall,
  Miscellaneous, ProtocolFailure, NumNormalisedErrors
static PString GetErrorText (Errors lastError, int osError=0)

I/O functions

virtual void PrintOn (ostream &strm) const
virtual void ReadFrom (istream &strm)
ostream & operator<< (ostream &strm, const PObject &obj)
istream & operator>> (istream &strm, PObject &obj)

Scattered read/write functions

virtual BOOL Read (const VectorOfSlice &slices)
virtual BOOL Write (const VectorOfSlice &slices)
typedef std::vector< SliceVectorOfSlice

Public Types

enum  PXBlockType { PXReadBlock, PXWriteBlock, PXAcceptBlock, PXConnectBlock }

Public Member Functions

Miscellaneous functions
virtual PObjectClone () const
Overrides from class PChannel
virtual BOOL Close ()
virtual BOOL Read (void *buf, PINDEX len)
virtual BOOL Write (const void *buf, PINDEX len)
Overrides from class PObject
virtual Comparison Compare (const PObject &obj) const
virtual PINDEX HashFunction () const
Information functions
virtual PChannelGetBaseReadChannel () const
virtual PChannelGetBaseWriteChannel () const
int GetHandle () const
virtual PString GetName () const
virtual BOOL IsOpen () const
Reading functions
virtual PINDEX GetLastReadCount () const
PTimeInterval GetReadTimeout () const
virtual void OnReadComplete (void *buf, PINDEX len)
virtual BOOL ReadAsync (void *buf, PINDEX len)
BOOL ReadBlock (void *buf, PINDEX len)
virtual int ReadChar ()
PString ReadString (PINDEX len)
void SetReadTimeout (const PTimeInterval &time)
Writing functions
virtual PINDEX GetLastWriteCount () const
PTimeInterval GetWriteTimeout () const
virtual void OnWriteComplete (const void *buf, PINDEX len)
void SetWriteTimeout (const PTimeInterval &time)
virtual BOOL WriteAsync (const void *buf, PINDEX len)
BOOL WriteChar (int c)
BOOL WriteString (const PString &str)
Queue manipulation functions
PINDEX GetLength () const
 Get the current queue length.
PINDEX GetSize () const
 Get the queue size.
virtual BOOL Open (PINDEX queueSize)
 PQueueChannel (PINDEX queueSize=0)
 ~PQueueChannel ()

Static Public Member Functions

static BOOL ConvertOSError (int libcReturnValue, Errors &lastError, int &osError)

Protected Member Functions

virtual BOOL ConvertOSError (int libcReturnValue, ErrorGroup group=LastGeneralError)
int PXClose ()
BOOL PXSetIOBlock (PXBlockType type, const PTimeInterval &timeout)
int ReadCharWithTimeout (PTimeInterval &timeout)
BOOL ReceiveCommandString (int nextChar, const PString &reply, PINDEX &pos, PINDEX start)
BOOL SetErrorValues (Errors errorCode, int osError, ErrorGroup group=LastGeneralError)

Protected Attributes

PString channelName
PINDEX dequeuePos
PINDEX enqueuePos
Errors lastErrorCode [NumErrorGroups+1]
 The platform independant error code.
int lastErrorNumber [NumErrorGroups+1]
 The operating system error number (eg as returned by errno).
PINDEX lastReadCount
 Number of byte last read by the Read() function.
PINDEX lastWriteCount
 Number of byte last written by the Write() function.
PMutex mutex
int os_handle
 The operating system file handle return by standard open() function.
PXBlockType px_lastBlockType
PMutex px_selectMutex
PMutex px_threadMutex
PMutex px_writeMutex
BYTE * queueBuffer
PINDEX queueLength
PINDEX queueSize
PTimeInterval readTimeout
 Timeout for read operations.
PSyncPoint unempty
PSyncPoint unfull
PTimeInterval writeTimeout
 Timeout for write operations.

Private Member Functions

 PCLASSINFO (PQueueChannel, PChannel)

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

Generated by  Doxygen 1.6.0   Back to index