00001 #ifndef CLASSLIB_COMPRESS_OUTPUT_STREAM_H 00002 # define CLASSLIB_COMPRESS_OUTPUT_STREAM_H 00003 00004 //<<<<<< INCLUDES >>>>>> 00005 00006 # include "classlib/sysapi/system.h" 00007 # include "classlib/iotools/FilterOutputStream.h" 00008 00009 namespace lat { 00010 //<<<<<< PUBLIC DEFINES >>>>>> 00011 //<<<<<< PUBLIC CONSTANTS >>>>>> 00012 //<<<<<< PUBLIC TYPES >>>>>> 00013 00014 class Compressor; 00015 class Checksum; 00016 class OutputStream; 00017 00018 //<<<<<< PUBLIC VARIABLES >>>>>> 00019 //<<<<<< PUBLIC FUNCTIONS >>>>>> 00020 //<<<<<< CLASS DECLARATIONS >>>>>> 00021 00048 class CompressOutputStream : public FilterOutputStream 00049 { 00050 public: 00051 enum { DEFAULT_BUF_SIZE = 4096 }; 00052 00053 CompressOutputStream (Compressor *compressor, 00054 Checksum *checksum, 00055 OutputStream *output, 00056 IOSize bufsize = DEFAULT_BUF_SIZE); 00057 ~CompressOutputStream (void); 00058 00059 using FilterOutputStream::write; 00060 virtual IOSize write (const void *from, IOSize n); 00061 virtual void flush (void); 00062 virtual void finish (void); 00063 virtual void close (void); 00064 00065 virtual unsigned checksum (void) const; 00066 00067 protected: 00068 virtual void compress (void); 00069 virtual void restart (void); 00070 00071 Compressor *m_compressor; //< Compression engine 00072 Checksum *m_checksum; //< Optional checksum accumulator 00073 unsigned char *m_buffer; //< Compression buffer 00074 IOSize m_size; //< Compression buffer size 00075 bool m_finished; //< Inidicates that #finish() was done 00076 00077 private: 00078 // undefined, no semantics 00079 CompressOutputStream (const CompressOutputStream &); 00080 CompressOutputStream &operator= (const CompressOutputStream &); 00081 }; 00082 00083 //<<<<<< INLINE PUBLIC FUNCTIONS >>>>>> 00084 //<<<<<< INLINE MEMBER FUNCTIONS >>>>>> 00085 00086 } // namespace lat 00087 #endif // CLASSLIB_COMPRESS_OUTPUT_STREAM_H