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 "AliHLTDataTypes.h"
14 #include "AliHLTDefinitions.h"
17 class AliHLTComponentHandler;
19 class AliHLTComponent {
22 virtual ~AliHLTComponent();
24 enum TComponentType { kUnknown=0, kSource=1, kProcessor=2, kSink=3 };
25 virtual int Init( AliHLTComponentEnvironment* environ, void* environ_param, int argc, const char** argv );
27 virtual int ProcessEvent( const AliHLTComponent_EventData& evtData, const AliHLTComponent_BlockData* blocks,
28 AliHLTComponent_TriggerData& trigData, AliHLTUInt8_t* outputPtr,
29 AliHLTUInt32_t& size, AliHLTUInt32_t& outputBlockCnt,
30 AliHLTComponent_BlockData*& outputBlocks,
31 AliHLTComponent_EventDoneData*& edd ) = 0;
33 // Information member functions for registration.
34 virtual TComponentType GetComponentType() = 0; // Source, sink, or processor
35 virtual const char* GetComponentID() = 0;
36 virtual void GetInputDataTypes( vector<AliHLTComponent_DataType>& ) = 0;
37 virtual AliHLTComponent_DataType GetOutputDataType() = 0;
38 virtual void GetOutputDataSize( unsigned long& constBase, double& inputMultiplier ) = 0;
40 // Spawn function, return new class instance
41 virtual AliHLTComponent* Spawn() = 0;
43 static int SetGlobalComponentHandler(AliHLTComponentHandler* pCH, int bOverwrite=0) {
45 if (fpComponentHandler==NULL || bOverwrite!=0)
46 fpComponentHandler=pCH;
51 static int UnsetGlobalComponentHandler() {
52 return SetGlobalComponentHandler(NULL,1);
56 // Fill various structures with default values.
57 void FillBlockData( AliHLTComponent_BlockData& blockData ) {
58 blockData.fStructSize = sizeof(blockData);
59 FillShmData( blockData.fShmKey );
60 blockData.fOffset = ~(AliHLTUInt32_t)0;
61 blockData.fPtr = NULL;
63 FillDataType( blockData.fDataType );
64 blockData.fSpecification = ~(AliHLTUInt32_t)0;
66 void FillShmData( AliHLTComponent_ShmData& shmData ) {
67 shmData.fStructSize = sizeof(shmData);
68 shmData.fShmType = gkAliHLTComponent_InvalidShmType;
69 shmData.fShmID = gkAliHLTComponent_InvalidShmID;
71 void FillDataType( AliHLTComponent_DataType& dataType ) {
72 dataType.fStructSize = sizeof(dataType);
73 memset( dataType.fID, '*', 8 );
74 memset( dataType.fOrigin, '*', 4 );
77 virtual int DoInit( int argc, const char** argv ){
81 virtual int DoDeinit(){
85 void* AllocMemory( unsigned long size ) {
86 if (fEnvironment.fAllocMemoryFunc)
87 return (*fEnvironment.fAllocMemoryFunc)(fEnvironment.fParam, size );
91 int MakeOutputDataBlockList( const vector<AliHLTComponent_BlockData>& blocks, AliHLTUInt32_t* blockCount,
92 AliHLTComponent_BlockData** outputBlocks ) {
93 if (fEnvironment.fMakeOutputDataBlockListFunc)
94 return (*fEnvironment.fMakeOutputDataBlockListFunc)(fEnvironment.fParam, blocks, blockCount, outputBlocks );
98 int GetEventDoneData( unsigned long size, AliHLTComponent_EventDoneData** edd ) {
99 if (fEnvironment.fGetEventDoneDataFunc)
100 return (*fEnvironment.fGetEventDoneDataFunc)(fEnvironment.fParam, fCurrentEvent, size, edd );
104 int Logging( AliHLTComponent_LogSeverity severity, const char* origin, const char* keyword, const char* message, ... );
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)