]>
Commit | Line | Data |
---|---|---|
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> | |
5ec8e281 | 13 | #include "AliHLTLogging.h" |
f23a6e1a | 14 | #include "AliHLTDataTypes.h" |
71d7c760 | 15 | #include "AliHLTDefinitions.h" |
f23a6e1a | 16 | #include "TObject.h" |
17 | ||
18 | class AliHLTComponentHandler; | |
19 | ||
5ec8e281 | 20 | class AliHLTComponent : public AliHLTLogging { |
f23a6e1a | 21 | public: |
22 | AliHLTComponent(); | |
23 | virtual ~AliHLTComponent(); | |
24 | ||
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 ); | |
27 | virtual int Deinit(); | |
71d7c760 | 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; | |
f23a6e1a | 33 | |
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; | |
71d7c760 | 39 | virtual void GetOutputDataSize( unsigned long& constBase, double& inputMultiplier ) = 0; |
f23a6e1a | 40 | |
41 | // Spawn function, return new class instance | |
42 | virtual AliHLTComponent* Spawn() = 0; | |
43 | ||
44 | static int SetGlobalComponentHandler(AliHLTComponentHandler* pCH, int bOverwrite=0) { | |
45 | int iResult=0; | |
46 | if (fpComponentHandler==NULL || bOverwrite!=0) | |
47 | fpComponentHandler=pCH; | |
48 | else | |
49 | iResult=-EPERM; | |
50 | return iResult; | |
51 | } | |
52 | static int UnsetGlobalComponentHandler() { | |
53 | return SetGlobalComponentHandler(NULL,1); | |
54 | } | |
55 | protected: | |
71d7c760 | 56 | |
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; | |
63 | blockData.fSize = 0; | |
64 | FillDataType( blockData.fDataType ); | |
65 | blockData.fSpecification = ~(AliHLTUInt32_t)0; | |
66 | } | |
67 | void FillShmData( AliHLTComponent_ShmData& shmData ) { | |
68 | shmData.fStructSize = sizeof(shmData); | |
69 | shmData.fShmType = gkAliHLTComponent_InvalidShmType; | |
70 | shmData.fShmID = gkAliHLTComponent_InvalidShmID; | |
71 | } | |
72 | void FillDataType( AliHLTComponent_DataType& dataType ) { | |
73 | dataType.fStructSize = sizeof(dataType); | |
74 | memset( dataType.fID, '*', 8 ); | |
75 | memset( dataType.fOrigin, '*', 4 ); | |
76 | } | |
f23a6e1a | 77 | |
78 | virtual int DoInit( int argc, const char** argv ){ | |
79 | return 0; | |
80 | } | |
81 | ||
82 | virtual int DoDeinit(){ | |
83 | return 0; | |
84 | } | |
85 | ||
86 | void* AllocMemory( unsigned long size ) { | |
87 | if (fEnvironment.fAllocMemoryFunc) | |
88 | return (*fEnvironment.fAllocMemoryFunc)(fEnvironment.fParam, size ); | |
89 | return NULL; | |
90 | } | |
91 | ||
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 ); | |
96 | return -ENOSYS; | |
97 | } | |
98 | ||
99 | int GetEventDoneData( unsigned long size, AliHLTComponent_EventDoneData** edd ) { | |
100 | if (fEnvironment.fGetEventDoneDataFunc) | |
101 | return (*fEnvironment.fGetEventDoneDataFunc)(fEnvironment.fParam, fCurrentEvent, size, edd ); | |
102 | return -ENOSYS; | |
103 | } | |
104 | ||
f23a6e1a | 105 | |
106 | private: | |
107 | static AliHLTComponentHandler* fpComponentHandler; | |
108 | AliHLTComponentEnvironment fEnvironment; | |
109 | ||
110 | AliHLTEventID_t fCurrentEvent; // Set by ProcessEvent before actual processing starts (e.g. before calling AliHLTProcessor::DoEvent) | |
111 | ||
112 | ClassDef(AliHLTComponent, 0) | |
113 | }; | |
114 | #endif |