src/stream/ZStream_PageBuffered.h

00001 /*  @(#) $Id: ZStream_PageBuffered.h,v 1.11 2006/04/27 03:19:32 agreen Exp $ */
00002 
00003 /* ------------------------------------------------------------
00004 Copyright (c) 2000 Andrew Green and Learning in Motion, Inc.
00005 http://www.zoolib.org
00006 
00007 Permission is hereby granted, free of charge, to any person obtaining a copy
00008 of this software and associated documentation files (the "Software"), to deal
00009 in the Software without restriction, including without limitation the rights
00010 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
00011 copies of the Software, and to permit persons to whom the Software is
00012 furnished to do so, subject to the following conditions:
00013 
00014 The above copyright notice and this permission notice shall be included in
00015 all copies or substantial portions of the Software.
00016 
00017 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00018 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00019 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
00020 COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
00021 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
00022 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00023 ------------------------------------------------------------ */
00024 
00025 #ifndef __ZStream_PageBuffered__
00026 #define __ZStream_PageBuffered__ 1
00027 #include "zconfig.h"
00028 
00029 #include "ZStreamer.h"
00030 
00031 // =================================================================================================
00032 #pragma mark -
00033 #pragma mark * ZStreamRPos_PageBuffered
00034 
00039 class ZStreamRPos_PageBuffered : public ZStreamRPos
00040         {
00041 public:
00042         ZStreamRPos_PageBuffered(
00043                 size_t iBufferCount, size_t iBufferSize, const ZStreamRPos& iStreamReal);
00044 
00045         ~ZStreamRPos_PageBuffered();
00046 
00047 // From ZStreamR via ZStreamRPos
00048         virtual void Imp_Read(void* iDest, size_t iCount, size_t* oCountRead);
00049         virtual size_t Imp_CountReadable();
00050         virtual void Imp_Skip(uint64 iCount, uint64* oCountSkipped);
00051 
00052 // From ZStreamRPos
00053         virtual uint64 Imp_GetPosition();
00054         virtual void Imp_SetPosition(uint64 iPosition);
00055 
00056         virtual uint64 Imp_GetSize();
00057 
00058 protected:
00059         void Internal_Init(size_t iBufferCount, size_t iBufferSize);
00060 
00061         const ZStreamRPos& fStreamReal;
00062         struct Buffer;
00063 
00064         Buffer* fBuffer_Head;
00065         Buffer* fBuffer_Tail;
00066         size_t fBufferSize;
00067 
00068         uint64 fPosition;
00069         };
00070 
00071 // =================================================================================================
00072 #pragma mark -
00073 #pragma mark * ZStreamerRPos_PageBuffered
00074 
00076 
00077 class ZStreamerRPos_PageBuffered : public ZStreamerRPos
00078         {
00079 public:
00080         ZStreamerRPos_PageBuffered(
00081                 size_t iBufferCount, size_t iBufferSize, ZRef<ZStreamerRPos> iStreamerSource);
00082 
00083         virtual ~ZStreamerRPos_PageBuffered();
00084 
00085 // From ZStreamerRPos
00086         virtual const ZStreamRPos& GetStreamRPos();
00087 
00088 protected:
00089         ZRef<ZStreamerRPos> fStreamerSource;
00090         ZStreamRPos_PageBuffered fStream;
00091         };
00092 
00093 // =================================================================================================
00094 #pragma mark -
00095 #pragma mark * ZStreamRWPos_PageBuffered
00096 
00101 class ZStreamRWPos_PageBuffered : public ZStreamRWPos
00102         {
00103 public:
00104         ZStreamRWPos_PageBuffered(
00105                 size_t iBufferCount, size_t iBufferSize, const ZStreamRWPos& iStreamReal);
00106 
00107         ~ZStreamRWPos_PageBuffered();
00108 
00109 // From ZStreamR via ZStreamRWPos
00110         virtual void Imp_Read(void* iDest, size_t iCount, size_t* oCountRead);
00111 
00112 // From ZStreamW via ZStreamRWPos
00113         virtual void Imp_Write(const void* iSource, size_t iCount, size_t* oCountWritten);
00114         virtual void Imp_Flush();
00115 
00116 // From ZStreamRPos/ZStreamWPos via ZStreamRWPos
00117         virtual uint64 Imp_GetPosition();
00118         virtual void Imp_SetPosition(uint64 iPosition);
00119 
00120         virtual uint64 Imp_GetSize();
00121 
00122 // From ZStreamWPos via ZStreamRWPos
00123         virtual void Imp_SetSize(uint64 iSize);
00124 
00125 protected:
00126         void Internal_Init(size_t iBufferCount, size_t iBufferSize);
00127 
00128         const ZStreamRWPos& fStreamReal;
00129         struct Buffer;
00130 
00131         Buffer* fBuffer_Head;
00132         Buffer* fBuffer_Tail;
00133         size_t fBufferSize;
00134 
00135         uint64 fPosition;
00136         };
00137 
00138 // =================================================================================================
00139 #pragma mark -
00140 #pragma mark * ZStreamerRWPos_PageBuffered
00141 
00143 
00144 class ZStreamerRWPos_PageBuffered : public ZStreamerRWPos
00145         {
00146 public:
00147         ZStreamerRWPos_PageBuffered(
00148                 size_t iBufferCount, size_t iBufferSize, ZRef<ZStreamerRWPos> iStreamerReal);
00149 
00150         virtual ~ZStreamerRWPos_PageBuffered();
00151 
00152 // From ZStreamerRWPos
00153         virtual const ZStreamRWPos& GetStreamRWPos();
00154 
00155 protected:
00156         ZRef<ZStreamerRWPos> fStreamerReal;
00157         ZStreamRWPos_PageBuffered fStream;
00158         };
00159 
00160 #endif // __ZStream_PageBuffered__

Generated on Thu Jul 26 11:21:53 2007 for ZooLib by  doxygen 1.4.7