tudocomp
– The TU Dortmund Compression Framework
RoundContext.hpp
Go to the documentation of this file.
1 #pragma once
2 
8 
9 namespace tdc {namespace esp {
10  template<typename round_view_t>
11  struct RoundContext {
13 
16 
17  size_t alphabet_size;
18  std::vector<size_t> scratchpad;
19  round_view_t s;
20  size_t i = 0;
21  size_t last_i = 0;
22 
23  std::vector<TypedBlock> block_buffer;
24 
25  RoundContext(size_t as,
26  round_view_t src,
27  bool metablocks_maximimze_repeating,
28  bool landmarks_tie_to_right,
29  DebugRoundContext debug_ctx):
30  debug(debug_ctx),
31  behavior_metablocks_maximimze_repeating(metablocks_maximimze_repeating),
32  behavior_landmarks_tie_to_right(landmarks_tie_to_right),
33  alphabet_size(as),
34  scratchpad(),
35  s(src),
36  i(0),
37  last_i(0)
38  {}
39 
41  IF_DEBUG(
42  size_t full_size = 0;
43  for (auto& b : block_buffer) {
44  full_size += b.len;
45  }
46  DCHECK_EQ(full_size, s.size()) << errmsg;
47  );
48  }
49 
50  void push_back(size_t l, size_t type) {
51  IF_DEBUG(i += l;)
52  block_buffer.push_back(TypedBlock { uint8_t(l), uint8_t(type) });
53  }
54 
55  void debug_check_advanced(size_t len) {
56  IF_DEBUG(
57  DCHECK_EQ(i - last_i, len);
58  last_i = i;
59  )
60  }
61 
62  std::vector<TypedBlock>& adjusted_blocks() {
63  debug_check_sizes("pre adjust");
64  adjust_blocks(block_buffer);
65  debug_check_sizes("post adjust");
66  debug.adjusted_blocks(block_buffer);
67 
68  IF_DEBUG(
69  for (auto& b: block_buffer) {
70  DCHECK_GE(b.len, 2);
71  DCHECK_LE(b.len, 3);
72  }
73  );
74  return block_buffer;
75  }
76 
77  void split(round_view_t);
78  };
79 }}
void split(round_view_t)
Contains the text compression and encoding framework.
Definition: namespaces.hpp:11
void debug_check_sizes(string_ref errmsg)
std::vector< TypedBlock > block_buffer
A const view into a slice of memory.
void adjusted_blocks(const ConstGenericView< TypedBlock > &buf)
std::vector< size_t > scratchpad
len_compact_t len
Definition: LZSSFactors.hpp:38
void adjust_blocks(std::vector< TypedBlock > &blocks)
Definition: BlockAdjust.hpp:39
DebugRoundContext debug
void debug_check_advanced(size_t len)
void push_back(size_t l, size_t type)
bool behavior_metablocks_maximimze_repeating
len_compact_t src
Definition: LZSSFactors.hpp:38
std::vector< TypedBlock > & adjusted_blocks()
RoundContext(size_t as, round_view_t src, bool metablocks_maximimze_repeating, bool landmarks_tie_to_right, DebugRoundContext debug_ctx)
#define IF_DEBUG(x)
x is compiled only in debug builds.
Definition: def.hpp:32