00001 /* 00002 * qchannel.h 00003 * 00004 * Class for implementing a serial queue channel in memory. 00005 * 00006 * Portable Windows Library 00007 * 00008 * Copyright (c) 2001 Equivalence Pty. Ltd. 00009 * 00010 * The contents of this file are subject to the Mozilla Public License 00011 * Version 1.0 (the "License"); you may not use this file except in 00012 * compliance with the License. You may obtain a copy of the License at 00013 * http://www.mozilla.org/MPL/ 00014 * 00015 * Software distributed under the License is distributed on an "AS IS" 00016 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 00017 * the License for the specific language governing rights and limitations 00018 * under the License. 00019 * 00020 * The Original Code is Portable Windows Library. 00021 * 00022 * The Initial Developer of the Original Code is Equivalence Pty. Ltd. 00023 * 00024 * Contributor(s): ______________________________________. 00025 * 00026 * $Log: qchannel.h,v $ 00027 * Revision 1.5 2007/04/19 04:33:53 csoutheren 00028 * Fixed problems with pre-compiled headers 00029 * 00030 * Revision 1.4 2005/11/30 12:47:37 csoutheren 00031 * Removed tabs, reformatted some code, and changed tags for Doxygen 00032 * 00033 * Revision 1.3 2004/11/11 07:34:50 csoutheren 00034 * Added #include <ptlib.h> 00035 * 00036 * Revision 1.2 2002/09/16 01:08:59 robertj 00037 * Added #define so can select if #pragma interface/implementation is used on 00038 * platform basis (eg MacOS) rather than compiler, thanks Robert Monaghan. 00039 * 00040 * Revision 1.1 2001/07/10 03:07:07 robertj 00041 * Added queue channel and delay channel classes to ptclib. 00042 * 00043 */ 00044 00045 #ifndef _QCHANNEL_H 00046 #define _QCHANNEL_H 00047 00048 00049 #ifdef P_USE_PRAGMA 00050 #pragma interface 00051 #endif 00052 00053 #ifndef _PTLIB_H 00054 #include <ptlib.h> 00055 #endif 00056 00070 class PQueueChannel : public PChannel 00071 { 00072 PCLASSINFO(PQueueChannel, PChannel); 00073 public: 00078 PQueueChannel( 00079 PINDEX queueSize = 0 00080 ); 00081 00084 ~PQueueChannel(); 00086 00087 00101 virtual BOOL Read( 00102 void * buf, 00103 PINDEX len 00104 ); 00105 00115 virtual BOOL Write( 00116 const void * buf, 00117 PINDEX len 00118 ); 00119 00123 virtual BOOL Close(); 00125 00126 00131 virtual BOOL Open( 00132 PINDEX queueSize 00133 ); 00134 00136 PINDEX GetSize() const { return queueSize; } 00137 00139 PINDEX GetLength() const { return queueLength; } 00141 00142 protected: 00143 PMutex mutex; 00144 BYTE * queueBuffer; 00145 PINDEX queueSize, queueLength, enqueuePos, dequeuePos; 00146 PSyncPoint unempty; 00147 PSyncPoint unfull; 00148 }; 00149 00150 00151 #endif // _QCHANNEL_H 00152 00153 00154 // End Of File ///////////////////////////////////////////////////////////////