tudocomp
– The TU Dortmund Compression Framework
Algorithm.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include <tudocomp/Meta.hpp>
4 #include <tudocomp/Env.hpp>
5 
6 namespace tdc {
7 
15 class Algorithm {
16  Env m_env;
17 public:
18  virtual ~Algorithm() = default;
19  Algorithm(Algorithm const&) = default;
20  Algorithm(Algorithm&&) = default;
21  Algorithm& operator=(Algorithm const&) = default;
22  Algorithm& operator=(Algorithm&&) = default;
23 
25  inline Algorithm() = delete;
27 
31  inline Algorithm(Env&& env): m_env(std::move(env)) {
32  /*
33  //FIXME:
34 
35  The following spooky lines of code are supposed to do absolutely
36  nothing except tell the compilation framework that we are really
37  serious about requiring "malloc".
38 
39  Not including an explicit call of "malloc" somewhere will cause the
40  compiler not to link against our custom "malloc" implementation in
41  the "tudocomp_stat" module.
42 
43  Until we know a better way to ensure this, this should stay.
44  */
45  volatile void* x = malloc(0);
46  if(x) { free((void*)x); x = nullptr; }
47  }
48 
51  inline Env& env() { return m_env; }
52  inline const Env& env() const { return m_env; }
53 };
54 
55 }
56 
Contains the text compression and encoding framework.
Definition: namespaces.hpp:11
const Env & env() const
Definition: Algorithm.hpp:52
Algorithm(Algorithm const &)=default
Env & env()
Provides access to the environment that the algorithm works in.
Definition: Algorithm.hpp:51
Algorithm & operator=(Algorithm const &)=default
virtual ~Algorithm()=default
Algorithm(Env &&env)
Instantiates an algorithm in the specified environment.
Definition: Algorithm.hpp:31
Local environment for a compression/encoding/decompression call.
Interface for algorithms.
Definition: Algorithm.hpp:15