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.2 2002/09/16 01:08:59 robertj 00028 * Added #define so can select if #pragma interface/implementation is used on 00029 * platform basis (eg MacOS) rather than compiler, thanks Robert Monaghan. 00030 * 00031 * Revision 1.1 2001/07/10 03:07:07 robertj 00032 * Added queue channel and delay channel classes to ptclib. 00033 * 00034 */ 00035 00036 #ifndef _QCHANNEL_H 00037 #define _QCHANNEL_H 00038 00039 00040 #ifdef P_USE_PRAGMA 00041 #pragma interface 00042 #endif 00043 00044 00058 class PQueueChannel : public PChannel 00059 { 00060 PCLASSINFO(PQueueChannel, PChannel); 00061 public: 00066 PQueueChannel( 00067 PINDEX queueSize = 0 00068 ); 00069 00072 ~PQueueChannel(); 00074 00075 00089 virtual BOOL Read( 00090 void * buf, 00091 PINDEX len 00092 ); 00093 00103 virtual BOOL Write( 00104 const void * buf, 00105 PINDEX len 00106 ); 00107 00111 virtual BOOL Close(); 00113 00114 00119 virtual BOOL Open( 00120 PINDEX queueSize 00121 ); 00122 00124 PINDEX GetSize() const { return queueSize; } 00125 00127 PINDEX GetLength() const { return queueLength; } 00129 00130 protected: 00131 PMutex mutex; 00132 BYTE * queueBuffer; 00133 PINDEX queueSize, queueLength, enqueuePos, dequeuePos; 00134 PSyncPoint unempty; 00135 PSyncPoint unfull; 00136 }; 00137 00138 00139 #endif // _QCHANNEL_H 00140 00141 00142 // End Of File ///////////////////////////////////////////////////////////////