00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef __ZStream_RateCapped__
00026 #define __ZStream_RateCapped__ 1
00027 #include "zconfig.h"
00028
00029 #include "ZStream_Filter.h"
00030 #include "ZStreamer.h"
00031
00032 #include "ZTime.h"
00033
00034
00035 #pragma mark -
00036 #pragma mark * ZooLib
00037
00038 namespace ZooLib {
00039
00040 class RateLimiter
00041 {
00042 public:
00043 RateLimiter(double iRate, size_t iQuantum);
00044
00045 size_t GetCount(size_t iLastCount, size_t iCount);
00046
00047 private:
00048 double fRate;
00049 size_t fQuantum;
00050
00051 ZTime fLastTime;
00052 };
00053
00054 }
00055
00056
00057 #pragma mark -
00058 #pragma mark * ZStreamR_RateCapped
00059
00060 class ZStreamR_RateCapped : public ZStreamR_Filter
00061 {
00062 public:
00063 ZStreamR_RateCapped(double iRate, size_t iQuantum, const ZStreamR& iStreamReal);
00064
00065 ~ZStreamR_RateCapped();
00066
00067
00068 virtual void Imp_Read(void* iDest, size_t iCount, size_t* oCountRead);
00069
00070 protected:
00071 ZooLib::RateLimiter fLimiter;
00072 size_t fLastCount;
00073 };
00074
00075
00076 #pragma mark -
00077 #pragma mark * ZStreamerR_RateCapped
00078
00079 class ZStreamerR_RateCapped : public ZStreamerR
00080 {
00081 public:
00082 ZStreamerR_RateCapped(double iRate, size_t iQuantum, ZRef<ZStreamerR> iStreamerReal);
00083
00084 virtual ~ZStreamerR_RateCapped();
00085
00086
00087 virtual const ZStreamR& GetStreamR();
00088
00089 protected:
00090 ZRef<ZStreamerR> fStreamerReal;
00091 ZStreamR_RateCapped fStream;
00092 };
00093
00094
00095 #pragma mark -
00096 #pragma mark * ZStreamU_RateCapped
00097
00098 class ZStreamU_RateCapped : public ZStreamU_Filter
00099 {
00100 public:
00101 ZStreamU_RateCapped(double iRate, size_t iQuantum, const ZStreamU& iStreamReal);
00102
00103 ~ZStreamU_RateCapped();
00104
00105
00106 virtual void Imp_Read(void* iDest, size_t iCount, size_t* oCountRead);
00107
00108 protected:
00109 ZooLib::RateLimiter fLimiter;
00110 size_t fLastCount;
00111 };
00112
00113
00114 #pragma mark -
00115 #pragma mark * ZStreamerU_RateCapped
00116
00117 class ZStreamerU_RateCapped : public ZStreamerU
00118 {
00119 public:
00120 ZStreamerU_RateCapped(double iRate, size_t iQuantum, ZRef<ZStreamerU> iStreamerReal);
00121
00122 virtual ~ZStreamerU_RateCapped();
00123
00124
00125 virtual const ZStreamU& GetStreamU();
00126
00127 protected:
00128 ZRef<ZStreamerU> fStreamerReal;
00129 ZStreamU_RateCapped fStream;
00130 };
00131
00132
00133 #pragma mark -
00134 #pragma mark * ZStreamRPos_RateCapped
00135
00136 class ZStreamRPos_RateCapped : public ZStreamRPos_Filter
00137 {
00138 public:
00139 ZStreamRPos_RateCapped(double iRate, size_t iQuantum, const ZStreamRPos& iStreamReal);
00140
00141 ~ZStreamRPos_RateCapped();
00142
00143
00144 virtual void Imp_Read(void* iDest, size_t iCount, size_t* oCountRead);
00145
00146 protected:
00147 ZooLib::RateLimiter fLimiter;
00148 size_t fLastCount;
00149 };
00150
00151
00152 #pragma mark -
00153 #pragma mark * ZStreamerRPos_RateCapped
00154
00155 class ZStreamerRPos_RateCapped : public ZStreamerRPos
00156 {
00157 public:
00158 ZStreamerRPos_RateCapped(double iRate, size_t iQuantum, ZRef<ZStreamerRPos> iStreamerReal);
00159
00160 virtual ~ZStreamerRPos_RateCapped();
00161
00162
00163 virtual const ZStreamRPos& GetStreamRPos();
00164
00165 protected:
00166 ZRef<ZStreamerRPos> fStreamerReal;
00167 ZStreamRPos_RateCapped fStream;
00168 };
00169
00170
00171 #pragma mark -
00172 #pragma mark * ZStreamW_RateCapped
00173
00174 class ZStreamW_RateCapped : public ZStreamW_Filter
00175 {
00176 public:
00177 ZStreamW_RateCapped(double iRate, size_t iQuantum, const ZStreamW& iStreamReal);
00178
00179 ~ZStreamW_RateCapped();
00180
00181
00182 virtual void Imp_Write(const void* iSource, size_t iCount, size_t* oCountWritten);
00183
00184 protected:
00185 ZooLib::RateLimiter fLimiter;
00186 size_t fLastCount;
00187 };
00188
00189
00190 #pragma mark -
00191 #pragma mark * ZStreamerW_RateCapped
00192
00193 class ZStreamerW_RateCapped : public ZStreamerW
00194 {
00195 public:
00196 ZStreamerW_RateCapped(double iRate, size_t iQuantum, ZRef<ZStreamerW> iStreamerReal);
00197
00198 virtual ~ZStreamerW_RateCapped();
00199
00200
00201 virtual const ZStreamW& GetStreamW();
00202
00203 protected:
00204 ZRef<ZStreamerW> fStreamerReal;
00205 ZStreamW_RateCapped fStream;
00206 };
00207
00208
00209 #pragma mark -
00210 #pragma mark * ZStreamWPos_RateCapped
00211
00212 class ZStreamWPos_RateCapped : public ZStreamWPos_Filter
00213 {
00214 public:
00215 ZStreamWPos_RateCapped(double iRate, size_t iQuantum, const ZStreamWPos& iStreamReal);
00216
00217 ~ZStreamWPos_RateCapped();
00218
00219
00220 virtual void Imp_Write(const void* iSource, size_t iCount, size_t* oCountWritten);
00221
00222 protected:
00223 ZooLib::RateLimiter fLimiter;
00224 size_t fLastCount;
00225 };
00226
00227
00228 #pragma mark -
00229 #pragma mark * ZStreamerWPos_RateCapped
00230
00231 class ZStreamerWPos_RateCapped : public ZStreamerWPos
00232 {
00233 public:
00234 ZStreamerWPos_RateCapped(double iRate, size_t iQuantum, ZRef<ZStreamerWPos> iStreamerReal);
00235
00236 virtual ~ZStreamerWPos_RateCapped();
00237
00238
00239 virtual const ZStreamWPos& GetStreamWPos();
00240
00241 protected:
00242 ZRef<ZStreamerWPos> fStreamerReal;
00243 ZStreamWPos_RateCapped fStream;
00244 };
00245
00246 #endif // __ZStream_RateCapped__