]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/BASE/AliHLTDataSource.h
Minor cleanup of code.
[u/mrichter/AliRoot.git] / HLT / BASE / AliHLTDataSource.h
1 //-*- Mode: C++ -*-
2 // @(#) $Id$
3
4 #ifndef ALIHLTDATASOURCE_H
5 #define ALIHLTDATASOURCE_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   AliHLTDataSource.h
11     @author Matthias Richter
12     @date   
13     @brief  Base class declaration for HLT data source components.
14     @note   The class is used in Offline (AliRoot) context
15 */
16
17 // see below for class documentation
18 // or
19 // refer to README to build package
20 // or
21 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt   
22
23 #include "AliHLTComponent.h"
24
25 /**
26  * @class AliHLTDataSource
27  * Base class of HLT data source components.
28  * The class provides a common interface for the implementation of HLT data
29  * source components. The child class must implement the functions:
30  * - @ref DoInit (optional)
31  * - @ref DoDeinit (optional)
32  * - @ref GetEvent
33  * - @ref GetComponentID
34  * - @ref GetOutputDataType
35  * - @ref GetOutputDataSize
36  * - @ref Spawn
37  *
38  * @ingroup alihlt_component
39  */
40 class AliHLTDataSource : public AliHLTComponent {
41  public:
42   /** standard constructor */
43   AliHLTDataSource();
44   /** standard destructor */
45   virtual ~AliHLTDataSource();
46
47   /**
48    * Event processing function.
49    * The method is called by the framework to process one event. After 
50    * preparation of data structures. The call is redirected to GetEvent.
51    * @return neg. error code if failed                                <br>
52    *         -ENOSPC      output buffer too small
53    */
54   int DoProcessing( const AliHLTComponentEventData& evtData,
55                     const AliHLTComponentBlockData* blocks, 
56                     AliHLTComponentTriggerData& trigData,
57                     AliHLTUInt8_t* outputPtr, 
58                     AliHLTUInt32_t& size,
59                     vector<AliHLTComponentBlockData>& outputBlocks,
60                     AliHLTComponentEventDoneData*& edd );
61
62   // Information member functions for registration.
63
64   /**
65    * Return @ref AliHLTComponent::kSource type as component type.
66    * @return component type id
67    */
68   TComponentType GetComponentType() { return AliHLTComponent::kSource;}
69
70   /**
71    * Default implementation for all data sources.
72    * There are no input data types.
73    */
74   void GetInputDataTypes( vector<AliHLTComponentDataType>& list);
75
76   /**
77    * @class AliSpecialEventGuard
78    * Guard structure to set the data sources into 'special event publishing'
79    * mode. The SOR and EOR events are generated by all the data sources and
80    * perculated through the chain as normal events. The AliSpecialEventGuard
81    * is a back-door mechansim to trigger publishing of the special event
82    * described by the run descriptor instead of the publishing of real data.
83    *
84    * The descriptor has to be valid throughout the lifetime of the guard.
85    */
86   class AliSpecialEventGuard {
87   public:
88     /** constructor, set run descriptor */
89     AliSpecialEventGuard(AliHLTRunDesc* pDesc, AliHLTComponentDataType dt, AliHLTUInt32_t spec);
90     /** destructor, reset run descriptor */
91     ~AliSpecialEventGuard();
92   };
93
94 protected:
95
96   /**
97    * The low-level data processing method for the component.
98    * This is the custom processing method and can be overloaded by 
99    * the component.
100    * @param evtData       event data structure
101    * @param trigData      trigger data structure
102    * @param outputPtr     pointer to target buffer
103    * @param size          <i>input</i>: size of target buffer
104    *                      <i>output</i>:size of produced data
105    * @param outputBlocks  list to receive output block descriptors
106    * @return neg. error code if failed
107    */
108   virtual int GetEvent( const AliHLTComponentEventData& evtData,
109                 AliHLTComponentTriggerData& trigData,
110                 AliHLTUInt8_t* outputPtr, 
111                 AliHLTUInt32_t& size,
112                 vector<AliHLTComponentBlockData>& outputBlocks );
113
114   /**
115    * The high-level data processing method.
116    * This is the default processing method; the method is called
117    * if no low level @ref GetEvent method is overloaded by the component.
118    * @param evtData       event data structure
119    * @param trigData      trigger data structure
120    * @return neg. error code if failed
121    */
122   virtual int GetEvent( const AliHLTComponentEventData& evtData, AliHLTComponentTriggerData& trigData);
123
124 private:
125   /** pointer to the special event going to be published */
126   static void* fgpSpecialEvent; //! transient
127   /** data size of the special event going to be published */
128   static int fgSpecialEventSize; //! transient
129   /** data type of the special event going to be published */
130   static AliHLTComponentDataType fgSpecialEventDataType; //! transient
131   /** data specification of the special event going to be published */
132   static AliHLTUInt32_t fgSpecialEventSpecification; //! transient
133
134   ClassDef(AliHLTDataSource, 2)
135 };
136 #endif