TPIE

2362a60
scheme.h
Go to the documentation of this file.
1 // -*- mode: c++; tab-width: 4; indent-tabs-mode: t; c-file-style: "stroustrup"; -*-
2 // vi:set ts=4 sts=4 sw=4 noet :
3 // Copyright 2013, The TPIE development team
4 //
5 // This file is part of TPIE.
6 //
7 // TPIE is free software: you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License as published by the
9 // Free Software Foundation, either version 3 of the License, or (at your
10 // option) any later version.
11 //
12 // TPIE is distributed in the hope that it will be useful, but WITHOUT ANY
13 // WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
15 // License for more details.
16 //
17 // You should have received a copy of the GNU Lesser General Public License
18 // along with TPIE. If not, see <http://www.gnu.org/licenses/>
19 
20 #ifndef TPIE_COMPRESSED_SCHEME_H
21 #define TPIE_COMPRESSED_SCHEME_H
22 
26 
27 namespace tpie {
28 
45 };
46 
51 public:
52  enum type {
53  none = 0,
54  snappy = 1
55  };
56 
64  virtual size_t max_compressed_length(size_t srcSize) const = 0;
65 
70  virtual void compress(char * dest, const char * src, size_t srcSize, size_t * destSize) const = 0;
71 
75  virtual size_t uncompressed_length(const char * src, size_t srcSize) const = 0;
76 
80  virtual void uncompress(char * dest, const char * src, size_t srcSize) const = 0;
81 
82 protected:
83  ~compression_scheme() {}
84 };
85 
86 const compression_scheme & get_compression_scheme_none();
87 const compression_scheme & get_compression_scheme_snappy();
88 
89 inline const compression_scheme & get_compression_scheme(compression_scheme::type t) {
90  switch (t) {
91  case compression_scheme::none:
92  return get_compression_scheme_none();
93  case compression_scheme::snappy:
94  return get_compression_scheme_snappy();
95  }
96  return get_compression_scheme_none();
97 }
98 
99 }
100 
101 #endif // TPIE_COMPRESSED_SCHEME_H
No written blocks should be compressed.
Definition: scheme.h:37
virtual void compress(char *dest, const char *src, size_t srcSize, size_t *destSize) const =0
Compress data from src into dest, returning its size in destSize.
Abstract virtual base class for each compression scheme.
Definition: scheme.h:50
virtual size_t max_compressed_length(size_t srcSize) const =0
An upper bound on the size of a compressed block corresponding to an uncompressed input of size srcSi...
compression_flags
Possible values for the compressionFlags parameter to stream::open.
Definition: scheme.h:33
Compress some blocks according to available resources (time, memory).
Definition: scheme.h:40
virtual void uncompress(char *dest, const char *src, size_t srcSize) const =0
Uncompress a compressed block at src into dest.
virtual size_t uncompressed_length(const char *src, size_t srcSize) const =0
Get the uncompressed size of the compressed block at src.
Compress all blocks according to the preferred compression scheme which can be set using tpie::the_co...
Definition: scheme.h:44