]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/BASE/AliHLTDataDeflater.h
adding base class for data deflater based on AliHLTCompModelDeflater; adding simple...
[u/mrichter/AliRoot.git] / HLT / BASE / AliHLTDataDeflater.h
CommitLineData
80fb7693 1//-*- Mode: C++ -*-
2// $Id$
3#ifndef ALIHLTDATADEFLATER_H
4#define ALIHLTDATADEFLATER_H
5//* This file is property of and copyright by the ALICE HLT Project *
6//* ALICE Experiment at CERN, All rights reserved. *
7//* See cxx source for full Copyright notice *
8
9/// @file AliHLTDataDeflater.h
10/// @author Matthias Richter, Timm Steinbeck
11/// @date 2011-08-10
12/// @brief Data deflater class storing only necessary bits
13/// @note Code original from AliHLTTPCCompModelDeflater
14
15#include "AliHLTLogging.h"
16#include "AliHLTDataTypes.h"
17#include "AliHLTStdIncludes.h"
18
19/**
20 * @class AliHLTDataDeflater
21 * Data deflater class to write a bitstream into a buffer. The necessary
22 * number of bits for each value is written to a stream without gaps.
23 * The buffer can be padded to fill full bytes and continue writing at the
24 * next byte.
25 *
26 * @ingroup alihlt_base
27 */
28class AliHLTDataDeflater : public AliHLTLogging
29{
30public:
31 /// standard constructor
32 AliHLTDataDeflater();
33 /// destructor
34 ~AliHLTDataDeflater();
35
36 /** function to initialise bit data output
37 * @param output AliHLTUInt8_t* pointer to output data
38 * @param outputSize UInt_t output size
39 */
40 int InitBitDataOutput( AliHLTUInt8_t* output, UInt_t outputSize );
41
42 /** function to close bit data output */
43 void CloseBitDataOutput()
44 {
45 Pad8Bits();
46 }
47
48 /** function to get current byte output position
49 * @return unsigned long value for current byte output position
50 */
51 unsigned long GetCurrentByteOutputPosition() const
52 {
53 return (unsigned long)( fBitDataCurrentOutput - fBitDataCurrentOutputStart );
54 }
55
56 /** function to get current bit output position
57 * @return unsigned long value for current bit output position
58 */
59 unsigned GetCurrentBitOutputPosition() const
60 {
61 return fBitDataCurrentPosInWord;
62 }
63
64 /** function to get current output byte
65 * @param offset Int_t (set to zero if not specified explicitly)
66 * @return AliHLTUInt8_t value for current output byte
67 */
68 AliHLTUInt8_t GetCurrentOutputByte( Int_t offset=0 ) const;
69
70 /** function to get bit data output size bytes
71 * @return UInt_t value of bit data output size bytes
72 */
73 UInt_t GetBitDataOutputSizeBytes() const
74 {
75 return fBitDataCurrentOutput-fBitDataCurrentOutputStart;
76 }
77
78 /** function for output bit
79 * @param value AliHLTUInt32_t const & input
80 * @return boolean (output bit)
81 */
82 bool OutputBit( AliHLTUInt32_t const & value );
83
84 /** function to output bits
85 * @param value AliHLTUInt64_t const &
86 * @param bitCount UInt_t const &
87 * @return zero upon success
88 */
89 bool OutputBits( AliHLTUInt64_t const & value, UInt_t const & bitCount );
90
91 /* function pad 8 bits */
92 void Pad8Bits();
93
94 /** function to output bytes
95 * @param data AliHLTUInt8_t const *
96 * @param byteCount UInt_t const &
97 * @return boolean (output bytes)
98 */
99 bool OutputBytes( AliHLTUInt8_t const * data, UInt_t const & byteCount );
100
101 /// clear the object and reset pointer references
102 virtual void Clear(Option_t * /*option*/ ="");
103
104 /// print info
105 virtual void Print(Option_t *option="") const;
106
107 /// print info
108 virtual void Print(ostream& out, Option_t *option="") const;
109
110 /// write bit pattern of a parameter to the current byte and position
111 virtual bool OutputParameterBits( int parameterId, AliHLTUInt64_t const & value );
112
113protected:
114
115private:
116 /// copy constructor prohibited
117 AliHLTDataDeflater(const AliHLTDataDeflater&);
118 /// assignment operator prohibited
119 AliHLTDataDeflater& operator=(const AliHLTDataDeflater&);
120
121 /// bit data current word
122 AliHLTUInt8_t fBitDataCurrentWord; //! bit data current word
123 /// bit data current position in word
124 UInt_t fBitDataCurrentPosInWord; //! data current position in word
125 /// bit data current output
126 AliHLTUInt8_t *fBitDataCurrentOutput; //! bit data current output
127 /// bit data current output start
128 AliHLTUInt8_t *fBitDataCurrentOutputStart; //! bit data current output start
129 /// bit data current output end
130 AliHLTUInt8_t *fBitDataCurrentOutputEnd; //! bit data current output end
131
132 ClassDef(AliHLTDataDeflater, 0)
133};
134
135ostream& operator<<(ostream &out, const AliHLTDataDeflater& me);
136
137#endif