Project
Loading...
Searching...
No Matches
TruncatedPrecisionConverter.h
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11
12/* Local Variables: */
13/* mode: c++ */
14/* End: */
15
16#ifndef TRUNCATEDPRECISIONCONVERTER_H
17#define TRUNCATEDPRECISIONCONVERTER_H
18
24
25namespace o2
26{
27namespace data_compression
28{
29
37template <class ParameterModelT>
39{
40 public:
41 TruncatedPrecisionConverter() : mParameterModel() {}
45
46 static const std::size_t sMaxLength = ParameterModelT::sBitlength;
47 using code_type = typename ParameterModelT::converted_type;
48
49 template <typename T, typename Writer>
50 int write(T value, Writer writer)
51 {
52 uint8_t bitlength = 0;
53 code_type content = 0;
54 mParameterModel.convert(value, content, bitlength);
55 return writer(content, bitlength);
56 }
57
58 void resetParameterModel() { mParameterModel.reset(); }
59
60 const ParameterModelT& getModel() const { return mParameterModel; }
61 ParameterModelT& getModel() { return mParameterModel; }
62
63 private:
65 ParameterModelT mParameterModel;
66};
67} // namespace data_compression
68} // namespace o2
69#endif
TruncatedPrecisionConverter(const TruncatedPrecisionConverter &)=delete
TruncatedPrecisionConverter & operator=(const TruncatedPrecisionConverter &)=delete
GLsizei const GLfloat * value
Definition glcorearb.h:819
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...