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

PDelayChannel Class Reference

#include <delaychan.h>

Inheritance diagram for PDelayChannel:

PIndirectChannel PChannel PObject

List of all members.


Detailed Description

Class for implementing a "delay line" channel. This indirect channel can be placed in a channel I/O chain to limit the speed of I/O. This can be useful if blocking is not available and buffers could be overwritten if the I/O occurs at full speed.

There are two modes of operation. In stream more, data can be read/written no faster than a fixed time for a fixed number of bytes. So, for example, you can say than 320 bytes must take 20 milliseconds, and thus if the application writes 640 byets it will delay 40 milliseconds before the next write.

In frame mode, the rate limiting applies to individual read or write operations. So you can say that each read takes 30 milliseconds even if on 4 bytes is read, and the same time if 24 bytes are read.

Definition at line 97 of file delaychan.h.


Comparison functions

enum  Comparison { LessThan = -1, EqualTo = 0, GreaterThan = 1 }
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

Error functions

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

Construction

enum  Mode { DelayReadsOnly, DelayWritesOnly, DelayReadsAndWrites }
 PDelayChannel (Mode mode, unsigned frameDelay, PINDEX frameSize=0, unsigned maximumSlip=250, unsigned minimumDelay=10)

Miscellaneous functions

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

Scattered read/write functions

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

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 ()

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)

Public Types

enum  PXBlockType { PXReadBlock, PXWriteBlock, PXAcceptBlock, PXConnectBlock }

Public Member Functions

Miscellaneous functions
virtual PObjectClone () const
Overrides from class PChannel
virtual BOOL Close ()
virtual PChannelGetBaseReadChannel () const
virtual PChannelGetBaseWriteChannel () const
virtual PString GetErrorText (ErrorGroup group=NumErrorGroups) const
virtual PString GetName () const
virtual BOOL IsOpen () const
virtual BOOL Shutdown (ShutdownValue option)
Overrides from class PObject
Comparison Compare (const PObject &obj) const
Information functions
int GetHandle () 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)
Channel establish functions
PChannelGetReadChannel () const
PChannelGetWriteChannel () const
BOOL Open (PChannel *readChannel, PChannel *writeChannel, BOOL autoDeleteRead=TRUE, BOOL autoDeleteWrite=TRUE)
BOOL Open (PChannel *channel, BOOL autoDelete=TRUE)
BOOL Open (PChannel &channel)
BOOL SetReadChannel (PChannel *channel, BOOL autoDelete=TRUE)
BOOL SetWriteChannel (PChannel *channel, BOOL autoDelete=TRUE)
Overrides from class PObject
virtual PINDEX HashFunction () const
Overrides from class PChannel
virtual BOOL Read (void *buf, PINDEX len)
virtual BOOL Write (const void *buf, PINDEX len)

Static Public Member Functions

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

Protected Member Functions

virtual BOOL ConvertOSError (int libcReturnValue, ErrorGroup group=LastGeneralError)
virtual BOOL OnOpen ()
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)
virtual void Wait (PINDEX count, PTimeInterval &nextTick)

Protected Attributes

PString channelName
PReadWriteMutex channelPointerMutex
 Race condition prevention on closing channel.
unsigned frameDelay
PINDEX frameSize
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.
PTimeInterval maximumSlip
PTimeInterval minimumDelay
Mode mode
PTimeInterval nextReadTick
PTimeInterval nextWriteTick
int os_handle
 The operating system file handle return by standard open() function.
PXBlockType px_lastBlockType
PThreadpx_readThread
PMutex px_selectMutex
PThreadpx_selectThread
PMutex px_threadMutex
PMutex px_writeMutex
PThreadpx_writeThread
BOOL readAutoDelete
 Automatically delete read channel on destruction.
PChannelreadChannel
 Channel for read operations.
PTimeInterval readTimeout
 Timeout for read operations.
BOOL writeAutoDelete
 Automatically delete write channel on destruction.
PChannelwriteChannel
 Channel for write operations.
PTimeInterval writeTimeout
 Timeout for write operations.

Private Member Functions

 PCLASSINFO (PDelayChannel, PIndirectChannel)

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

Generated by  Doxygen 1.6.0   Back to index