]>
Commit | Line | Data |
---|---|---|
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 | */ | |
28 | class AliHLTDataDeflater : public AliHLTLogging | |
29 | { | |
30 | public: | |
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 */ | |
f95bc7cd | 43 | void CloseBitDataOutput(); |
80fb7693 | 44 | |
45 | /** function to get current byte output position | |
46 | * @return unsigned long value for current byte output position | |
47 | */ | |
48 | unsigned long GetCurrentByteOutputPosition() const | |
49 | { | |
50 | return (unsigned long)( fBitDataCurrentOutput - fBitDataCurrentOutputStart ); | |
51 | } | |
52 | ||
53 | /** function to get current bit output position | |
54 | * @return unsigned long value for current bit output position | |
55 | */ | |
56 | unsigned GetCurrentBitOutputPosition() const | |
57 | { | |
58 | return fBitDataCurrentPosInWord; | |
59 | } | |
60 | ||
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 | |
64 | */ | |
65 | AliHLTUInt8_t GetCurrentOutputByte( Int_t offset=0 ) const; | |
66 | ||
67 | /** function to get bit data output size bytes | |
68 | * @return UInt_t value of bit data output size bytes | |
69 | */ | |
70 | UInt_t GetBitDataOutputSizeBytes() const | |
71 | { | |
72 | return fBitDataCurrentOutput-fBitDataCurrentOutputStart; | |
73 | } | |
74 | ||
75 | /** function for output bit | |
76 | * @param value AliHLTUInt32_t const & input | |
77 | * @return boolean (output bit) | |
78 | */ | |
79 | bool OutputBit( AliHLTUInt32_t const & value ); | |
80 | ||
81 | /** function to output bits | |
82 | * @param value AliHLTUInt64_t const & | |
83 | * @param bitCount UInt_t const & | |
84 | * @return zero upon success | |
85 | */ | |
86 | bool OutputBits( AliHLTUInt64_t const & value, UInt_t const & bitCount ); | |
87 | ||
88 | /* function pad 8 bits */ | |
89 | void Pad8Bits(); | |
90 | ||
91 | /** function to output bytes | |
92 | * @param data AliHLTUInt8_t const * | |
93 | * @param byteCount UInt_t const & | |
94 | * @return boolean (output bytes) | |
95 | */ | |
96 | bool OutputBytes( AliHLTUInt8_t const * data, UInt_t const & byteCount ); | |
97 | ||
98 | /// clear the object and reset pointer references | |
99 | virtual void Clear(Option_t * /*option*/ =""); | |
100 | ||
101 | /// print info | |
102 | virtual void Print(Option_t *option="") const; | |
103 | ||
104 | /// print info | |
105 | virtual void Print(ostream& out, Option_t *option="") const; | |
106 | ||
107 | /// write bit pattern of a parameter to the current byte and position | |
108 | virtual bool OutputParameterBits( int parameterId, AliHLTUInt64_t const & value ); | |
109 | ||
f95bc7cd | 110 | /// return unique version of the deflater, base class has version 0 |
111 | virtual int GetDeflaterVersion() const {return 0;} | |
112 | ||
80fb7693 | 113 | protected: |
114 | ||
115 | private: | |
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 | ||
135 | ostream& operator<<(ostream &out, const AliHLTDataDeflater& me); | |
136 | ||
137 | #endif |