]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/BASE/AliHLTComponent.h
FMD1 position at 320 (see FMD TDR table 4.1)
[u/mrichter/AliRoot.git] / HLT / BASE / AliHLTComponent.h
CommitLineData
f23a6e1a 1// @(#) $Id$
2
3#ifndef ALIHLTCOMPONENT_H
4#define ALIHLTCOMPONENT_H
5/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
6 * See cxx source for full Copyright notice */
7
8/* AliHLTComponent
9 base class for HLT components
10 */
11
12#include <errno.h>
13#include "AliHLTDataTypes.h"
14#include "TObject.h"
15
16class AliHLTComponentHandler;
17
18class AliHLTComponent {
19 public:
20 AliHLTComponent();
21 virtual ~AliHLTComponent();
22
23 enum TComponentType { kUnknown=0, kSource=1, kProcessor=2, kSink=3 };
24 virtual int Init( AliHLTComponentEnvironment* environ, void* environ_param, int argc, const char** argv );
25 virtual int Deinit();
26 virtual int ProcessEvent( AliHLTComponent_EventData evtData, AliHLTComponent_BlockData* blocks,
27 AliHLTComponent_TriggerData trigData, AliHLTUInt8_t* outputPtr,
28 AliHLTUInt32_t* size, AliHLTUInt32_t* outputBlockCnt,
29 AliHLTComponent_BlockData** outputBlocks,
30 AliHLTComponent_EventDoneData** edd ) = 0;
31
32 // Information member functions for registration.
33 virtual TComponentType GetComponentType() = 0; // Source, sink, or processor
34 virtual const char* GetComponentID() = 0;
35 virtual void GetInputDataTypes( vector<AliHLTComponent_DataType>& ) = 0;
36 virtual AliHLTComponent_DataType GetOutputDataType() = 0;
37
38 // Spawn function, return new class instance
39 virtual AliHLTComponent* Spawn() = 0;
40
41 static int SetGlobalComponentHandler(AliHLTComponentHandler* pCH, int bOverwrite=0) {
42 int iResult=0;
43 if (fpComponentHandler==NULL || bOverwrite!=0)
44 fpComponentHandler=pCH;
45 else
46 iResult=-EPERM;
47 return iResult;
48 }
49 static int UnsetGlobalComponentHandler() {
50 return SetGlobalComponentHandler(NULL,1);
51 }
52 protected:
53
54 virtual int DoInit( int argc, const char** argv ){
55 return 0;
56 }
57
58 virtual int DoDeinit(){
59 return 0;
60 }
61
62 void* AllocMemory( unsigned long size ) {
63 if (fEnvironment.fAllocMemoryFunc)
64 return (*fEnvironment.fAllocMemoryFunc)(fEnvironment.fParam, size );
65 return NULL;
66 }
67
68 int MakeOutputDataBlockList( const vector<AliHLTComponent_BlockData>& blocks, AliHLTUInt32_t* blockCount,
69 AliHLTComponent_BlockData** outputBlocks ) {
70 if (fEnvironment.fMakeOutputDataBlockListFunc)
71 return (*fEnvironment.fMakeOutputDataBlockListFunc)(fEnvironment.fParam, blocks, blockCount, outputBlocks );
72 return -ENOSYS;
73 }
74
75 int GetEventDoneData( unsigned long size, AliHLTComponent_EventDoneData** edd ) {
76 if (fEnvironment.fGetEventDoneDataFunc)
77 return (*fEnvironment.fGetEventDoneDataFunc)(fEnvironment.fParam, fCurrentEvent, size, edd );
78 return -ENOSYS;
79 }
80
81 int Logging( AliHLTComponent_LogSeverity severity, const char* origin, const char* keyword, const char* message, ... );
82
83 private:
84 static AliHLTComponentHandler* fpComponentHandler;
85 AliHLTComponentEnvironment fEnvironment;
86
87 AliHLTEventID_t fCurrentEvent; // Set by ProcessEvent before actual processing starts (e.g. before calling AliHLTProcessor::DoEvent)
88
89 ClassDef(AliHLTComponent, 0)
90};
91#endif