PTLib  Version 2.10.10
indchan.h
Go to the documentation of this file.
1 /*
2  * indchan.h
3  *
4  * Indirect I/O channel class.
5  *
6  * Portable Windows Library
7  *
8  * Copyright (c) 1993-1998 Equivalence Pty. Ltd.
9  *
10  * The contents of this file are subject to the Mozilla Public License
11  * Version 1.0 (the "License"); you may not use this file except in
12  * compliance with the License. You may obtain a copy of the License at
13  * http://www.mozilla.org/MPL/
14  *
15  * Software distributed under the License is distributed on an "AS IS"
16  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
17  * the License for the specific language governing rights and limitations
18  * under the License.
19  *
20  * The Original Code is Portable Windows Library.
21  *
22  * The Initial Developer of the Original Code is Equivalence Pty. Ltd.
23  *
24  * Portions are Copyright (C) 1993 Free Software Foundation, Inc.
25  * All Rights Reserved.
26  *
27  * Contributor(s): ______________________________________.
28  *
29  * $Revision: 26933 $
30  * $Author: rjongbloed $
31  * $Date: 2012-02-02 21:17:20 -0600 (Thu, 02 Feb 2012) $
32  */
33 
34 #ifndef PTLIB_INDIRECTCHANNEL_H
35 #define PTLIB_INDIRECTCHANNEL_H
36 
37 #ifdef P_USE_PRAGMA
38 #pragma interface
39 #endif
40 
41 #include <ptlib/channel.h>
42 #include <ptlib/syncthrd.h>
43 
49 class PIndirectChannel : public PChannel
50 {
51  PCLASSINFO(PIndirectChannel, PChannel);
52 
53  public:
61 
65 
66 
76  const PObject & obj
77  ) const;
79 
80 
90  virtual PString GetName() const;
91 
98  virtual PBoolean Close();
99 
107  virtual PBoolean IsOpen() const;
108 
124  virtual PBoolean Read(
125  void * buf,
126  PINDEX len
127  );
128 
143  virtual PBoolean Write(
144  const void * buf,
145  PINDEX len
146  );
147 
156  virtual PBoolean Shutdown(
157  ShutdownValue option
158  );
159 
167  virtual bool SetLocalEcho(
168  bool localEcho
169  );
170 
171 
180  virtual PChannel * GetBaseReadChannel() const;
181 
190  virtual PChannel * GetBaseWriteChannel() const;
191 
197  virtual PString GetErrorText(
198  ErrorGroup group = NumErrorGroups
199  ) const;
201 
211  PBoolean Open(
212  PChannel & channel
213  );
214 
225  PBoolean Open(
226  PChannel * channel,
227  PBoolean autoDelete = true
228  );
229 
241  PBoolean Open(
244  PBoolean autoDeleteRead = true,
245  PBoolean autoDeleteWrite = true
246  );
247 
253  PChannel * GetReadChannel() const;
254 
260  bool SetReadChannel(
261  PChannel * channel,
262  bool autoDelete = true,
263  bool closeExisting = false
264  );
265 
271  PChannel * GetWriteChannel() const;
272 
279  PChannel * channel,
280  bool autoDelete = true,
281  bool closeExisting = false
282  );
284 
285 
286  protected:
296  virtual PBoolean OnOpen();
297 
298 
299  // Member variables
302 
305 
308 
311 
314 };
315 
316 
317 #endif // PTLIB_INDIRECTCHANNEL_H
318 
319 
320 // End Of File ///////////////////////////////////////////////////////////////
PReadWriteMutex channelPointerMutex
Race condition prevention on closing channel.
Definition: indchan.h:313
Definition: channel.h:569
virtual PString GetErrorText(ErrorGroup group=NumErrorGroups) const
Get error message description.
virtual PString GetName() const
Get the name of the channel.
PBoolean readAutoDelete
Automatically delete read channel on destruction.
Definition: indchan.h:304
Comparison
Result of the comparison operation performed by the Compare() function.
Definition: object.h:1184
virtual PBoolean IsOpen() const
Determine if the channel is currently open and read and write operations can be executed on it...
This is a channel that operates indirectly through another channel(s).
Definition: indchan.h:49
PChannel * readChannel
Channel for read operations.
Definition: indchan.h:301
virtual PBoolean Shutdown(ShutdownValue option)
Close one or both of the data streams associated with a channel.
ShutdownValue
Definition: channel.h:433
PChannel * GetReadChannel() const
Get the channel used for read operations.
virtual PChannel * GetBaseWriteChannel() const
This function returns the eventual base channel for writing of a series of indirect channels provided...
PChannel * GetWriteChannel() const
Get the channel used for write operations.
BOOL PBoolean
Definition: object.h:102
PChannel * writeChannel
Channel for write operations.
Definition: indchan.h:307
Abstract class defining I/O channel semantics.
Definition: channel.h:107
virtual PBoolean Close()
Close the channel.
virtual PChannel * GetBaseReadChannel() const
This function returns the eventual base channel for reading of a series of indirect channels provided...
PIndirectChannel()
Create a new indirect channel without any channels to redirect to.
The character string class.
Definition: pstring.h:108
PBoolean Open(PChannel &channel)
Set the channel for both read and write operations.
Comparison Compare(const PObject &obj) const
Determine if the two objects refer to the same indirect channel.
PBoolean writeAutoDelete
Automatically delete write channel on destruction.
Definition: indchan.h:310
ErrorGroup
Error groups.
Definition: channel.h:565
virtual PBoolean Write(const void *buf, PINDEX len)
Low level write to the channel.
virtual PBoolean OnOpen()
This callback is executed when the Open() function is called with open channels.
virtual bool SetLocalEcho(bool localEcho)
Set local echo mode.
virtual PBoolean Read(void *buf, PINDEX len)
Low level read from the channel.
bool SetReadChannel(PChannel *channel, bool autoDelete=true, bool closeExisting=false)
Set the channel for read operations.
This class defines a thread synchronisation object.
Definition: syncthrd.h:251
Ultimate parent class for all objects in the class library.
Definition: object.h:1118
PBoolean SetWriteChannel(PChannel *channel, bool autoDelete=true, bool closeExisting=false)
Set the channel for read operations.
~PIndirectChannel()
Close the indirect channel, deleting read/write channels if desired.