|
SHOGUN v0.9.3
|
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/lib/io.h> 00017 00018 #ifdef USE_LZO 00019 #include <lzo/lzoconf.h> 00020 #include <lzo/lzo1x.h> 00021 #endif 00022 00023 namespace shogun 00024 { 00025 enum E_COMPRESSION_TYPE 00026 { 00027 UNCOMPRESSED, 00028 LZO, 00029 GZIP, 00030 BZIP2, 00031 LZMA 00032 }; 00033 00034 00047 class CCompressor : public CSGObject 00048 { 00049 public: 00050 00055 CCompressor(E_COMPRESSION_TYPE ct) : CSGObject(), compression_type(ct) 00056 { 00057 } 00058 00060 virtual ~CCompressor() 00061 { 00062 } 00063 00075 void compress(uint8_t* uncompressed, uint64_t uncompressed_size, 00076 uint8_t* &compressed, uint64_t &compressed_size, int32_t level=1); 00077 00090 void decompress(uint8_t* compressed, uint64_t compressed_size, 00091 uint8_t* uncompressed, uint64_t& uncompressed_size); 00092 00094 inline virtual const char* get_name() const { return "Compressor"; } 00095 00096 protected: 00098 E_COMPRESSION_TYPE compression_type; 00099 }; 00100 } 00101 #endif //__COMPRESSOR_H__