Line data Source code
1 : //-*- Mode: C++ -*-
2 : // $Id$
3 : #ifndef ALIHLTDATADEFLATERHUFFMAN_H
4 : #define ALIHLTDATADEFLATERHUFFMAN_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 AliHLTDataDeflaterHuffman.h
10 : /// @author Thorsten Kollegger, Matthias Richter
11 : /// @date 2011-08-10
12 : /// @brief Data deflater class using huffman coding
13 :
14 : #include "AliHLTDataDeflater.h"
15 : #include "AliHLTHuffman.h"
16 : #include <vector>
17 : #include <string>
18 : #include <sstream>
19 :
20 : /**
21 : * @class AliHLTDataDeflaterHuffman
22 : * Deflater implementation using standard huffman code.
23 : *
24 : * @ingroup alihlt_base
25 : */
26 : class AliHLTDataDeflaterHuffman : public AliHLTDataDeflater
27 : {
28 : public:
29 : /// standard constructor
30 : AliHLTDataDeflaterHuffman(bool bTrainingMode=false);
31 : /// destructor
32 : ~AliHLTDataDeflaterHuffman();
33 :
34 : /// add a parameter definition to the configuration, return reference id
35 : int AddParameterDefinition(const char* name, unsigned bitLength, unsigned refLength=0);
36 :
37 : /// init list of decoders
38 : int InitDecoders(TList* decoderlist);
39 :
40 : /// inherited from AliHLTDataDeflater: start the encoding for a new event
41 : virtual int StartEncoder();
42 :
43 : /// inherited from AliHLTDataDeflater: stop the encoding for current event
44 : virtual int StopEncoder();
45 :
46 : /// inherited from AliHLTDataDeflater: write bit pattern according to configuration
47 : virtual bool OutputParameterBits( int parameterId, AliHLTUInt64_t const & value );
48 :
49 : /// add a parameter definition for huffman training
50 : int AddTrainingParameter(const char* name, unsigned bitLength);
51 :
52 : /// add a training value for the specified parameter
53 : bool AddTrainingValue( int memberId, AliHLTUInt64_t const & value );
54 :
55 : /// generate huffman trees for all parameters and return list
56 : const TList* GenerateHuffmanTree();
57 :
58 0 : const TList* GetList() const {return fHuffmanCoderList;}
59 :
60 : /// clear the object and reset pointer references
61 : virtual void Clear(Option_t * /*option*/ ="");
62 :
63 : /// print info
64 : virtual void Print(Option_t *option="") const;
65 :
66 : /// print info
67 : virtual void Print(ostream& out, Option_t *option="") const;
68 :
69 : /// find object: 'DeflaterConfiguration'
70 : virtual TObject *FindObject(const char *name) const;
71 :
72 : /// save data according to option
73 : virtual void SaveAs(const char *filename="",Option_t *option="") const;
74 :
75 : /// DataDeflaterHuffman version (ID) is 2
76 0 : virtual int GetDeflaterVersion() const {return 2;}
77 :
78 : /// check if in training mode
79 0 : bool IsTrainingMode() const {return fTrainingMode;}
80 :
81 : protected:
82 : private:
83 : /// copy constructor prohibited
84 : AliHLTDataDeflaterHuffman(const AliHLTDataDeflaterHuffman&);
85 : /// assigment operator prohibited
86 : AliHLTDataDeflaterHuffman& operator=(const AliHLTDataDeflaterHuffman&);
87 :
88 : /// parameter length reference for calculation of ratio
89 : vector<unsigned> fReferenceLength;
90 : /// index of the decoders in the decoder list
91 : vector<AliHLTHuffman*> fHuffmanCoders; //! index of decoders
92 :
93 : /// list of huffman coders identified by parameter name
94 : TList* fHuffmanCoderList; //! list of huffman coders
95 :
96 : bool fTrainingMode; //! indicate training mode
97 :
98 : vector<unsigned> fParameterClusterCount; // cluster count for every parameter
99 : vector<unsigned> fBitCount; // bit count for every parameter
100 :
101 126 : ClassDef(AliHLTDataDeflaterHuffman, 0)
102 : };
103 :
104 : ostream& operator<<(ostream &out, const AliHLTDataDeflaterHuffman& me);
105 :
106 : #endif
|