SHOGUN
v2.0.0
|
00001 /* 00002 * This program is free software; you can redistribute it and/or modify 00003 * it under the terms of the GNU General Public License as published by 00004 * the Free Software Foundation; either version 3 of the License, or 00005 * (at your option) any later version. 00006 * 00007 * Written (W) 2009 Soeren Sonnenburg 00008 * Copyright (C) 2009 Berlin Institute of Technology 00009 */ 00010 #ifndef __COMPRESSOR_H__ 00011 #define __COMPRESSOR_H__ 00012 00013 #include <shogun/lib/config.h> 00014 #include <shogun/lib/common.h> 00015 #include <shogun/base/SGObject.h> 00016 #include <shogun/io/SGIO.h> 00017 00018 #ifdef USE_LZO 00019 #include <lzo/lzoconf.h> 00020 #include <lzo/lzo1x.h> 00021 #endif 00022 00023 namespace shogun 00024 { 00026 enum E_COMPRESSION_TYPE 00027 { 00028 UNCOMPRESSED, 00029 LZO, 00030 GZIP, 00031 BZIP2, 00032 LZMA, 00033 SNAPPY 00034 }; 00035 00036 00049 class CCompressor : public CSGObject 00050 { 00051 public: 00053 CCompressor(); 00054 00059 CCompressor(E_COMPRESSION_TYPE ct) : CSGObject(), compression_type(ct) 00060 { 00061 } 00062 00064 virtual ~CCompressor() 00065 { 00066 } 00067 00079 void compress(uint8_t* uncompressed, uint64_t uncompressed_size, 00080 uint8_t* &compressed, uint64_t &compressed_size, int32_t level=1); 00081 00094 void decompress(uint8_t* compressed, uint64_t compressed_size, 00095 uint8_t* uncompressed, uint64_t& uncompressed_size); 00096 00098 inline virtual const char* get_name() const { return "Compressor"; } 00099 00100 protected: 00102 E_COMPRESSION_TYPE compression_type; 00103 }; 00104 } 00105 #endif //__COMPRESSOR_H__