src/stream/ZStream_Limited.h

00001 /*  @(#) $Id: ZStream_Limited.h,v 1.7 2006/04/27 03:19:32 agreen Exp $ */
00002 
00003 /* ------------------------------------------------------------
00004 Copyright (c) 2004 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_Limited__
00026 #define __ZStream_Limited__ 1
00027 
00028 #include "zconfig.h"
00029 
00030 #include "ZStream.h"
00031 #include "ZStreamer.h"
00032 
00033 // =================================================================================================
00034 #pragma mark -
00035 #pragma mark * ZStreamR_Limited
00036 
00038 
00039 class ZStreamR_Limited : public ZStreamR
00040         {
00041 public:
00042         ZStreamR_Limited(uint64 iLimit, const ZStreamR& iStreamSource);
00043         ~ZStreamR_Limited();
00044 
00045 // From ZStreamR
00046         virtual void Imp_Read(void* iDest, size_t iCount, size_t* oCountRead);
00047         virtual size_t Imp_CountReadable();
00048 
00049         virtual void Imp_CopyToDispatch(const ZStreamW& iStreamW, uint64 iCount,
00050                 uint64* oCountRead, uint64* oCountWritten);
00051 
00052         virtual void Imp_CopyTo(const ZStreamW& iStreamW, uint64 iCount,
00053                 uint64* oCountRead, uint64* oCountWritten);
00054 
00055         virtual void Imp_Skip(uint64 iCount, uint64* oCountSkipped);
00056 
00057 protected:
00058         const ZStreamR& fStreamSource;
00059         uint64 fCountRemaining;
00060         };
00061 
00062 // typedef ZStreamerR_FT<ZStreamR_Limited> ZStreamerR_Limited;
00063 
00064 // =================================================================================================
00065 #pragma mark -
00066 #pragma mark * ZStreamW_Limited
00067 
00069 
00070 class ZStreamW_Limited : public ZStreamW
00071         {
00072 public:
00073         ZStreamW_Limited(uint64 iLimit, const ZStreamW& iStreamSink);
00074         ~ZStreamW_Limited();
00075 
00076 // From ZStreamW
00077         virtual void Imp_Write(const void* iSource, size_t iCount, size_t* oCountWritten);
00078         virtual void Imp_Flush();
00079 
00080 protected:
00081         const ZStreamW& fStreamSink;
00082         uint64 fCountRemaining;
00083         };
00084 
00085 // typedef ZStreamerW_FT<ZStreamW_Limited> ZStreamerW_Limited;
00086 
00087 // =================================================================================================
00088 #pragma mark -
00089 #pragma mark * ZStreamRPos_Limited
00090 
00094 class ZStreamRPos_Limited : public ZStreamRPos
00095         {
00096 public:
00097         ZStreamRPos_Limited(uint64 iOffset, uint64 iLimit, const ZStreamRPos& iStreamSource);
00098         ~ZStreamRPos_Limited();
00099 
00100 // From ZStreamR
00101         virtual void Imp_Read(void* iDest, size_t iCount, size_t* oCountRead);
00102 
00103 // From ZStreamRPos
00104         virtual uint64 Imp_GetPosition();
00105         virtual void Imp_SetPosition(uint64 iPosition);
00106 
00107         virtual uint64 Imp_GetSize();
00108 
00109 protected:
00110         const ZStreamRPos& fStreamSource;
00111         uint64 fOffset;
00112         uint64 fLimit;
00113         };
00114 
00115 // =================================================================================================
00116 #pragma mark -
00117 #pragma mark * ZStreamerRPos_Limited
00118 
00120 
00121 class ZStreamerRPos_Limited : public ZStreamerRPos
00122         {
00123 public:
00124         ZStreamerRPos_Limited(uint64 iOffset, uint64 iLimit, ZRef<ZStreamerRPos> iStreamer);
00125 
00126         virtual ~ZStreamerRPos_Limited();
00127 
00128 // From ZStreamerRPos
00129         virtual const ZStreamRPos& GetStreamRPos();
00130 
00131 protected:
00132         ZRef<ZStreamerRPos> fStreamer;
00133         ZStreamRPos_Limited fStream;
00134         };
00135 
00136 
00137 #endif // __ZStream_Limited__

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