]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/BASE/AliHLTComponent.cxx
- added version announcement to base library
[u/mrichter/AliRoot.git] / HLT / BASE / AliHLTComponent.cxx
CommitLineData
f23a6e1a 1// $Id$
2
3/**************************************************************************
4 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
5 * *
6 * Authors: Matthias Richter <Matthias.Richter@ift.uib.no> *
7 * Timm Steinbeck <timm@kip.uni-heidelberg.de> *
f23a6e1a 8 * for The ALICE Off-line Project. *
9 * *
10 * Permission to use, copy, modify and distribute this software and its *
11 * documentation strictly for non-commercial purposes is hereby granted *
12 * without fee, provided that the above copyright notice appears in all *
13 * copies and that both the copyright notice and this permission notice *
14 * appear in the supporting documentation. The authors make no claims *
15 * about the suitability of this software for any purpose. It is *
16 * provided "as is" without express or implied warranty. *
17 **************************************************************************/
18
bfccbf68 19/** @file AliHLTComponent.cxx
20 @author Matthias Richter, Timm Steinbeck
21 @date
22 @brief Base class implementation for HLT components. */
f23a6e1a 23
0c0c9d99 24#if __GNUC__>= 3
f23a6e1a 25using namespace std;
26#endif
27
85869391 28#include "AliHLTStdIncludes.h"
f23a6e1a 29#include "AliHLTComponent.h"
30#include "AliHLTComponentHandler.h"
f23a6e1a 31#include "AliHLTSystem.h"
32
b22e91eb 33/** ROOT macro for the implementation of ROOT specific class methods */
f23a6e1a 34ClassImp(AliHLTComponent)
35
f23a6e1a 36AliHLTComponent::AliHLTComponent()
85869391 37 :
38 fCurrentEvent(0),
39 fEnvironment()
f23a6e1a 40{
41 memset(&fEnvironment, 0, sizeof(AliHLTComponentEnvironment));
42 if (fpComponentHandler)
43 fpComponentHandler->ScheduleRegister(this);
44}
45
46AliHLTComponent::~AliHLTComponent()
47{
48}
49
b22e91eb 50AliHLTComponentHandler* AliHLTComponent::fpComponentHandler=NULL;
51
85869391 52int AliHLTComponent::SetGlobalComponentHandler(AliHLTComponentHandler* pCH, int bOverwrite)
53{
54 int iResult=0;
55 if (fpComponentHandler==NULL || bOverwrite!=0)
56 fpComponentHandler=pCH;
57 else
58 iResult=-EPERM;
59 return iResult;
60}
61
62int AliHLTComponent::UnsetGlobalComponentHandler() {
63 return SetGlobalComponentHandler(NULL,1);
64}
65
f23a6e1a 66int AliHLTComponent::Init( AliHLTComponentEnvironment* environ, void* environ_param, int argc, const char** argv )
67{
68 int iResult=0;
69 if (environ) {
70 memcpy(&fEnvironment, environ, sizeof(AliHLTComponentEnvironment));
71 fEnvironment.fParam=environ_param;
72 }
73 iResult=DoInit(argc, argv);
74 return iResult;
75}
76
77int AliHLTComponent::Deinit()
78{
79 int iResult=0;
80 iResult=DoDeinit();
81 return iResult;
82}
fa2e9b7c 83
84void AliHLTComponent::DataType2Text( const AliHLTComponent_DataType& type, char output[14] ) {
85memset( output, 0, 14 );
86strncat( output, type.fOrigin, 4 );
87strcat( output, ":" );
88strncat( output, type.fID, 8 );
89}
90
85869391 91void* AliHLTComponent::AllocMemory( unsigned long size ) {
92 if (fEnvironment.fAllocMemoryFunc)
93 return (*fEnvironment.fAllocMemoryFunc)(fEnvironment.fParam, size );
94 return NULL;
95}
96
fa2e9b7c 97int AliHLTComponent::MakeOutputDataBlockList( const vector<AliHLTComponent_BlockData>& blocks, AliHLTUInt32_t* blockCount,
98 AliHLTComponent_BlockData** outputBlocks ) {
99 if ( !blockCount || !outputBlocks )
100 return EFAULT;
101 AliHLTUInt32_t count = blocks.size();
102 if ( !count )
103 {
104 *blockCount = 0;
105 *outputBlocks = NULL;
106 return 0;
107 }
108 *outputBlocks = reinterpret_cast<AliHLTComponent_BlockData*>( AllocMemory( sizeof(AliHLTComponent_BlockData)*count ) );
109 if ( !*outputBlocks )
110 return ENOMEM;
111 for ( unsigned long i = 0; i < count; i++ )
112 (*outputBlocks)[i] = blocks[i];
113 *blockCount = count;
114 return 0;
115
116}
0c0c9d99 117
85869391 118int AliHLTComponent::GetEventDoneData( unsigned long size, AliHLTComponent_EventDoneData** edd ) {
119 if (fEnvironment.fGetEventDoneDataFunc)
120 return (*fEnvironment.fGetEventDoneDataFunc)(fEnvironment.fParam, fCurrentEvent, size, edd );
121 return -ENOSYS;
122}
123
0c0c9d99 124int AliHLTComponent::FindMatchingDataTypes(AliHLTComponent* pConsumer, vector<AliHLTComponent_DataType>* tgtList)
125{
126 int iResult=0;
127 if (pConsumer) {
128 vector<AliHLTComponent_DataType> ctlist;
129 ((AliHLTComponent*)pConsumer)->GetInputDataTypes(ctlist);
130 vector<AliHLTComponent_DataType>::iterator type=ctlist.begin();
131 while (type!=ctlist.end() && iResult==0) {
132 if ((*type)==GetOutputDataType()) {
133 if (tgtList) tgtList->push_back(*type);
134 iResult++;
135 break;
136 }
137 type++;
138 }
139 } else {
140 iResult=-EINVAL;
141 }
142 return iResult;
143}