src/stream/ZStream_Count.h

00001 /*  @(#) $Id: ZStream_Count.h,v 1.5 2006/10/19 22:49:46 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_Count__
00026 #define __ZStream_Count__ 1
00027 
00028 #include "zconfig.h"
00029 
00030 #include "ZStream.h"
00031 
00032 // =================================================================================================
00033 #pragma mark -
00034 #pragma mark * ZStreamR_Count
00035 
00037 
00038 class ZStreamR_Count : public ZStreamR
00039         {
00040 public:
00042         ZStreamR_Count(const ZStreamR& iStreamSource);
00043         ZStreamR_Count(uint64& oCount, const ZStreamR& iStreamSource);
00044 
00045         ~ZStreamR_Count();
00046 
00047 // From ZStreamR
00048         virtual void Imp_Read(void* iDest, size_t iCount, size_t* oCountRead);
00049         virtual size_t Imp_CountReadable();
00050 
00051         virtual void Imp_CopyToDispatch(const ZStreamW& iStreamW, uint64 iCount,
00052                 uint64* oCountRead, uint64* oCountWritten);
00053 
00054         virtual void Imp_CopyTo(const ZStreamW& iStreamW, uint64 iCount,
00055                 uint64* oCountRead, uint64* oCountWritten);
00056 
00057         virtual void Imp_Skip(uint64 iCount, uint64* oCountSkipped);
00058 
00059 // Our protocol
00060 
00062         uint64 GetCount();
00063 
00065         void ZeroCount();
00066 
00067 protected:
00068         const ZStreamR& fStreamSource;
00069         uint64 fCount;
00070         uint64* fCountPtr;
00071         };
00072 
00073 //typedef ZStreamerR_FT<ZStreamR_Count> ZStreamerR_Count;
00074 
00075 // =================================================================================================
00076 #pragma mark -
00077 #pragma mark * ZStreamW_Count
00078 
00080 
00081 class ZStreamW_Count : public ZStreamW
00082         {
00083 public:
00085         ZStreamW_Count(const ZStreamW& iStreamSink);
00086 
00087         ZStreamW_Count(uint64& oCount, const ZStreamW& iStreamSink);
00088 
00091         ZStreamW_Count();
00092         ZStreamW_Count(uint64& oCount);
00093 
00094         ~ZStreamW_Count();
00095 
00096 // From ZStreamW
00097         virtual void Imp_Write(const void* iSource, size_t iCount, size_t* oCountWritten);
00098 
00099         virtual void Imp_CopyFromDispatch(const ZStreamR& iStreamR, uint64 iCount,
00100                 uint64* oCountRead, uint64* oCountWritten);
00101 
00102         virtual void Imp_CopyFrom(const ZStreamR& iStreamR, uint64 iCount,
00103                 uint64* oCountRead, uint64* oCountWritten);
00104 
00105         virtual void Imp_Flush();
00106 
00107 // Our protocol
00108 
00110         uint64 GetCount();
00111 
00113         void ZeroCount();
00114 
00115 protected:
00116         const ZStreamW* fStreamSink;
00117         uint64 fCount;
00118         uint64* fCountPtr;
00119         };
00120 
00121 //typedef ZStreamerW_FT<ZStreamW_Count> ZStreamerW_Count;
00122 
00123 #endif // __ZStream_Count__

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