]>
Commit | Line | Data |
---|---|---|
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 | 25 | using namespace std; |
26 | #endif | |
27 | ||
28 | #include "AliHLTComponent.h" | |
29 | #include "AliHLTComponentHandler.h" | |
a5854ddd | 30 | #include <string> |
f23a6e1a | 31 | #include "AliHLTSystem.h" |
32 | ||
33 | ClassImp(AliHLTComponent) | |
34 | ||
35 | AliHLTComponentHandler* AliHLTComponent::fpComponentHandler=NULL; | |
36 | ||
37 | AliHLTComponent::AliHLTComponent() | |
38 | { | |
39 | memset(&fEnvironment, 0, sizeof(AliHLTComponentEnvironment)); | |
40 | if (fpComponentHandler) | |
41 | fpComponentHandler->ScheduleRegister(this); | |
42 | } | |
43 | ||
44 | AliHLTComponent::~AliHLTComponent() | |
45 | { | |
46 | } | |
47 | ||
48 | int AliHLTComponent::Init( AliHLTComponentEnvironment* environ, void* environ_param, int argc, const char** argv ) | |
49 | { | |
50 | int iResult=0; | |
51 | if (environ) { | |
52 | memcpy(&fEnvironment, environ, sizeof(AliHLTComponentEnvironment)); | |
53 | fEnvironment.fParam=environ_param; | |
54 | } | |
55 | iResult=DoInit(argc, argv); | |
56 | return iResult; | |
57 | } | |
58 | ||
59 | int AliHLTComponent::Deinit() | |
60 | { | |
61 | int iResult=0; | |
62 | iResult=DoDeinit(); | |
63 | return iResult; | |
64 | } | |
fa2e9b7c | 65 | |
66 | void AliHLTComponent::DataType2Text( const AliHLTComponent_DataType& type, char output[14] ) { | |
67 | memset( output, 0, 14 ); | |
68 | strncat( output, type.fOrigin, 4 ); | |
69 | strcat( output, ":" ); | |
70 | strncat( output, type.fID, 8 ); | |
71 | } | |
72 | ||
73 | int AliHLTComponent::MakeOutputDataBlockList( const vector<AliHLTComponent_BlockData>& blocks, AliHLTUInt32_t* blockCount, | |
74 | AliHLTComponent_BlockData** outputBlocks ) { | |
75 | if ( !blockCount || !outputBlocks ) | |
76 | return EFAULT; | |
77 | AliHLTUInt32_t count = blocks.size(); | |
78 | if ( !count ) | |
79 | { | |
80 | *blockCount = 0; | |
81 | *outputBlocks = NULL; | |
82 | return 0; | |
83 | } | |
84 | *outputBlocks = reinterpret_cast<AliHLTComponent_BlockData*>( AllocMemory( sizeof(AliHLTComponent_BlockData)*count ) ); | |
85 | if ( !*outputBlocks ) | |
86 | return ENOMEM; | |
87 | for ( unsigned long i = 0; i < count; i++ ) | |
88 | (*outputBlocks)[i] = blocks[i]; | |
89 | *blockCount = count; | |
90 | return 0; | |
91 | ||
92 | } | |
0c0c9d99 | 93 | |
94 | int AliHLTComponent::FindMatchingDataTypes(AliHLTComponent* pConsumer, vector<AliHLTComponent_DataType>* tgtList) | |
95 | { | |
96 | int iResult=0; | |
97 | if (pConsumer) { | |
98 | vector<AliHLTComponent_DataType> ctlist; | |
99 | ((AliHLTComponent*)pConsumer)->GetInputDataTypes(ctlist); | |
100 | vector<AliHLTComponent_DataType>::iterator type=ctlist.begin(); | |
101 | while (type!=ctlist.end() && iResult==0) { | |
102 | if ((*type)==GetOutputDataType()) { | |
103 | if (tgtList) tgtList->push_back(*type); | |
104 | iResult++; | |
105 | break; | |
106 | } | |
107 | type++; | |
108 | } | |
109 | } else { | |
110 | iResult=-EINVAL; | |
111 | } | |
112 | return iResult; | |
113 | } |