PTLib  Version 2.18.8
 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 
27 #ifndef PTLIB_QCHANNEL_H
28 #define PTLIB_QCHANNEL_H
29 
30 
31 #ifdef P_USE_PRAGMA
32 #pragma interface
33 #endif
34 
36 
37 
50 class PQueueChannel : public PChannel
51 {
52  PCLASSINFO(PQueueChannel, PChannel);
53  public:
59  PINDEX queueSize = 0
60  );
61 
64  ~PQueueChannel();
66 
67 
75  virtual PString GetName() const { return "Queue"; }
76 
88  virtual PBoolean Read(
89  void * buf,
90  PINDEX len
91  );
92 
102  virtual PBoolean Write(
103  const void * buf,
104  PINDEX len
105  );
106 
110  virtual PBoolean Close();
112 
113 
118  virtual PBoolean Open(
119  PINDEX queueSize
120  );
121 
123  PINDEX GetSize() const { return queueSize; }
124 
126  PINDEX GetLength() const { return queueLength; }
128 
129  protected:
130  PDECLARE_MUTEX(mutex);
131  BYTE * queueBuffer;
132  PINDEX queueSize, queueLength, enqueuePos, dequeuePos;
135 };
136 
137 
138 #endif // PTLIB_QCHANNEL_H
139 
140 
141 // End Of File ///////////////////////////////////////////////////////////////
#define PCLASSINFO(cls, par)
Declare all the standard PTLib class information.
Definition: object.h:2164
PSyncPoint unempty
Definition: qchannel.h:133
PINDEX queueSize
Definition: qchannel.h:132
PINDEX GetSize() const
Get the queue size.
Definition: qchannel.h:123
virtual PString GetName() const
Get the platform and I/O channel type name of the channel.
Definition: qchannel.h:75
PSyncPoint unfull
Definition: qchannel.h:134
#define PDECLARE_MUTEX(...)
Definition: mutex.h:200
BYTE * queueBuffer
Definition: qchannel.h:131
Abstract class defining I/O channel semantics.
Definition: channel.h:103
bool PBoolean
Definition: object.h:174
The character string class.
Definition: pstring.h:108
#define P_PUSH_MSVC_WARNINGS(warnings)
Definition: object.h:153
Class for implementing a serial queue channel in memory.
Definition: qchannel.h:50
This class defines a thread synchronisation object.
Definition: syncpoint.h:63
PINDEX GetLength() const
Get the current queue length.
Definition: qchannel.h:126