PWLib  1.10.10
Protected Member Functions | Protected Attributes
PIndirectChannel Class Reference

#include <indchan.h>

Inheritance diagram for PIndirectChannel:
PChannel PObject PDelayChannel PInternetProtocol PRFC822Channel PSNMP PSSLChannel PVXMLSession PVXMLChannel PFTP PHTTP PPOP3 PSMTP PSNMPClient PSNMPServer PFTPClient PFTPServer PHTTPClient PPOP3Client PPOP3Server PSMTPClient PSMTPServer

List of all members.

Public Member Functions

Construction
 PIndirectChannel ()
 ~PIndirectChannel ()
 Close the indirect channel, deleting read/write channels if desired.
Overrides from class PObject
Comparison Compare (const PObject &obj) const
Overrides from class PChannel
virtual PString GetName () const
virtual BOOL Close ()
virtual BOOL IsOpen () const
virtual BOOL Read (void *buf, PINDEX len)
virtual BOOL Write (const void *buf, PINDEX len)
virtual BOOL Shutdown (ShutdownValue option)
virtual PChannelGetBaseReadChannel () const
virtual PChannelGetBaseWriteChannel () const
virtual PString GetErrorText (ErrorGroup group=NumErrorGroups) const
Channel establish functions
BOOL Open (PChannel &channel)
BOOL Open (PChannel *channel, BOOL autoDelete=TRUE)
BOOL Open (PChannel *readChannel, PChannel *writeChannel, BOOL autoDeleteRead=TRUE, BOOL autoDeleteWrite=TRUE)
PChannelGetReadChannel () const
BOOL SetReadChannel (PChannel *channel, BOOL autoDelete=TRUE)
PChannelGetWriteChannel () const
BOOL SetWriteChannel (PChannel *channel, BOOL autoDelete=TRUE)

Protected Member Functions

virtual BOOL OnOpen ()

Protected Attributes

PChannelreadChannel
 Channel for read operations.
BOOL readAutoDelete
 Automatically delete read channel on destruction.
PChannelwriteChannel
 Channel for write operations.
BOOL writeAutoDelete
 Automatically delete write channel on destruction.
PReadWriteMutex channelPointerMutex
 Race condition prevention on closing channel.

Detailed Description

This is a channel that operates indirectly through another channel(s). This allows for a protocol to operate through a "channel" mechanism and for its low level byte exchange (Read and Write) to operate via a completely different channel, eg TCP or Serial port etc.


Constructor & Destructor Documentation

Create a new indirect channel without any channels to redirect to. If an attempt to read or write is made before Open() is called the the functions will assert.

Close the indirect channel, deleting read/write channels if desired.

References Close().


Member Function Documentation

virtual BOOL PIndirectChannel::Close ( ) [virtual]

Close the channel. This will detach itself from the read and write channels and delete both of them if they are auto delete.

Returns:
TRUE if the channel is closed.

Reimplemented from PChannel.

Reimplemented in PRFC822Channel, PVXMLChannel, PPOP3Client, PSSLChannel, PVXMLSession, PSMTPClient, and PFTPClient.

Referenced by ~PIndirectChannel().

Comparison PIndirectChannel::Compare ( const PObject obj) const [virtual]

Determine if the two objects refer to the same indirect channel. This actually compares the channel pointers.

Returns:
EqualTo if channel pointer identical.
Parameters:
objAnother indirect channel to compare against.

Reimplemented from PChannel.

virtual PChannel* PIndirectChannel::GetBaseReadChannel ( ) const [virtual]

This function returns the eventual base channel for reading of a series of indirect channels provided by descendents of PIndirectChannel#.

The behaviour for this function is to return "this".

Returns:
Pointer to base I/O channel for the indirect channel.

Reimplemented from PChannel.

virtual PChannel* PIndirectChannel::GetBaseWriteChannel ( ) const [virtual]

This function returns the eventual base channel for writing of a series of indirect channels provided by descendents of PIndirectChannel#.

The behaviour for this function is to return "this".

Returns:
Pointer to base I/O channel for the indirect channel.

Reimplemented from PChannel.

virtual PString PIndirectChannel::GetErrorText ( ErrorGroup  group = NumErrorGroups) const [virtual]

Get error message description. Return a string indicating the error message that may be displayed to the user. The error for the last I/O operation in this object is used.

Returns:
Operating System error description string.
Parameters:
groupError group to get

Reimplemented from PChannel.

Reimplemented in PSSLChannel.

virtual PString PIndirectChannel::GetName ( ) const [virtual]

Get the name of the channel. This is a combination of the channel pointers names (or simply the channel pointers name if the read and write channels are the same) or empty string if both null.

Returns:
string for the channel names.

Reimplemented from PChannel.

Get the channel used for read operations.

Returns:
pointer to the read channel.

References readChannel.

Get the channel used for write operations.

Returns:
pointer to the write channel.

References writeChannel.

virtual BOOL PIndirectChannel::IsOpen ( ) const [virtual]

Determine if the channel is currently open and read and write operations can be executed on it. For example, in the PFile# class it returns if the file is currently open.

Returns:
TRUE if the channel is open.

Reimplemented from PChannel.

Reimplemented in PVXMLChannel.

virtual BOOL PIndirectChannel::OnOpen ( ) [protected, virtual]

This callback is executed when the Open() function is called with open channels. It may be used by descendent channels to do any handshaking required by the protocol that channel embodies.

The default behaviour is to simply return TRUE.

Returns:
Returns TRUE if the protocol handshaking is successful.

Reimplemented in PRFC822Channel, PPOP3Server, PPOP3Client, PSSLChannel, PFTPServer, PSMTPServer, PFTPClient, and PSMTPClient.

BOOL PIndirectChannel::Open ( PChannel channel)

Set the channel for both read and write operations. This then checks that they are open and then calls the OnOpen() virtual function. If it in turn returns TRUE then the Open() function returns success.

Returns:
TRUE if both channels are set, open and OnOpen() returns TRUE.
Parameters:
channelChannel to be used for both read and write operations.
BOOL PIndirectChannel::Open ( PChannel channel,
BOOL  autoDelete = TRUE 
)

Set the channel for both read and write operations. This then checks that they are open and then calls the OnOpen() virtual function. If it in turn returns TRUE then the Open() function returns success.

The channel pointed to by #channel# may be automatically deleted when the PIndirectChannel is destroyed or a new subchannel opened.

Returns:
TRUE if both channels are set, open and OnOpen() returns TRUE.
Parameters:
channelChannel to be used for both read and write operations.
autoDeleteAutomatically delete the channel
BOOL PIndirectChannel::Open ( PChannel readChannel,
PChannel writeChannel,
BOOL  autoDeleteRead = TRUE,
BOOL  autoDeleteWrite = TRUE 
)

Set the channel for both read and write operations. This then checks that they are open and then calls the OnOpen() virtual function. If it in turn returns TRUE then the Open() function returns success.

The channels pointed to by readChannel# and writeChannel# may be automatically deleted when the PIndirectChannel is destroyed or a new subchannel opened.

Returns:
TRUE if both channels are set, open and OnOpen() returns TRUE.
Parameters:
readChannelChannel to be used for both read operations.
writeChannelChannel to be used for both write operations.
autoDeleteReadAutomatically delete the read channel
autoDeleteWriteAutomatically delete the write channel
virtual BOOL PIndirectChannel::Read ( void *  buf,
PINDEX  len 
) [virtual]

Low level read from the channel. This function may block until the requested number of characters were read or the read timeout was reached. The GetLastReadCount() function returns the actual number of bytes read.

This will use the readChannel# pointer to actually do the read. If readChannel# is null the this asserts.

The GetErrorCode() function should be consulted after Read() returns FALSE to determine what caused the failure.

Returns:
TRUE indicates that at least one character was read from the channel. FALSE means no bytes were read due to timeout or some other I/O error.
Parameters:
bufPointer to a block of memory to receive the read bytes.
lenMaximum number of bytes to read into the buffer.

Reimplemented from PChannel.

Reimplemented in PVXMLChannel, PSSLChannel, PInternetProtocol, and PDelayChannel.

BOOL PIndirectChannel::SetReadChannel ( PChannel channel,
BOOL  autoDelete = TRUE 
)

Set the channel for read operations.

Returns:
Returns TRUE if both channels are set and are both open.
Parameters:
channelChannel to be used for both read operations.
autoDeleteAutomatically delete the channel
BOOL PIndirectChannel::SetWriteChannel ( PChannel channel,
BOOL  autoDelete = TRUE 
)

Set the channel for read operations.

Returns:
Returns TRUE if both channels are set and are both open.
Parameters:
channelChannel to be used for both write operations.
autoDeleteAutomatically delete the channel
virtual BOOL PIndirectChannel::Shutdown ( ShutdownValue  option) [virtual]

Close one or both of the data streams associated with a channel.

The behavour here is to pass the shutdown on to its read and write channels.

Returns:
TRUE if the shutdown was successfully performed.
Parameters:
optionFlag for shut down of read, write or both.

Reimplemented from PChannel.

Reimplemented in PSSLChannel.

virtual BOOL PIndirectChannel::Write ( const void *  buf,
PINDEX  len 
) [virtual]

Low level write to the channel. This function will block until the requested number of characters are written or the write timeout is reached. The GetLastWriteCount() function returns the actual number of bytes written.

This will use the writeChannel# pointer to actually do the write. If writeChannel# is null the this asserts.

The GetErrorCode() function should be consulted after Write() returns FALSE to determine what caused the failure.

Returns:
TRUE if at least len bytes were written to the channel.
Parameters:
bufPointer to a block of memory to write.
lenNumber of bytes to write.

Reimplemented from PChannel.

Reimplemented in PRFC822Channel, PVXMLChannel, PSSLChannel, PInternetProtocol, and PDelayChannel.


Member Data Documentation

Race condition prevention on closing channel.

Automatically delete read channel on destruction.

Channel for read operations.

Referenced by GetReadChannel().

Automatically delete write channel on destruction.

Channel for write operations.

Referenced by GetWriteChannel().


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