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