qchannel.h

Go to the documentation of this file.
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.4  2005/11/30 12:47:37  csoutheren
00028  * Removed tabs, reformatted some code, and changed tags for Doxygen
00029  *
00030  * Revision 1.3  2004/11/11 07:34:50  csoutheren
00031  * Added #include <ptlib.h>
00032  *
00033  * Revision 1.2  2002/09/16 01:08:59  robertj
00034  * Added #define so can select if #pragma interface/implementation is used on
00035  *   platform basis (eg MacOS) rather than compiler, thanks Robert Monaghan.
00036  *
00037  * Revision 1.1  2001/07/10 03:07:07  robertj
00038  * Added queue channel and delay channel classes to ptclib.
00039  *
00040  */
00041 
00042 #ifndef _QCHANNEL_H
00043 #define _QCHANNEL_H
00044 
00045 
00046 #ifdef P_USE_PRAGMA
00047 #pragma interface
00048 #endif
00049 
00050 #include <ptlib.h>
00051 
00065 class PQueueChannel : public PChannel
00066 {
00067     PCLASSINFO(PQueueChannel, PChannel);
00068   public:
00073     PQueueChannel(
00074       PINDEX queueSize = 0   
00075     );
00076 
00079     ~PQueueChannel();
00081 
00082 
00096     virtual BOOL Read(
00097       void * buf,   
00098       PINDEX len    
00099     );
00100 
00110     virtual BOOL Write(
00111       const void * buf, 
00112       PINDEX len        
00113     );
00114 
00118     virtual BOOL Close();
00120 
00121 
00126     virtual BOOL Open(
00127       PINDEX queueSize   
00128     );
00129 
00131     PINDEX GetSize() const { return queueSize; }
00132 
00134     PINDEX GetLength() const { return queueLength; }
00136 
00137   protected:
00138     PMutex     mutex;
00139     BYTE     * queueBuffer;
00140     PINDEX     queueSize, queueLength, enqueuePos, dequeuePos;
00141     PSyncPoint unempty;
00142     PSyncPoint unfull;
00143 };
00144 
00145 
00146 #endif // _QCHANNEL_H
00147 
00148 
00149 // End Of File ///////////////////////////////////////////////////////////////

Generated on Fri Sep 21 14:40:11 2007 for PWLib by  doxygen 1.5.3