Tianjie Xu | 1c26e2e | 2017-10-26 17:19:41 -0700 | [diff] [blame] | 1 | // Copyright 2017 The Chromium OS Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef _BSDIFF_COMPRESSOR_INTERFACE_H_ |
| 6 | #define _BSDIFF_COMPRESSOR_INTERFACE_H_ |
| 7 | |
| 8 | #include <stddef.h> |
| 9 | #include <stdint.h> |
| 10 | |
| 11 | #include <memory> |
| 12 | #include <vector> |
| 13 | |
Tianjie Xu | 4d10c3e | 2017-10-26 14:02:06 -0700 | [diff] [blame] | 14 | #include "bsdiff/constants.h" |
Tianjie Xu | 1c26e2e | 2017-10-26 17:19:41 -0700 | [diff] [blame] | 15 | |
Tianjie Xu | 4d10c3e | 2017-10-26 14:02:06 -0700 | [diff] [blame] | 16 | namespace bsdiff { |
Tianjie Xu | 1c26e2e | 2017-10-26 17:19:41 -0700 | [diff] [blame] | 17 | |
| 18 | class CompressorInterface { |
| 19 | public: |
| 20 | virtual ~CompressorInterface() = default; |
| 21 | |
| 22 | // Compress and write |size| bytes of input data starting from |buf|. |
| 23 | virtual bool Write(const uint8_t* buf, size_t size) = 0; |
| 24 | |
| 25 | // Finish the compression step. |
| 26 | virtual bool Finish() = 0; |
| 27 | |
| 28 | // Return the compressed data. This method must be only called after Finish(). |
| 29 | virtual const std::vector<uint8_t>& GetCompressedData() = 0; |
| 30 | |
Tianjie Xu | b4cba64 | 2017-11-14 22:46:38 -0800 | [diff] [blame] | 31 | // Return the type of the current compressor. |
Tianjie Xu | 32b1f21 | 2018-03-06 11:42:45 -0800 | [diff] [blame] | 32 | virtual CompressorType Type() const = 0; |
Tianjie Xu | b4cba64 | 2017-11-14 22:46:38 -0800 | [diff] [blame] | 33 | |
Tianjie Xu | 1c26e2e | 2017-10-26 17:19:41 -0700 | [diff] [blame] | 34 | protected: |
| 35 | CompressorInterface() = default; |
| 36 | }; |
| 37 | |
Tianjie Xu | 1c26e2e | 2017-10-26 17:19:41 -0700 | [diff] [blame] | 38 | } // namespace bsdiff |
| 39 | |
| 40 | #endif // _BSDIFF_COMPRESSOR_INTERFACE_H_ |