src/stream/ZStream_Memory.h

00001 /*  @(#) $Id: ZStream_Memory.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_Memory__
00026 #define __ZStream_Memory__ 1
00027 
00028 #include "zconfig.h"
00029 
00030 #include "ZStreamer.h"
00031 
00032 // =================================================================================================
00033 #pragma mark -
00034 #pragma mark * ZStreamR_Memory
00035 
00037 
00038 class ZStreamR_Memory : public ZStreamR
00039         {
00040 public:
00041         ZStreamR_Memory(const void* iAddress);
00042 
00043 // From ZStreamR
00044         virtual void Imp_Read(void* iDest, size_t iCount, size_t* oCountRead);
00045 
00046         virtual void Imp_CopyToDispatch(const ZStreamW& iStreamW, uint64 iCount,
00047                 uint64* oCountRead, uint64* oCountWritten);
00048 
00049         virtual void Imp_CopyTo(const ZStreamW& iStreamW, uint64 iCount,
00050                 uint64* oCountRead, uint64* oCountWritten);
00051 
00052         virtual void Imp_Skip(uint64 iCount, uint64* oCountSkipped);
00053 
00054 // Our protocol
00056         const void* GetCurrentAddress();
00057 
00058 protected:
00059         void pCopyTo(const ZStreamW& iStreamW, uint64 iCount,
00060                 uint64* oCountRead, uint64* oCountWritten);
00061 
00062         const char* fAddress;
00063         };
00064 
00065 typedef ZStreamerR_T<ZStreamR_Memory> ZStreamerR_Memory;
00066 
00067 // =================================================================================================
00068 #pragma mark -
00069 #pragma mark * ZStreamRPos_Memory
00070 
00072 
00073 class ZStreamRPos_Memory : public ZStreamRPos
00074         {
00075 public:
00076         ZStreamRPos_Memory(const void* iAddress, size_t iSize);
00077         ZStreamRPos_Memory(const std::pair<const void*, size_t>& iParam);
00078 
00079 // From ZStreamR via ZStreamRPos
00080         virtual void Imp_Read(void* iDest, size_t iCount, size_t* oCountRead);
00081         virtual size_t Imp_CountReadable();
00082 
00083         virtual void Imp_CopyToDispatch(const ZStreamW& iStreamW, uint64 iCount,
00084                 uint64* oCountRead, uint64* oCountWritten);
00085 
00086         virtual void Imp_CopyTo(const ZStreamW& iStreamW, uint64 iCount,
00087                 uint64* oCountRead, uint64* oCountWritten);
00088 
00089         virtual void Imp_Skip(uint64 iCount, uint64* oCountSkipped);
00090 
00091 // From ZStreamRPos
00092         virtual uint64 Imp_GetPosition();
00093         virtual void Imp_SetPosition(uint64 iPosition);
00094 
00095         virtual uint64 Imp_GetSize();
00096 
00097 // Our protocol
00099         const void* GetCurrentAddress();
00100 
00101 protected:
00102         void pCopyTo(const ZStreamW& iStreamW, uint64 iCount,
00103                 uint64* oCountRead, uint64* oCountWritten);
00104 
00105         const char* fAddress;
00106         uint64 fPosition;
00107         size_t fSize;
00108         };
00109 
00110 // =================================================================================================
00111 #pragma mark -
00112 #pragma mark * ZStreamerRPos_Memory
00113 
00115 
00116 class ZStreamerRPos_Memory : public ZStreamerRPos
00117         {
00118 public:
00119         ZStreamerRPos_Memory(const void* iAddress, size_t iSize);
00120         virtual ~ZStreamerRPos_Memory();
00121 
00122 // From ZStreamerRPos
00123         virtual const ZStreamRPos& GetStreamRPos();
00124 
00125 // Our protocol
00126         const void* GetCurrentAddress();
00127 
00128 protected:
00129         ZStreamRPos_Memory fStream;
00130         };
00131 
00132 // Alternate template-based definition:
00133 // typedef ZStreamerRPos_T<ZStreamRPos_Memory> ZStreamerRPos_Memory;
00134 
00135 // =================================================================================================
00136 #pragma mark -
00137 #pragma mark * ZStreamW_Memory
00138 
00140 
00141 class ZStreamW_Memory : public ZStreamW
00142         {
00143 public:
00144         ZStreamW_Memory(void* iAddress);
00145 
00146 // From ZStreamW
00147         virtual void Imp_Write(const void* iSource, size_t iCount, size_t* oCountWritten);
00148 
00149         virtual void Imp_CopyFromDispatch(const ZStreamR& iStreamR, uint64 iCount,
00150                 uint64* oCountRead, uint64* oCountWritten);
00151 
00152         virtual void Imp_CopyFrom(const ZStreamR& iStreamR, uint64 iCount,
00153                 uint64* oCountRead, uint64* oCountWritten);
00154 
00155 // Our protocol
00157         void* GetCurrentAddress();
00158 
00159 protected:
00160         void pCopyFrom(const ZStreamR& iStreamR, uint64 iCount,
00161                 uint64* oCountRead, uint64* oCountWritten);
00162 
00163         char* fAddress;
00164         };
00165 
00166 typedef ZStreamerW_T<ZStreamW_Memory> ZStreamerW_Memory;
00167 
00168 // =================================================================================================
00169 #pragma mark -
00170 #pragma mark * ZStreamWPos_Memory
00171 
00173 
00174 class ZStreamWPos_Memory : public ZStreamWPos
00175         {
00176 public:
00177         ZStreamWPos_Memory(void* iAddress, size_t iSize);
00178         ZStreamWPos_Memory(void* iAddress, size_t iSize, size_t iCapacity);
00179 
00180 // From ZStreamW via ZStreamWPos
00181         virtual void Imp_Write(const void* iSource, size_t iCount, size_t* oCountWritten);
00182 
00183         virtual void Imp_CopyFromDispatch(const ZStreamR& iStreamR, uint64 iCount,
00184                 uint64* oCountRead, uint64* oCountWritten);
00185 
00186         virtual void Imp_CopyFrom(const ZStreamR& iStreamR, uint64 iCount,
00187                 uint64* oCountRead, uint64* oCountWritten);
00188 
00189 // From ZStreamWPos
00190         virtual uint64 Imp_GetPosition();
00191         virtual void Imp_SetPosition(uint64 iPosition);
00192 
00193         virtual uint64 Imp_GetSize();
00194         virtual void Imp_SetSize(uint64 iSize);
00195 
00196 // Our protocol
00198         void* GetCurrentAddress();
00199 
00200 protected:
00201         void pCopyFrom(const ZStreamR& iStreamR, uint64 iCount,
00202                 uint64* oCountRead, uint64* oCountWritten);
00203 
00204         char* fAddress;
00205         uint64 fPosition;
00206         size_t fSize;
00207         size_t fCapacity;
00208         };
00209 
00210 // =================================================================================================
00211 #pragma mark -
00212 #pragma mark * ZStreamerWPos_Memory
00213 
00215 
00216 class ZStreamerWPos_Memory : public ZStreamerWPos
00217         {
00218 public:
00219         ZStreamerWPos_Memory(void* iAddress, size_t iSize);
00220         ZStreamerWPos_Memory(void* iAddress, size_t iSize, size_t iCapacity);
00221         virtual ~ZStreamerWPos_Memory();
00222 
00223 // From ZStreamerWPos
00224         virtual const ZStreamWPos& GetStreamWPos();
00225 
00226 // Our protocol
00227         void* GetCurrentAddress();
00228 
00229 protected:
00230         ZStreamWPos_Memory fStream;
00231         };
00232 
00233 // Alternate template-based definition:
00234 // typedef ZStreamerW_T<ZStreamWPos_Memory> ZStreamerWPos_Memory;
00235 
00236 #endif // __ZStream_Memory__

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