#pragma region CPL License /* Nuclex Native Framework Copyright (C) 2002-2021 Nuclex Development Labs This library is free software; you can redistribute it and/or modify it under the terms of the IBM Common Public License as published by the IBM Corporation; either version 1.0 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the IBM Common Public License for more details. You should have received a copy of the IBM Common Public License along with this library */ #pragma endregion // CPL License #ifndef NUCLEX_STORAGE_COMPRESSION_CSC_CSCCOMPRESSIONALGORITHM_H #define NUCLEX_STORAGE_COMPRESSION_CSC_CSCCOMPRESSIONALGORITHM_H #include "Nuclex/Storage/Config.h" #if defined(NUCLEX_STORAGE_HAVE_CSC) #include "Nuclex/Storage/Compression/CompressionAlgorithm.h" namespace Nuclex { namespace Storage { namespace Compression { namespace Csc { // ------------------------------------------------------------------------------------------- // /// Provides compressors and decompressors using the CSC algorithm class CscCompressionAlgorithm : public CompressionAlgorithm { /// Quality parameter that results in the fastest compression public: static const int FastestQuality; /// Quality parameter that results in the highest ratio compression public: static const int StrongestQuality; /// Quality parameter that results in reasonable compression /// /// There's usually a point where a compression algorithm's time requirement /// rises exponentially while the gains on terms of compression ratio are just /// minimal. This quality tries to reflect a point before. /// public: static const int DefaultQuality; /// Initializes the CSCcompressor and decompressor factory /// CSC compression level that will be used public: CscCompressionAlgorithm(int level); /// Frees all resources owned by the instance public: virtual ~CscCompressionAlgorithm() override = default; /// Returns the human-readable name of the compression algorithm /// The name of the compression algorithm the factory provides public: const std::string &GetName() const override { return this->name; } /// Returns a unique id for the compression algorithm /// The compression algorithm's unique id public: std::array GetId() const override { return std::array { 'C', 'S', 'A', 'C', '0', '0', '0', '1' }; } /// /// Returns the average number of CPU cycles this algorithm runs for to /// compress one kilobyte of data /// /// The avergae number of CPU cycles to comrpess one kilobyte public: std::size_t GetCompressionCyclesPerKilobyte() const override { return 10000; }; /// /// Returns the average size of data compressed with this algorithm as compared /// to its uncompressed size /// /// The average ratio of compressed size to uncompressed size public: float GetAverageCompressionRatio() const override { return 0.8f; } /// Whether this compression algorithm is experimental /// True if the compression algorithm is experimental, false otherwise public: bool IsExperimental() const override { return true; } /// Creates a new data compressor /// A new data compressor of the algorithm's type public: std::unique_ptr CreateCompressor() const override; /// Creates a new data decompressor /// A new data decompressor of the algorithm's type public: std::unique_ptr CreateDecompressor() const override; /// The name of the compression algorithm private: std::string name; /// Compression level that will be used when compressing things private: int level; }; // ------------------------------------------------------------------------------------------- // }}}} // namespace Nuclex::Storage::Compression::Csc #endif // defined(NUCLEX_STORAGE_HAVE_CSC) #endif // NUCLEX_STORAGE_COMPRESSION_CSC_CSCCOMPRESSOR_H