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 */
9 base class for HLT components
13 #include "AliHLTLogging.h"
14 #include "AliHLTDataTypes.h"
15 #include "AliHLTDefinitions.h"
18 class AliHLTComponentHandler;
20 class AliHLTComponent : public AliHLTLogging {
23 virtual ~AliHLTComponent();
25 enum TComponentType { kUnknown=0, kSource=1, kProcessor=2, kSink=3 };
26 virtual int Init( AliHLTComponentEnvironment* environ, void* environ_param, int argc, const char** argv );
28 virtual int ProcessEvent( const AliHLTComponent_EventData& evtData, const AliHLTComponent_BlockData* blocks,
29 AliHLTComponent_TriggerData& trigData, AliHLTUInt8_t* outputPtr,
30 AliHLTUInt32_t& size, AliHLTUInt32_t& outputBlockCnt,
31 AliHLTComponent_BlockData*& outputBlocks,
32 AliHLTComponent_EventDoneData*& edd ) = 0;
34 // Information member functions for registration.
35 virtual TComponentType GetComponentType() = 0; // Source, sink, or processor
36 virtual const char* GetComponentID() = 0;
37 virtual void GetInputDataTypes( vector<AliHLTComponent_DataType>& ) = 0;
38 virtual AliHLTComponent_DataType GetOutputDataType() = 0;
39 virtual void GetOutputDataSize( unsigned long& constBase, double& inputMultiplier ) = 0;
41 // Spawn function, return new class instance
42 virtual AliHLTComponent* Spawn() = 0;
44 static int SetGlobalComponentHandler(AliHLTComponentHandler* pCH, int bOverwrite=0) {
46 if (fpComponentHandler==NULL || bOverwrite!=0)
47 fpComponentHandler=pCH;
52 static int UnsetGlobalComponentHandler() {
53 return SetGlobalComponentHandler(NULL,1);
57 // Fill various structures with default values.
58 void FillBlockData( AliHLTComponent_BlockData& blockData ) {
59 blockData.fStructSize = sizeof(blockData);
60 FillShmData( blockData.fShmKey );
61 blockData.fOffset = ~(AliHLTUInt32_t)0;
62 blockData.fPtr = NULL;
64 FillDataType( blockData.fDataType );
65 blockData.fSpecification = ~(AliHLTUInt32_t)0;
67 void FillShmData( AliHLTComponent_ShmData& shmData ) {
68 shmData.fStructSize = sizeof(shmData);
69 shmData.fShmType = gkAliHLTComponent_InvalidShmType;
70 shmData.fShmID = gkAliHLTComponent_InvalidShmID;
72 void FillDataType( AliHLTComponent_DataType& dataType ) {
73 dataType.fStructSize = sizeof(dataType);
74 memset( dataType.fID, '*', 8 );
75 memset( dataType.fOrigin, '*', 4 );
78 virtual int DoInit( int argc, const char** argv ){
82 virtual int DoDeinit(){
86 void* AllocMemory( unsigned long size ) {
87 if (fEnvironment.fAllocMemoryFunc)
88 return (*fEnvironment.fAllocMemoryFunc)(fEnvironment.fParam, size );
92 int MakeOutputDataBlockList( const vector<AliHLTComponent_BlockData>& blocks, AliHLTUInt32_t* blockCount,
93 AliHLTComponent_BlockData** outputBlocks ) {
94 if (fEnvironment.fMakeOutputDataBlockListFunc)
95 return (*fEnvironment.fMakeOutputDataBlockListFunc)(fEnvironment.fParam, blocks, blockCount, outputBlocks );
99 int GetEventDoneData( unsigned long size, AliHLTComponent_EventDoneData** edd ) {
100 if (fEnvironment.fGetEventDoneDataFunc)
101 return (*fEnvironment.fGetEventDoneDataFunc)(fEnvironment.fParam, fCurrentEvent, size, edd );
107 static AliHLTComponentHandler* fpComponentHandler;
108 AliHLTComponentEnvironment fEnvironment;
110 AliHLTEventID_t fCurrentEvent; // Set by ProcessEvent before actual processing starts (e.g. before calling AliHLTProcessor::DoEvent)
112 ClassDef(AliHLTComponent, 0)