Octane v1.01.20 - The Open Compression Toolkit for C++ http://octane.sourceforge.net/
Homepage | Main | Modules | Class Hierarchy | Compound List | File List | Compound Members | Related Pages

compressors/compressor.hpp

Go to the documentation of this file.
00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 //---------------------------------------------------------------------------
00010 
00016 
00017 //---------------------------------------------------------------------------
00018 // forward declarations
00019 class OctaneCompressor;
00020 //---------------------------------------------------------------------------
00021 
00022 //---------------------------------------------------------------------------
00023 // recursive header protection
00024 #ifndef CompressorH
00025 #define CompressorH
00026 //---------------------------------------------------------------------------
00027 
00028 //---------------------------------------------------------------------------
00029 // application includes
00030 #include "../core/octaneclass.hpp"
00031 #include "../core/compressormanager.hpp"
00032 #include "../bitio/bitio.hpp"
00033 // system includes
00034 #include <string>
00035 //---------------------------------------------------------------------------
00036 
00037 
00038 
00039 //---------------------------------------------------------------------------
00045 class OctaneCompressor : public OctaneClass
00046 {
00047 public:
00049         OctaneCompressor(bool registerme=false) {ResetStatistics();};
00051         virtual ~OctaneCompressor() {;};
00052 public:
00053         //---------------------------------------------------------------------------
00054         // OCTANE PUBLIC API - RTTI AND HELP FUNCTIONS - these are supported by all derived classes
00055         virtual std::string GetName() {return GetInstantiatedName();};
00056         virtual std::string GetDescription() {return "Base Compressor";};
00057         virtual std::string GetHelpInformation() {return "";};
00062         virtual unsigned short int GetCompressorStateFileGUID() {return guid;};
00063         //---------------------------------------------------------------------------
00064 public:
00065         //---------------------------------------------------------------------------
00066         // COMPRESSOR PUBLIC API - FACTORY FUNCTION / MAKE AN INSTANTIATION OF DERIVED COMPRESSOR
00068         virtual OctaneCompressor *MakeCompressorInstantiation()=0;
00070         virtual std::string GetClassName() {return "Compressor";};
00072         std::string GetInstantiatedName() {if (instantiatedname=="") return GetClassName()+std::string(".unnamed"); else return instantiatedname;};
00074         unsigned short int GetGuid() {return guid;};
00076         void SetInstantiatedName(std::string val) {instantiatedname=val;};
00078         void SetInfo(std::string compressorname,unsigned short int compressorguid);
00079         //---------------------------------------------------------------------------
00080 public:
00081         //---------------------------------------------------------------------------
00082         // COMPRESSOR PUBLIC API - PREPARATION FOR COMPRESSING/DECOMPRESSING
00084         virtual void ResetState() {;};
00086         virtual void SynchronizeStateForNewStream() {;};
00090         virtual bool PrepareForCompression() {return true;};
00093         virtual void SetupAnyDefaultParser() {;};
00096         virtual bool IsReadyToCompress() {return true;};
00097         //---------------------------------------------------------------------------
00098 public:
00099         //---------------------------------------------------------------------------
00100         // COMPRESSOR PUBLIC API - COMPRESSING/DECOMPRESSING WRAPPERS (NOT VIRTUAL!)
00103         bool Compress(bitreader &from, bitwriter &to, bool needtowriteheader, bool savedecompressstateinfo);
00107         bool Decompress(bitreader &from, bitwriter &to, bool needtoreadheader);
00109         bool CreateSymbolsAndModelsUsingStream(bitreader &from);
00112         bool Save(bitwriter &to,bool fortempdecompressiononly);
00116         bool Load(bitreader &from);
00118         bool LoadState(bitreader &from);
00119         //---------------------------------------------------------------------------
00120 protected:
00121         //---------------------------------------------------------------------------
00122         // COMPRESSOR PROTECTED DERIVED COMPRESSION/DECOMPRESSING
00127         virtual bool DoProtectedCompress(bitreader &from, bitwriter &to)=0;
00132         virtual bool DoProtectedDecompress(bitreader &from, bitwriter &to)=0;
00133         //---------------------------------------------------------------------------
00134 protected:
00135         //---------------------------------------------------------------------------
00136         // OCTANE PROTECTED DERIVED STATE LOADING AND SAVING
00142         virtual bool DoProtectedCreateSymbolsAndModelsUsingStream(bitreader &from) {return true;};
00148         virtual bool DoProtectedSaveState(bitwriter &to,bool fortempdecompressiononly) {return true;};
00154         virtual bool DoProtectedLoadState(bitreader &from) {return true;};
00155         //---------------------------------------------------------------------------
00156 public:
00157         //---------------------------------------------------------------------------
00158         // COMPRESSOR PUBLIC API - STATISTICS REPORTING
00159         // These methods just wrap the calls below inside some timing/stats gathering functions
00161         void ResetStatistics();
00163         unsigned int GetStatistics_Cumulative_Compression_BytesRead() {return Cumulative_Compression_BytesRead;};
00165         unsigned int GetStatistics_Cumulative_Decompression_BytesRead() {return Cumulative_Decompression_BytesRead;};
00167         unsigned int GetStatistics_Cumulative_Compression_BytesWritten() {return Cumulative_Compression_BytesWritten;};
00169         unsigned int GetStatistics_Cumulative_Decompression_BytesWritten() {return Cumulative_Decompression_BytesWritten;};
00171         float GetStatistics_Cumulative_Compression_Bitrate() {if (Cumulative_Compression_BytesRead==0) return 0; else return (float)8.0*(float)Cumulative_Compression_BytesWritten/(float)Cumulative_Compression_BytesRead;};
00173         float GetStatistics_Cumulative_Decompression_Bitrate() {if (Cumulative_Decompression_BytesWritten==0) return 0; else return (float)8.0*(float)Cumulative_Decompression_BytesRead/(float)Cumulative_Decompression_BytesWritten;};
00175         float GetStatistics_Cumulative_Compression_Ratio() {if (Cumulative_Compression_BytesRead==0) return 0; else return (float)Cumulative_Compression_BytesWritten/(float)Cumulative_Compression_BytesRead;};
00177         float GetStatistics_Cumulative_Decompression_Ratio() {if (Cumulative_Decompression_BytesWritten==0) return 0; else return (float)Cumulative_Decompression_BytesRead/(float)Cumulative_Decompression_BytesWritten;};
00179         float GetStatistics_Cumulative_Compression_ExecutionTime() {return Cumulative_Compression_ExecutionTime;};
00181         float GetStatistics_Cumulative_Decompression_ExecutionTime() {return Cumulative_Decompression_ExecutionTime;};
00183         float GetStatistics_Cumulative_ExecutionTime() {return GetStatistics_Cumulative_Compression_ExecutionTime()+GetStatistics_Cumulative_Decompression_ExecutionTime();};
00185         int GetStatistics_Cumulative_ErrorCount() {return Cumulative_ErrorCount;};
00186         // last operation stats
00188         unsigned int GetStatistics_LastOperation_Compression_BytesRead() {return LastOperation_Compression_BytesRead;};
00190         unsigned int GetStatistics_LastOperation_Decompression_BytesRead() {return LastOperation_Decompression_BytesRead;};
00192         unsigned int GetStatistics_LastOperation_Compression_BytesWritten() {return LastOperation_Compression_BytesWritten;};
00194         unsigned int GetStatistics_LastOperation_Decompression_BytesWritten() {return LastOperation_Decompression_BytesWritten;};
00196         unsigned int GetStatistics_LastOperation_State_BytesRead() {return LastOperation_State_BytesRead;};
00198         unsigned int GetStatistics_LastOperation_State_BytesWritten() {return LastOperation_State_BytesWritten;};
00200         float GetStatistics_LastOperation_Compression_Bitrate() {if (LastOperation_Compression_BytesRead==0) return 0; else return (float)8.0*(float)LastOperation_Compression_BytesWritten/(float)LastOperation_Compression_BytesRead;};
00202         float GetStatistics_LastOperation_Decompression_Bitrate() {if (LastOperation_Decompression_BytesWritten==0) return 0; else return (float)8.0*(float)LastOperation_Decompression_BytesRead/(float)LastOperation_Decompression_BytesWritten;};
00204         float GetStatistics_LastOperation_Compression_Ratio() {if (LastOperation_Compression_BytesRead==0) return 0; else return (float)LastOperation_Compression_BytesWritten/(float)LastOperation_Compression_BytesRead;};
00206         float GetStatistics_LastOperation_Decompression_Ratio() {if (LastOperation_Decompression_BytesWritten==0) return 0; else return (float)LastOperation_Decompression_BytesRead/(float)LastOperation_Decompression_BytesWritten;};
00208         float GetStatistics_LastOperation_Compression_ExecutionTime() {return LastOperation_Compression_ExecutionTime;};
00210         float GetStatistics_LastOperation_Decompression_ExecutionTime() {return LastOperation_Decompression_ExecutionTime;};
00212         float GetStatistics_LastOperation_ExecutionTime() {return GetStatistics_LastOperation_Compression_ExecutionTime()+GetStatistics_LastOperation_Decompression_ExecutionTime();};
00214         float GetStatistics_LastOperation_State_ExecutionTime() {return LastOperation_State_ExecutionTime;};
00217         int GetStatistics_LastOperation_ErrorCount() {return LastOperation_ErrorCount;};
00219         void Add_LastOperation_Compression_BytesRead(int val) {LastOperation_Compression_BytesRead+=val;};
00221         void Add_LastOperation_Compression_BytesWritten(int val) {LastOperation_Compression_BytesWritten+=val;};
00223         void Add_LastOperation_Decompression_BytesRead(int val) {LastOperation_Decompression_BytesRead+=val;};
00225         void Add_LastOperation_Decompression_BytesWritten(int val) {LastOperation_Decompression_BytesWritten+=val;};
00226         //---------------------------------------------------------------------------
00227 public:
00228         //---------------------------------------------------------------------------
00231         bool SaveCompressionHeader(bitwriter &to, bool savedecompressstateinfo);
00233         bool LoadCompressionHeader(bitreader &from);
00235         bool SaveGUID(bitwriter &to);
00238         static int LoadGUID(bitreader &from);
00239         //---------------------------------------------------------------------------
00240 protected:
00242         std::string instantiatedname;
00244         unsigned short int guid;
00245 private:
00246         // statistics tracking
00248         unsigned int Cumulative_Compression_BytesRead;
00250         unsigned int Cumulative_Decompression_BytesRead;
00252         unsigned int Cumulative_Compression_BytesWritten;
00254         unsigned int Cumulative_Decompression_BytesWritten;
00256         float Cumulative_Compression_Bitrate;
00258         float Cumulative_Decompression_Bitrate;
00260         float Cumulative_Compression_Ratio;
00262         float Cumulative_Decompression_Ratio;
00264         float Cumulative_Compression_ExecutionTime;
00266         float Cumulative_Decompression_ExecutionTime;
00268         int Cumulative_ErrorCount;
00270         unsigned int LastOperation_Compression_BytesRead;
00272         unsigned int LastOperation_Decompression_BytesRead;
00274         unsigned int LastOperation_Compression_BytesWritten;
00276         unsigned int LastOperation_Decompression_BytesWritten;
00278         unsigned int LastOperation_State_BytesRead;
00280         unsigned int LastOperation_State_BytesWritten;
00282         float LastOperation_Compression_Bitrate;
00284         float LastOperation_Decompression_Bitrate;
00286         float LastOperation_Compression_Ratio;
00288         float LastOperation_Decompression_Ratio;
00290         float LastOperation_Compression_ExecutionTime;
00292         float LastOperation_Decompression_ExecutionTime;
00294         float LastOperation_State_ExecutionTime;
00296         int LastOperation_ErrorCount;
00297 };
00298 //---------------------------------------------------------------------------
00299 
00300 
00301 
00302 //---------------------------------------------------------------------------
00303 #endif
00304 //---------------------------------------------------------------------------
00305 
 
Generated on 20 May 2004 by doxygen 1.3.3