]>
Commit | Line | Data |
---|---|---|
62bb3cd4 | 1 | //-*- Mode: C++ -*- |
2 | // @(#) $Id$ | |
3 | ||
4 | #ifndef ALIHLTOUTHANDLER_H | |
5 | #define ALIHLTOUTHANDLER_H | |
6 | /* This file is property of and copyright by the ALICE HLT Project * | |
7 | * ALICE Experiment at CERN, All rights reserved. * | |
8 | * See cxx source for full Copyright notice */ | |
9 | ||
10 | /** @file AliHLTOUTHandler.h | |
11 | @author Matthias Richter | |
12 | @date | |
13 | @brief Base class declaration of HLTOUT handlers | |
14 | ||
15 | // see below for class documentation | |
16 | // or | |
17 | // refer to README to build package | |
18 | // or | |
19 | // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt | |
20 | */ | |
21 | #include "AliHLTLogging.h" | |
22 | ||
23 | class AliHLTOUT; | |
24 | ||
25 | /** | |
26 | * @class AliHLTOUTHandler | |
27 | * Base class declaration of HLT output handlers. | |
28 | * The library implementation of the AliHLTModuleAgent allows to generate | |
29 | * handlers for data blocks of the HLT output. This can be the output of | |
30 | * the real HLT coming from the HLTOUT nodes, or simulated HLT output. <br> | |
31 | * \em Note: The created instance of AliHLTOUTHandler is | |
32 | * deleted by the framework. | |
33 | */ | |
34 | class AliHLTOUTHandler : public AliHLTLogging { | |
35 | public: | |
36 | /** standard constructor */ | |
37 | AliHLTOUTHandler(); | |
38 | /** standard destructor */ | |
39 | virtual ~AliHLTOUTHandler(); | |
40 | ||
62bb3cd4 | 41 | /** |
42 | * Process the data. | |
0f1882a7 | 43 | * The data blocks can be selected by AliHLTOUT::SelectFirstDataBlock() and |
44 | * AliHLTOUT::SelectNextDataBlock() | |
45 | * | |
46 | * Properties of the current data block can be retrieved by the following member | |
626bfcc1 | 47 | * functions of AliHLTOUT: |
48 | * - AliHLTOUT::GetDataBlockDescription(AliHLTComponentDataType& dt, AliHLTUInt32_t& spec) | |
49 | * - AliHLTOUT::GetDataBlockIndex() | |
50 | * - AliHLTOUT::GetDataBuffer(const AliHLTUInt8_t* &pBuffer, AliHLTUInt32_t& size) | |
51 | * - AliHLTOUT::ReleaseDataBuffer(const AliHLTUInt8_t* pBuffer) | |
52 | * | |
53 | * The handler might decode the data block and produce new data as a | |
54 | * replacement, see GetProcessedData() | |
55 | * @param pData instance of the AliHLTOUT data | |
56 | * @return depending on the overloaded function, neg. error code if failed | |
62bb3cd4 | 57 | */ |
58 | virtual int ProcessData(AliHLTOUT* pData) = 0; | |
59 | ||
626bfcc1 | 60 | /** |
61 | * Get the output data, if available. | |
62 | * Some of the handlers might produce data to replace the original data | |
63 | * block. The handler must ensure the internal storage of the buffer and | |
64 | * is also responsible for cleaning the buffer. The buffer must be valid | |
65 | * until the next call of ProcessData() or ReleaseProcessedData(). | |
66 | * | |
67 | * The default implementation just returns a NULL pointer to indicate | |
68 | * 'no data'. | |
69 | * @param pData target to receive data pointer | |
70 | * @return size of the buffer | |
71 | */ | |
72 | virtual int GetProcessedData(const AliHLTUInt8_t* &pData); | |
73 | ||
74 | /** | |
75 | * Release the buffer of processed data. | |
76 | * The handler implementation can do cleanup here. | |
77 | * @param pData pointer to buffer | |
78 | * @param size size of the buffer | |
79 | * @return neg. error code if failed | |
80 | */ | |
81 | virtual int ReleaseProcessedData(const AliHLTUInt8_t* pData, int size); | |
82 | ||
d4a18597 | 83 | /** |
84 | * Cleanup the current event processing. | |
85 | */ | |
86 | virtual int FinishEvent(); | |
87 | ||
88 | enum { | |
89 | kHandlerUndefined = 0, | |
90 | kHandlerOK = 0, | |
91 | kHandlerError = 0x1000 | |
92 | }; | |
93 | ||
94 | /** | |
95 | * Check state flag of the handler. | |
96 | * @return true if flag matches | |
97 | */ | |
98 | bool CheckStatus(unsigned int flag) { | |
99 | return (fState&flag)!=0; | |
100 | } | |
101 | ||
102 | /** | |
103 | * Reset the state flag. | |
104 | */ | |
105 | void ResetState() { | |
106 | fState=kHandlerOK; | |
107 | } | |
108 | ||
626bfcc1 | 109 | protected: |
d4a18597 | 110 | void SetStatusFlag(unsigned int flag) { |
111 | fState|=flag; | |
112 | } | |
113 | ||
114 | void ClearStatusFlag(unsigned int flag) { | |
115 | fState&=~flag; | |
116 | } | |
626bfcc1 | 117 | |
62bb3cd4 | 118 | private: |
119 | /** copy constructor prohibited */ | |
120 | AliHLTOUTHandler(const AliHLTOUTHandler&); | |
121 | /** assignment operator prohibited */ | |
122 | AliHLTOUTHandler& operator=(const AliHLTOUTHandler&); | |
123 | ||
d4a18597 | 124 | /** internal state of the handler */ |
125 | int fState; //!transient | |
126 | ||
62bb3cd4 | 127 | ClassDef(AliHLTOUTHandler, 0) |
128 | }; | |
129 | #endif |