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 *
9 /// @file AliHLTDataDeflater.h
10 /// @author Matthias Richter, Timm Steinbeck
12 /// @brief Data deflater class storing only necessary bits
13 /// @note Code original from AliHLTTPCCompModelDeflater
15 #include "AliHLTLogging.h"
16 #include "AliHLTDataTypes.h"
17 #include "AliHLTStdIncludes.h"
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
26 * @ingroup alihlt_base
28 class AliHLTDataDeflater : public AliHLTLogging
31 /// standard constructor
34 ~AliHLTDataDeflater();
36 /** function to initialise bit data output
37 * @param output AliHLTUInt8_t* pointer to output data
38 * @param outputSize UInt_t output size
40 int InitBitDataOutput( AliHLTUInt8_t* output, UInt_t outputSize );
42 /** function to close bit data output */
43 void CloseBitDataOutput();
45 /** function to get current byte output position
46 * @return unsigned long value for current byte output position
48 unsigned long GetCurrentByteOutputPosition() const
50 return (unsigned long)( fBitDataCurrentOutput - fBitDataCurrentOutputStart );
53 /** function to get current bit output position
54 * @return unsigned long value for current bit output position
56 unsigned GetCurrentBitOutputPosition() const
58 return fBitDataCurrentPosInWord;
61 /** function to get current output byte
62 * @param offset Int_t (set to zero if not specified explicitly)
63 * @return AliHLTUInt8_t value for current output byte
65 AliHLTUInt8_t GetCurrentOutputByte( Int_t offset=0 ) const;
67 /** function to get bit data output size bytes
68 * @return UInt_t value of bit data output size bytes
70 UInt_t GetBitDataOutputSizeBytes() const
72 return fBitDataCurrentOutput-fBitDataCurrentOutputStart;
75 /** function for output bit
76 * @param value AliHLTUInt32_t const & input
77 * @return boolean (output bit)
79 bool OutputBit( AliHLTUInt32_t const & value );
81 /** function to output bits
82 * @param value AliHLTUInt64_t const &
83 * @param bitCount UInt_t const &
84 * @return zero upon success
86 bool OutputBits( AliHLTUInt64_t const & value, UInt_t const & bitCount );
88 /* function pad 8 bits */
91 /** function to output bytes
92 * @param data AliHLTUInt8_t const *
93 * @param byteCount UInt_t const &
94 * @return boolean (output bytes)
96 bool OutputBytes( AliHLTUInt8_t const * data, UInt_t const & byteCount );
98 /// clear the object and reset pointer references
99 virtual void Clear(Option_t * /*option*/ ="");
102 virtual void Print(Option_t *option="") const;
105 virtual void Print(ostream& out, Option_t *option="") const;
107 /// write bit pattern of a parameter to the current byte and position
108 virtual bool OutputParameterBits( int parameterId, AliHLTUInt64_t const & value );
110 /// return unique version of the deflater, base class has version 0
111 virtual int GetDeflaterVersion() const {return 0;}
116 /// copy constructor prohibited
117 AliHLTDataDeflater(const AliHLTDataDeflater&);
118 /// assignment operator prohibited
119 AliHLTDataDeflater& operator=(const AliHLTDataDeflater&);
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
132 ClassDef(AliHLTDataDeflater, 0)
135 ostream& operator<<(ostream &out, const AliHLTDataDeflater& me);