changed include paths
[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
a5854ddd 12#include <cerrno>
5ec8e281 13#include "AliHLTLogging.h"
f23a6e1a 14#include "AliHLTDataTypes.h"
71d7c760 15#include "AliHLTDefinitions.h"
f23a6e1a 16#include "TObject.h"
17
18class AliHLTComponentHandler;
19
5ec8e281 20class 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;
0c0c9d99 43
44 int FindMatchingDataTypes(AliHLTComponent* pConsumer, vector<AliHLTComponent_DataType>* tgtList);
f23a6e1a 45
46 static int SetGlobalComponentHandler(AliHLTComponentHandler* pCH, int bOverwrite=0) {
47 int iResult=0;
48 if (fpComponentHandler==NULL || bOverwrite!=0)
49 fpComponentHandler=pCH;
50 else
51 iResult=-EPERM;
52 return iResult;
53 }
54 static int UnsetGlobalComponentHandler() {
55 return SetGlobalComponentHandler(NULL,1);
56 }
57 protected:
71d7c760 58
59 // Fill various structures with default values.
60 void FillBlockData( AliHLTComponent_BlockData& blockData ) {
61 blockData.fStructSize = sizeof(blockData);
62 FillShmData( blockData.fShmKey );
63 blockData.fOffset = ~(AliHLTUInt32_t)0;
64 blockData.fPtr = NULL;
65 blockData.fSize = 0;
66 FillDataType( blockData.fDataType );
67 blockData.fSpecification = ~(AliHLTUInt32_t)0;
68 }
69 void FillShmData( AliHLTComponent_ShmData& shmData ) {
70 shmData.fStructSize = sizeof(shmData);
71 shmData.fShmType = gkAliHLTComponent_InvalidShmType;
72 shmData.fShmID = gkAliHLTComponent_InvalidShmID;
73 }
74 void FillDataType( AliHLTComponent_DataType& dataType ) {
75 dataType.fStructSize = sizeof(dataType);
76 memset( dataType.fID, '*', 8 );
77 memset( dataType.fOrigin, '*', 4 );
78 }
f23a6e1a 79
80 virtual int DoInit( int argc, const char** argv ){
81 return 0;
82 }
83
84 virtual int DoDeinit(){
85 return 0;
86 }
87
88 void* AllocMemory( unsigned long size ) {
89 if (fEnvironment.fAllocMemoryFunc)
90 return (*fEnvironment.fAllocMemoryFunc)(fEnvironment.fParam, size );
91 return NULL;
92 }
93
94 int MakeOutputDataBlockList( const vector<AliHLTComponent_BlockData>& blocks, AliHLTUInt32_t* blockCount,
fa2e9b7c 95 AliHLTComponent_BlockData** outputBlocks );
96/* { */
97/* if (fEnvironment.fMakeOutputDataBlockListFunc) */
98/* return (*fEnvironment.fMakeOutputDataBlockListFunc)(fEnvironment.fParam, blocks, blockCount, outputBlocks ); */
99/* return -ENOSYS; */
100/* } */
f23a6e1a 101
102 int GetEventDoneData( unsigned long size, AliHLTComponent_EventDoneData** edd ) {
103 if (fEnvironment.fGetEventDoneDataFunc)
104 return (*fEnvironment.fGetEventDoneDataFunc)(fEnvironment.fParam, fCurrentEvent, size, edd );
105 return -ENOSYS;
106 }
107
f23a6e1a 108
fa2e9b7c 109 void DataType2Text( const AliHLTComponent_DataType& type, char output[14] );
110
f23a6e1a 111 private:
112 static AliHLTComponentHandler* fpComponentHandler;
113 AliHLTComponentEnvironment fEnvironment;
114
115 AliHLTEventID_t fCurrentEvent; // Set by ProcessEvent before actual processing starts (e.g. before calling AliHLTProcessor::DoEvent)
116
117 ClassDef(AliHLTComponent, 0)
118};
119#endif