]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/BASE/AliHLTOUT.h
bugfixes, code cleanup and docu
[u/mrichter/AliRoot.git] / HLT / BASE / AliHLTOUT.h
1 //-*- Mode: C++ -*-
2 // @(#) $Id$
3
4 #ifndef ALIHLTOUT_H
5 #define ALIHLTOUT_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   AliHLTOUT.h
11     @author Matthias Richter
12     @date   
13     @brief  The control class for HLTOUT data.
14 */
15
16 #include <vector>
17 #include "AliHLTLogging.h"
18 #include "AliHLTModuleAgent.h"
19
20 class AliHLTOUTHandler;
21 class AliHLTOUTHandlerDesc; // AliHLTModuleAgent.h
22 class AliESDEvent;
23 class AliHLTReconstructor;
24 class AliRawReader;
25 class TTree;
26
27 #define AliHLTOUTInvalidIndex (~(AliHLTUInt32_t)0)
28
29 typedef vector<AliHLTUInt32_t> AliHLTOUTIndexList;
30
31 /**
32  * @class AliHLTOUT
33  * The control class for HLTOUT data.
34  * The output of the HLT, either from the HLTOUT nodes or simulated output,
35  * is transferred and stored in the HOMER format. The AliHLTOUT class 
36  * implements scanning of the HOMER data for all HLTOUT DDL links and
37  * abstracts access to the complete HLTOUT data.
38  * 
39  */
40 class AliHLTOUT {
41  public:
42   /** standard constructor */
43   AliHLTOUT();
44   /** standard destructor */
45   virtual ~AliHLTOUT();
46
47   /**
48    * Create an AliHLTOUTRawReader instance.
49    * Helper function to transparently access classes from the
50    * libHLTrec library.
51    */
52   static AliHLTOUT* New(AliRawReader* pRawReader);
53
54   /**
55    * Create an AliHLTOUTDigitReader instance
56    * Helper function to transparently access classes from the
57    * libHLTrec library.
58    */
59   static AliHLTOUT* New(TTree* pDigitTree, int event=-1);
60
61   /**
62    * Get the global instance.
63    * The global instance is set temporarily by the AliHLTOUTGlobalInstanceGuard
64    * mainly for the sake of data input to an analysis chain. The
65    * AliHLTOUTPublisherComponent objects can access the global instance.
66    */
67   static AliHLTOUT* GetGlobalInstance() {return fgGlobalInstance;}
68
69   /**
70    * Delete an instance of the HLTOUT.
71    * Helper function to transparently access classes from the
72    * libHLTrec library. Before deleting, the availability of the
73    * library is checked.
74    */
75   static void Delete(AliHLTOUT* pInstance);
76
77   /**
78    * Locking guard for the AliHLTOUT object.
79    * If the object is locked, the selection of data blocks can not be changed.
80    */
81   class AliHLTOUTLockGuard {
82   public:
83     /** constructor */
84     AliHLTOUTLockGuard(AliHLTOUT* pInstance) : fpInstance(pInstance)
85     {if (fpInstance) fpInstance->SetStatusFlag(kLocked);}
86     /** destructor */
87     ~AliHLTOUTLockGuard()
88     {if (fpInstance) fpInstance->ClearStatusFlag(kLocked);}
89
90   private:
91     /** standard constructor prohibited */
92     AliHLTOUTLockGuard();
93     /** copy constructor prohibited */
94     AliHLTOUTLockGuard(const AliHLTOUTLockGuard&);
95     /** assignment operator prohibited */
96     AliHLTOUTLockGuard& operator=(const AliHLTOUTLockGuard&);
97
98     /** the AliHLTOUT instance the guard is locking */
99     AliHLTOUT* fpInstance; //!transient
100   };
101
102   /**
103    * Guard for handling of global AliHLTOUT instance.
104    * The global HLTOUT instance can be set for certain steps of the
105    * processing. The initial objective is to support input to the
106    * AliHLTOUTPublisherComponent running in a kChain handler.
107    *
108    * The Guard restores the original instance when closed.
109    */
110   class AliHLTOUTGlobalInstanceGuard {
111   public:
112     /** constructor */
113     AliHLTOUTGlobalInstanceGuard(AliHLTOUT* pInstance) : fpLastInstance(AliHLTOUT::fgGlobalInstance)
114     {AliHLTOUT::fgGlobalInstance=pInstance;}
115     /** destructor */
116     ~AliHLTOUTGlobalInstanceGuard()
117     {AliHLTOUT::fgGlobalInstance=fpLastInstance;}
118
119   private:
120     /** standard constructor prohibited */
121     AliHLTOUTGlobalInstanceGuard();
122     /** copy constructor prohibited */
123     AliHLTOUTGlobalInstanceGuard(const AliHLTOUTGlobalInstanceGuard&);
124     /** assignment operator prohibited */
125     AliHLTOUTGlobalInstanceGuard& operator=(const AliHLTOUTGlobalInstanceGuard&);
126
127     /** the AliHLTOUT instance the guard is locking */
128     AliHLTOUT* fpLastInstance; //!transient
129   };
130
131   /**
132    * The HLT OUT Event Header.
133    * Defined between HLT and DAQ.
134    */
135   struct AliHLTOUTEventHeader {
136     /**Total length of the data in bytes, including HLT event header, excluding CDH. */
137     AliHLTUInt32_t fLength; //! see above
138     /** version of the header */
139     AliHLTUInt32_t fVersion; //! see above
140     /** High 32 bit word of event id */
141     AliHLTUInt32_t fEventIDHigh; //! see above
142     /** Low 32 bit word of event id */
143     AliHLTUInt32_t fEventIDLow; //! see above
144   };
145
146   enum {
147     /// versions 1 of the HLT header
148     kVersion1 = 1,
149     /// versions 2 of the HLT header
150     kVersion2 = 2
151   };
152
153   enum {
154     /// size of HLT decision in data format version 1: 29x4
155     kSizeDecisionVersion1 = 116,
156     /// size of HLT decision in data format version 2: 30x4
157     kSizeDecisionVersion2 = 120
158   };
159
160   // definitions from ALICE internal notes ALICE-INT-2002-010 and
161   // ALICE-INT-2006-XXX
162   enum {
163     /** the 32bit word in the CDH containing the status flags */
164     kCDHStatusWord=4, //! see above
165     /** start of the flags in word fgkCDHStatusWord */
166     kCDHStatusFlagsOffset=12, //! see above
167     /** bit indicating HLT decision in the HLTOUT*/
168     kCDHFlagsHLTDecision=6, //! see above
169     /** bit indicating HLT payload in the HLTOUT*/
170     kCDHFlagsHLTPayload=7 //! see above
171   };
172
173   /**
174    * Block descriptor.
175    */
176   class AliHLTOUTBlockDescriptor {
177   public:
178     AliHLTOUTBlockDescriptor(AliHLTComponentDataType dt, AliHLTUInt32_t spec, AliHLTUInt32_t index, AliHLTOUT* pCollection)
179       : fDataType(dt), fSpecification(spec), fIndex(index), fSelected(false), fProcessed(false), fpCollection(pCollection) {};
180     AliHLTOUTBlockDescriptor(const AliHLTOUTBlockDescriptor& src)
181       : fDataType(src.fDataType), fSpecification(src.fSpecification), fIndex(src.fIndex), fSelected(false), fProcessed(false), fpCollection(src.fpCollection) {}
182     AliHLTOUTBlockDescriptor& operator=(const AliHLTOUTBlockDescriptor& src)
183     { fDataType=src.fDataType; fSpecification=src.fSpecification; fIndex=src.fIndex; fSelected=false; fProcessed=false; fpCollection=src.fpCollection; return *this; }
184     ~AliHLTOUTBlockDescriptor() {}
185
186     operator AliHLTComponentDataType() const {return fDataType;}
187     operator AliHLTUInt32_t() const {return fSpecification;}
188     int operator==(AliHLTComponentDataType dt) const {return dt==fDataType;}
189     int operator==(AliHLTUInt32_t spec) const {return spec==fSpecification;}
190     int operator==(AliHLTOUT* collection) const {return collection==fpCollection;}
191
192     AliHLTUInt32_t GetIndex() const {return fIndex;}
193     AliHLTOUT* GetCollection() const {return fpCollection;}
194
195     bool IsSelected() const {return fSelected;}
196     void Select(bool selected=true) {fSelected=selected;}
197     bool IsProcessed() const {return fProcessed;}
198     void MarkProcessed() {fProcessed=true;}
199
200     /**
201      * Get the data buffer
202      * @param pBuffer [out] buffer of the selected data block
203      * @param size    [out] size of the selected data block
204      */
205     int GetDataBuffer(const AliHLTUInt8_t* &pBuffer, AliHLTUInt32_t& size) {
206       if (fpCollection) return fpCollection->GetDataBuffer(GetIndex(), pBuffer, size);
207       return -ENODEV;
208     }
209
210   private:      
211     /** data type of the block */
212     AliHLTComponentDataType fDataType; //!transient
213     /** data specification of the block */
214     AliHLTUInt32_t          fSpecification; //!transient
215     /** index in the data stream */
216     AliHLTUInt32_t          fIndex; //!transient
217     /** selection flag */
218     bool                    fSelected; //!transient
219     /** processed flag */
220     bool                    fProcessed; //!transient
221     /** the collection */
222     AliHLTOUT*              fpCollection; //!transient
223   };
224
225   class AliHLTOUTHandlerListEntry {
226   public:
227     AliHLTOUTHandlerListEntry(AliHLTOUTHandler* pHandler, 
228                               AliHLTModuleAgent::AliHLTOUTHandlerDesc& handlerDesc,
229                               AliHLTModuleAgent* pAgent,
230                               AliHLTUInt32_t index);
231
232     /** copy constructor for vector handling */
233     AliHLTOUTHandlerListEntry(const AliHLTOUTHandlerListEntry& src);
234
235     /** assignment operator for vector handling */
236     AliHLTOUTHandlerListEntry& operator=(const AliHLTOUTHandlerListEntry& src);
237
238     ~AliHLTOUTHandlerListEntry();
239
240     static const AliHLTOUTHandlerListEntry fgkVoidHandlerListEntry; //! initializer
241
242     operator AliHLTOUTHandler*() const {return fpHandler;}
243
244     // please note that fpHandlerDesc is really a pointer and is created
245     // in the constructor. Thats why it is dereferenced here. The pointer
246     // type is on purpose, even though it is a bit confusing with the 
247     // argument by reference in the AliHLTOUTHandlerListEntry constructor.
248     operator const AliHLTModuleAgent::AliHLTOUTHandlerDesc&() const 
249     {return fpHandlerDesc?*fpHandlerDesc:AliHLTModuleAgent::fgkVoidHandlerDesc;}
250     operator AliHLTModuleAgent*() const {return fpAgent;}
251
252     /**
253      * Two list entries are considered to be equal if the handlers
254      * are equal.
255      */
256     bool operator==(const AliHLTOUTHandlerListEntry& entry) const;
257
258     bool operator==(const AliHLTModuleAgent::AliHLTOUTHandlerType handlerType) const;
259
260     /**
261      * Compare the handler descriptor of this list entry with another
262      * descriptor.
263      */
264     bool operator==(const AliHLTModuleAgent::AliHLTOUTHandlerDesc desc) const; 
265
266     AliHLTUInt32_t operator[](int i) const;
267
268     /**
269      * Add a block index to this descriptor.
270      * One descriptor can serve multiple blocks if the agent returns the
271      * same handler for all of the blocks. Instead of creating a new entry
272      * the block index ist just added
273      */
274     void AddIndex(AliHLTUInt32_t index);
275
276     /**
277      * Add all indices of the descriptor.
278      */
279     void AddIndex(AliHLTOUTHandlerListEntry &desc);
280
281     /**
282      * Check if an index is served by this descriptor.
283      * @return true if the index is in the table
284      */
285     bool HasIndex(AliHLTUInt32_t index) const;
286
287     /**
288      * Invalidate all block indices
289      */
290     void InvalidateBlocks() {fBlocks.clear();}
291
292     /**
293      * Check whether the entry has valid blocks.
294      */
295     bool IsEmpty() {return fBlocks.size()==0;}
296
297   private:
298     /** standard constructor prohibited */
299     AliHLTOUTHandlerListEntry();
300
301     /** pointer to the handler */
302     AliHLTOUTHandler* fpHandler; //! transient
303
304     /** pointer to handler description */
305     AliHLTModuleAgent::AliHLTOUTHandlerDesc* fpHandlerDesc; //! transient
306
307     /** pointer to module agent */
308     AliHLTModuleAgent* fpAgent; //! transient
309
310     /** list of block indices */
311     AliHLTOUTIndexList fBlocks; //!transient
312   };
313
314   typedef vector<AliHLTOUTHandlerListEntry> AliHLTOUTHandlerListEntryVector;
315   typedef vector<AliHLTOUTBlockDescriptor>  AliHLTOUTBlockDescriptorVector;
316   typedef vector<AliHLTOUT*>                AliHLTOUTPVector;
317
318   /**
319    * Selection guard for the AliHLTOUT object.
320    * If the object is locked, the selection of data blocks can not be changed.
321    */
322   class AliHLTOUTSelectionGuard {
323   public:
324     /** constructor */
325     AliHLTOUTSelectionGuard(AliHLTOUT* pInstance) : fpInstance(pInstance)
326     {if (fpInstance) fpInstance->SelectDataBlock();}
327     /** constructor */
328     AliHLTOUTSelectionGuard(AliHLTOUT* pInstance, const AliHLTOUTHandlerListEntry* pHandlerDesc) : fpInstance(pInstance)
329     {if (fpInstance) fpInstance->SelectDataBlocks(pHandlerDesc);}
330     /** destructor */
331     ~AliHLTOUTSelectionGuard()
332     {if (fpInstance) fpInstance->DisableBlockSelection();}
333
334   private:
335     /** standard constructor prohibited */
336     AliHLTOUTSelectionGuard();
337     /** copy constructor prohibited */
338     AliHLTOUTSelectionGuard(const AliHLTOUTSelectionGuard&);
339     /** assignment operator prohibited */
340     AliHLTOUTSelectionGuard& operator=(const AliHLTOUTSelectionGuard&);
341
342     /** the AliHLTOUT instance the guard is locking */
343     AliHLTOUT* fpInstance; //!transient
344   };
345
346   /**
347    * Init for processing.
348    * The HLTOUT is scanned for all available data blocks and the
349    * AliHLTOUTHandler objects for the data blocks are created according
350    * to the module agents (see AliHLTModuleAgent).
351    */
352   int Init();
353
354   /**
355    * Reset and clear all data block descriptors.
356    * @note Since sub-collections are only referred via the block
357    * descriptors, all information on sub-collections is also lost.
358    * Child classes should implement ResetInput in order to cleanup
359    * the input devices.
360    */
361   int Reset();
362
363   /**
364    * Get number of data blocks in the HLTOUT data
365    */
366   int GetNofDataBlocks();
367
368   /**
369    * Select the first data block of a certain data type and specification.
370    * The selection criteria can be of kAliHLTAnyDataType and/or
371    * kAliHLTVoidDataSpec in order to be ignored and just match any data block.
372    *
373    * The search criteria can be combined with a handler type (e.g. kRawReader)
374    * @param dt    [in]  data type to match                                <br>
375    * @param spec  [in]  data specification to match                       <br>
376    * @param handlerType [in]  type of the handler
377    * @param skipProcessed [in] skip all block marked processed
378    * @return block index: >= 0 if success, -ENOENT if no block found      <br>
379    *         neg. error code if failed                                    <br>
380    *                        -EPERM if access denied (object locked)
381    */
382   int SelectFirstDataBlock(AliHLTComponentDataType dt=kAliHLTAnyDataType,
383                            AliHLTUInt32_t spec=kAliHLTVoidDataSpec,
384                            AliHLTModuleAgent::AliHLTOUTHandlerType handlerType=AliHLTModuleAgent::kUnknownOutput,
385                            bool skipProcessed=true);
386
387   /**
388    * Select the next data block of data type and specification of the previous
389    * call to @ref SelectFirstDataBlock.
390    * @return block index: >= 0 if success, -ENOENT if no block found      <br>
391    *         neg. error code if failed                                    <br>
392    *                        -EPERM if access denied (object locked)
393    */
394   int SelectNextDataBlock();
395
396   /**
397    * Get properties of the selected data block.
398    * @param dt    [out] data type of the selected block
399    * @param spec  [out] data specification of the selected block
400    */
401   int GetDataBlockDescription(AliHLTComponentDataType& dt, AliHLTUInt32_t& spec);
402
403   /**
404    * Get handler description of the current data block.
405    */
406   const AliHLTOUTHandlerListEntry& GetDataBlockHandlerDesc();
407
408   /**
409    * Get handler type of the selected data block.
410    * @return handler type for the selected data block
411    */
412   AliHLTModuleAgent::AliHLTOUTHandlerType GetDataBlockHandlerType();
413
414   /**
415    * Get the index of the current data block.
416    * @return index, AliHLTOUTInvalidIndex if no block selected
417    */
418   AliHLTUInt32_t GetDataBlockIndex();
419
420   /**
421    * Get buffer of the selected data block.
422    * @param pBuffer [out] buffer of the selected data block
423    * @param size    [out] size of the selected data block
424    */
425   int GetDataBuffer(const AliHLTUInt8_t* &pBuffer, AliHLTUInt32_t& size);
426
427   /**
428    * Release buffer after use.
429    * @param pBuffer [in]  buffer of the selected data block
430    */
431   int ReleaseDataBuffer(const AliHLTUInt8_t* pBuffer);
432
433   /**
434    * Add the current data block to the selection.
435    * Note: enables also the block selection
436    */
437   int SelectDataBlock();
438
439   /**
440    * Add the all data blocks of a certain handler to the selection.
441    * Note: enables also the block selection
442    */
443   int SelectDataBlocks(const AliHLTOUTHandlerListEntry* pHandlerDesc);
444
445   /**
446    * Enable the selection of data blocks.
447    */
448   int EnableBlockSelection();
449
450   /**
451    * Disable the selection of data blocks.
452    */
453   int DisableBlockSelection();
454
455   /**
456    * Reset the data block selection.
457    * Resets the selection list, none of the blocks is selected.
458    */
459   int ResetBlockSelection();
460
461   /**
462    * Mark the current block as processed.
463    */
464   int MarkDataBlockProcessed();
465
466   /**
467    * Mark all data blocks of a certain handler processed.
468    */
469   int MarkDataBlocksProcessed(const AliHLTOUTHandlerListEntry* pHandlerDesc);
470
471   /**
472    * Add a sub collection to the HLTOUT.
473    */
474   int AddSubCollection(AliHLTOUT* pCollection);
475
476   /**
477    * Release a previously added sub collection.
478    */
479   int ReleaseSubCollection(AliHLTOUT* pCollection);
480
481   /**
482    * Get module agent for the selected data block.
483    */
484   AliHLTModuleAgent* GetAgent();
485
486   /**
487    * Get handler for the selected data block.
488    */
489   AliHLTOUTHandler* GetHandler();
490
491   /**
492    * Convert data buffer to ESD.
493    * The buffer is supposed to describe a streamed AliESDEvent object.
494    * If no target object is specified, the ESD is written to a file AliHLTdetESDs.root,
495    * where 'det' is derived from the data type origin. Each time the function is invoked
496    * a new event is created. Dummy events are added if the previous events did not contain
497    *
498    * The function needs AliRoot and might not be implemented by all AliHLTOUT
499    * implementations.
500    * a data block of this specification.
501    * @param pBuffer  [in] the data buffer
502    * @param size     [in] data buffer size
503    * @param dt       [in] data type of the block
504    * @param tgtesd   [out] optional target
505    */
506   virtual int WriteESD(const AliHLTUInt8_t* pBuffer, AliHLTUInt32_t size, AliHLTComponentDataType dt, AliESDEvent* tgtesd=NULL) const;
507
508   enum AliHLTOUTByteOrder {
509     /** no data block selected */
510     kInvalidByteOrder=-1,
511     kUnknownByteOrder=0,
512     kLittleEndian,
513     kBigEndian
514   };
515
516   enum AliHLTOUTDataType {
517     kUint64 = 0,
518     kUint32 = 1,
519     kUint16 = 2,
520     kUint8  = 3,
521     kDouble = 4,
522     kFloat  = 5
523   };
524
525   /**
526    * Check byte order of selected block
527    */
528   AliHLTOUTByteOrder CheckByteOrder();
529
530   /**
531    * Check alignment of selected block
532    */
533   int CheckAlignment(AliHLTOUT::AliHLTOUTDataType type);
534
535   /**
536    * Helper function to byte swap a 64 bit value.
537    */
538   static AliHLTUInt64_t ByteSwap64(AliHLTUInt64_t src);
539
540   /**
541    * Helper function to byte swap a 32 bit value.
542    */
543   static AliHLTUInt32_t ByteSwap32(AliHLTUInt32_t src);
544
545   /**
546    * Insert a handler item.
547    * The current list entries are checked if the handler is already in
548    * the list. It is added if not in the list, otherwise the block index
549    * is added to the existing entry.
550    * @param list     the handler list
551    * @param entry    handler list entry
552    * @return 0 if added, EEXIST (non negative!) if merged with existing entry <br>
553    *         neg. error code if failed
554    */
555   static int InsertHandler(AliHLTOUTHandlerListEntryVector& list, const AliHLTOUTHandlerListEntry &entry);
556   
557   /**
558    * Insert all handlers of the specified type to the list.
559    */
560   int FillHandlerList(AliHLTOUTHandlerListEntryVector& list, AliHLTModuleAgent::AliHLTOUTHandlerType handlerType);
561
562   /**
563    * Remove empty items which have a duplicate in the list.
564    */
565   static int RemoveEmptyDuplicateHandlers(AliHLTOUTHandlerListEntryVector& list);
566
567   /**
568    * Find an entry of a certain description in the list.
569    * @return index of the entry if found, -ENOENT if not found
570    */
571   static int FindHandler(AliHLTOUTHandlerListEntryVector& list, const AliHLTModuleAgent::AliHLTOUTHandlerDesc desc);
572
573   /**
574    * Invalidate all blocks of the handlers in the list
575    */
576   static int InvalidateBlocks(AliHLTOUTHandlerListEntryVector& list);
577
578  protected:
579   /**
580    * Add a block descriptor.
581    * This is done by the child classes generating the index. The AliHLTOUT
582    * object must be locked for index generation.
583    * @param desc    the block descriptor
584    * @return 0 if success, -EPERM if access denied
585    */
586   int AddBlockDescriptor(const AliHLTOUTBlockDescriptor desc);
587
588   /**
589    * Print output or suppress.
590    */
591   bool BeVerbose() {return fbVerbose;}
592
593   /**
594    * Switch output.
595    */
596   void SwitchVerbosity(bool verbose) {fbVerbose=verbose;}
597
598  private:
599   /** copy constructor prohibited */
600   AliHLTOUT(const AliHLTOUT&);
601   /** assignment operator prohibited */
602   AliHLTOUT& operator=(const AliHLTOUT&);
603
604   /**
605    * Internal status flags
606    */
607   enum {
608     /** the HLTOUT object is locked with the current data block selection */
609     kLocked = 0x1,
610     /** childs can add block descriptors */
611     kCollecting = 0x2,
612     /** user of the data block has checked the byte order */
613     kByteOrderChecked = 0x4,
614     /** warning on byte order missmatch has been printed */
615     kByteOrderWarning = 0x8,
616     /** user of the data block has checked the alignment */
617     kAlignmentChecked = 0x10,
618     /** warning on alignment missmatch has been printed */
619     kAlignmentWarning = 0x20,
620     /** enable block selection list */
621     kBlockSelection = 0x40,
622     /** skip processed data blocks */
623     kSkipProcessed = 0x80,
624     /** marked as sub collection */
625     kIsSubCollection = 0x100
626   };
627
628   /**
629    * Generate the index of the HLTOUT data.
630    * Must be implemented by the child classes.
631    */
632   virtual int GenerateIndex()=0;
633
634   /**
635    * Find AliHLTOUTHandler objects for the data blocks.
636    * The available AliHLTModuleAgents are probed whether they provide
637    * handlers for data processing.
638    */
639   int InitHandlers();
640
641   /**
642    * Cleanup and reset the data input.
643    */
644   virtual int ResetInput();
645
646   /**
647    * Get the data buffer
648    * @param index   [in]  index of the block
649    * @param pBuffer [out] buffer of the selected data block
650    * @param size    [out] size of the selected data block
651    */
652   virtual int GetDataBuffer(AliHLTUInt32_t index, const AliHLTUInt8_t* &pBuffer, 
653                             AliHLTUInt32_t& size)=0;
654
655   /**
656    * Check byte order of data block
657    */
658   virtual AliHLTOUTByteOrder CheckBlockByteOrder(AliHLTUInt32_t index)=0;
659
660   /**
661    * Check alignment of data block
662    */
663   virtual int CheckBlockAlignment(AliHLTUInt32_t index, AliHLTOUT::AliHLTOUTDataType type)=0;
664
665   /**
666    * Select the data block of data type and specification of the previous
667    * call to @ref SelectFirstDataBlock. Core function of @ref SelectFirstDataBlock
668    * and @ref SelectNextDataBlock, starts to find a block at the current list
669    * position.
670    * 
671    * The data block is searched from the conditions of fSearchDataType,
672    * fSearchSpecification, fSearchHandlerType and the selection list.
673    *
674    * @return identifier >=0 if success, neg. error code if failed         <br>
675    *                        -ENOENT if no block found                     <br>
676    *                        -EPERM if access denied (object locked)
677    */
678   int FindAndSelectDataBlock();
679
680   /**
681    * Set status flag.
682    * @param flag     flag to set
683    * @return current status flags
684    */
685   unsigned int SetStatusFlag(unsigned int flag) {return fFlags|=flag;}
686
687   /**
688    * Clear status flag.
689    * @param flag     flag to clear
690    * @return current status flags
691    */
692   unsigned int ClearStatusFlag(unsigned int flag) {return fFlags&=~flag;}
693
694   /**
695    * Check status flag.
696    * @param flag     flag to check
697    * @return 1 if flag is set
698    */
699   int CheckStatusFlag(unsigned int flag) const {return (fFlags&flag)==flag;}
700
701   /**
702    * Find handler description for a certain block index.
703    */
704   const AliHLTOUTHandlerListEntry& FindHandlerDesc(AliHLTUInt32_t blockIndex);
705
706   /**
707    * Internal New function for the external HLTOUT instances.
708    * Currently supported classes are AliHLTOUTRawReader and
709    * AliHLTOUTDigitReader, both implemented in libHLTrec.so.
710    */
711   static AliHLTOUT* New(const char* classname);
712
713   /**
714    * Set the RawReader as parameter.
715    * The function is for internal use only in conjunction with the
716    * New() functions.
717    */
718   virtual void SetParam(AliRawReader* pRawReader);
719
720   /**
721    * Set the RunLoader as parameter
722    * The function is for internal use only in conjunction with the
723    * New() functions.
724    */
725   virtual void SetParam(TTree* pDigitTree, int event=-1);
726
727   /** data type for the current block search, set from @ref SelectFirstDataBlock */
728   AliHLTComponentDataType fSearchDataType; //!transient
729
730   /** data specification for the current block search */
731   AliHLTUInt32_t fSearchSpecification; //!transient
732
733   /** handler type for the current block search */
734   AliHLTModuleAgent::AliHLTOUTHandlerType fSearchHandlerType; // !transient
735
736   /** instance flags: locked, collecting, ... */
737   unsigned int fFlags; //!transient
738
739   /** list of block descriptors */
740   AliHLTOUTBlockDescriptorVector fBlockDescList; //!transient
741
742   /** current position in the list */
743   unsigned int fCurrent; //!transient
744
745   /** data buffer under processing */
746   const AliHLTUInt8_t* fpBuffer; //!transient
747
748   /** list of AliHLTOUTHandlers */
749   AliHLTOUTHandlerListEntryVector fDataHandlers; // !transient
750
751   /** verbose or silent output */
752   bool fbVerbose; //!transient
753
754   /** gobal instance set for certain steps of the analysis */
755   static AliHLTOUT* fgGlobalInstance; //! transient
756
757   /** logging methods */
758   AliHLTLogging fLog; //! transient
759
760   ClassDef(AliHLTOUT, 4)
761 };
762 #endif