PTLib  Version 2.14.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
qchannel.h
Go to the documentation of this file.
1 /*
2  * qchannel.h
3  *
4  * Class for implementing a serial queue channel in memory.
5  *
6  * Portable Windows Library
7  *
8  * Copyright (c) 2001 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  * Contributor(s): ______________________________________.
25  *
26  * $Revision: 28729 $
27  * $Author: csoutheren $
28  * $Date: 2013-01-02 10:20:47 +1100 (Wed, 02 Jan 2013) $
29  */
30 
31 #ifndef PTLIB_QCHANNEL_H
32 #define PTLIB_QCHANNEL_H
33 
34 
35 #ifdef P_USE_PRAGMA
36 #pragma interface
37 #endif
38 
40 
41 
54 class PQueueChannel : public PChannel
55 {
56  PCLASSINFO(PQueueChannel, PChannel);
57  public:
63  PINDEX queueSize = 0
64  );
65 
68  ~PQueueChannel();
70 
71 
85  virtual PBoolean Read(
86  void * buf,
87  PINDEX len
88  );
89 
99  virtual PBoolean Write(
100  const void * buf,
101  PINDEX len
102  );
103 
107  virtual PBoolean Close();
109 
110 
115  virtual PBoolean Open(
116  PINDEX queueSize
117  );
118 
120  PINDEX GetSize() const { return queueSize; }
121 
123  PINDEX GetLength() const { return queueLength; }
125 
126  protected:
128  BYTE * queueBuffer;
129  PINDEX queueSize, queueLength, enqueuePos, dequeuePos;
132 };
133 
134 
135 #endif // PTLIB_QCHANNEL_H
136 
137 
138 // End Of File ///////////////////////////////////////////////////////////////