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 * $Revision: 20385 $ 00027 * $Author: rjongbloed $ 00028 * $Date: 2008-06-04 10:40:38 +0000 (Wed, 04 Jun 2008) $ 00029 */ 00030 00031 #ifndef _QCHANNEL_H 00032 #define _QCHANNEL_H 00033 00034 00035 #ifdef P_USE_PRAGMA 00036 #pragma interface 00037 #endif 00038 00039 #ifndef _PTLIB_H 00040 #include <ptlib.h> 00041 #endif 00042 00056 class PQueueChannel : public PChannel 00057 { 00058 PCLASSINFO(PQueueChannel, PChannel); 00059 public: 00064 PQueueChannel( 00065 PINDEX queueSize = 0 00066 ); 00067 00070 ~PQueueChannel(); 00072 00073 00087 virtual PBoolean Read( 00088 void * buf, 00089 PINDEX len 00090 ); 00091 00101 virtual PBoolean Write( 00102 const void * buf, 00103 PINDEX len 00104 ); 00105 00109 virtual PBoolean Close(); 00111 00112 00117 virtual PBoolean Open( 00118 PINDEX queueSize 00119 ); 00120 00122 PINDEX GetSize() const { return queueSize; } 00123 00125 PINDEX GetLength() const { return queueLength; } 00127 00128 protected: 00129 PMutex mutex; 00130 BYTE * queueBuffer; 00131 PINDEX queueSize, queueLength, enqueuePos, dequeuePos; 00132 PSyncPoint unempty; 00133 PSyncPoint unfull; 00134 }; 00135 00136 00137 #endif // _QCHANNEL_H 00138 00139 00140 // End Of File ///////////////////////////////////////////////////////////////