Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

delaychan.h

Go to the documentation of this file.
00001 /* 00002 * delaychan.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: delaychan.h,v $ 00027 * Revision 1.4 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.3 2002/02/25 11:05:02 rogerh 00032 * New Delay code which solves the accumulated error problem. Based on ideas 00033 * by Tomasz Motylewski <T.Motylewski@bfad.de>, Roger and Craig. 00034 * 00035 * Revision 1.2 2002/01/15 03:55:43 craigs 00036 * Added PAdaptiveDelay class 00037 * 00038 * Revision 1.1 2001/07/10 03:07:07 robertj 00039 * Added queue channel and delay channel classes to ptclib. 00040 * 00041 */ 00042 00043 #ifndef _DELAYCHAN_H 00044 #define _DELAYCHAN_H 00045 00046 00047 #ifdef P_USE_PRAGMA 00048 #pragma interface 00049 #endif 00050 00059 class PAdaptiveDelay : public PObject 00060 { 00061 PCLASSINFO(PAdaptiveDelay, PObject); 00062 00063 public: 00064 PAdaptiveDelay(); 00065 BOOL Delay(int time); 00066 void Restart(); 00067 00068 protected: 00069 BOOL firstTime; 00070 PTime targetTime; 00071 }; 00072 00073 00089 class PDelayChannel : public PIndirectChannel 00090 { 00091 PCLASSINFO(PDelayChannel, PIndirectChannel); 00092 public: 00095 enum Mode { 00096 DelayReadsOnly, 00097 DelayWritesOnly, 00098 DelayReadsAndWrites 00099 }; 00100 00108 PDelayChannel( 00109 Mode mode, 00110 unsigned frameDelay, 00111 PINDEX frameSize = 0, 00112 unsigned maximumSlip = 250, 00113 unsigned minimumDelay = 10 00114 ); 00116 00117 00131 virtual BOOL Read( 00132 void * buf, 00133 PINDEX len 00134 ); 00135 00145 virtual BOOL Write( 00146 const void * buf, 00147 PINDEX len 00148 ); 00150 00151 00152 protected: 00153 virtual void Wait(PINDEX count, PTimeInterval & nextTick); 00154 00155 Mode mode; 00156 unsigned frameDelay; 00157 PINDEX frameSize; 00158 PTimeInterval maximumSlip; 00159 PTimeInterval minimumDelay; 00160 00161 PTimeInterval nextReadTick; 00162 PTimeInterval nextWriteTick; 00163 }; 00164 00165 00166 #endif // _DELAYCHAN_H 00167 00168 00169 // End Of File ///////////////////////////////////////////////////////////////

Generated on Sat Jul 24 15:35:56 2004 for PWLib by doxygen 1.3.7