]>
Commit | Line | Data |
---|---|---|
c5318542 | 1 | // $Id$ |
2 | ||
289c6c1a | 3 | //************************************************************************** |
4 | //* This file is property of and copyright by the ALICE HLT Project * | |
5 | //* ALICE Experiment at CERN, All rights reserved. * | |
6 | //* * | |
7 | //* Primary Authors: Matthias Richter <Matthias.Richter@ift.uib.no> * | |
8 | //* Timm Steinbeck <timm@kip.uni-heidelberg.de> * | |
9 | //* for The ALICE HLT Project. * | |
10 | //* * | |
11 | //* Permission to use, copy, modify and distribute this software and its * | |
12 | //* documentation strictly for non-commercial purposes is hereby granted * | |
13 | //* without fee, provided that the above copyright notice appears in all * | |
14 | //* copies and that both the copyright notice and this permission notice * | |
15 | //* appear in the supporting documentation. The authors make no claims * | |
16 | //* about the suitability of this software for any purpose. It is * | |
17 | //* provided "as is" without express or implied warranty. * | |
18 | //************************************************************************** | |
19 | ||
20 | // @file AliHLTSampleComponent1.cxx | |
21 | // @author Matthias Richter, Timm M. Steinbeck | |
22 | // @date | |
23 | // @brief A sample processing component for the HLT. | |
24 | // Component illustrates the basic functionality and component | |
25 | // initialization. | |
c5318542 | 26 | |
27 | #if __GNUC__== 3 | |
28 | using namespace std; | |
29 | #endif | |
30 | ||
c5318542 | 31 | #include "AliHLTSampleComponent1.h" |
5045badf | 32 | #include "TString.h" |
33 | #include "TObjString.h" | |
289c6c1a | 34 | #include "TMap.h" |
c5318542 | 35 | |
5045badf | 36 | /** ROOT macro for the implementation of ROOT specific class methods */ |
c5318542 | 37 | ClassImp(AliHLTSampleComponent1) |
38 | ||
289c6c1a | 39 | /** one global instance used for registration */ |
40 | AliHLTSampleComponent1 gAliHLTSampleComponent1; | |
41 | ||
c5318542 | 42 | AliHLTSampleComponent1::AliHLTSampleComponent1() |
289c6c1a | 43 | : AliHLTProcessor() |
44 | , fArgument1(0) | |
45 | , fArgument2(0) | |
c5318542 | 46 | { |
289c6c1a | 47 | // an example component which implements the ALICE HLT processor |
48 | // interface and illustrates the basic interface methods | |
49 | // | |
f644d3f1 | 50 | // see header file for class documentation |
5045badf | 51 | // or |
52 | // refer to README to build package | |
53 | // or | |
54 | // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt | |
289c6c1a | 55 | // |
56 | // NOTE: all helper classes should be instantiated in DoInit() | |
c5318542 | 57 | } |
58 | ||
59 | AliHLTSampleComponent1::~AliHLTSampleComponent1() | |
60 | { | |
289c6c1a | 61 | // destructor |
62 | // | |
63 | // NOTE: implement proper cleanup in DoDeinit() | |
64 | } | |
65 | ||
66 | const char* AliHLTSampleComponent1::GetComponentID() | |
67 | { | |
68 | // component property: id | |
69 | return "Sample-component1"; | |
70 | } | |
71 | ||
72 | void AliHLTSampleComponent1::GetInputDataTypes( vector<AliHLTComponentDataType>& list) | |
73 | { | |
74 | // component property: list of input data types | |
75 | list.push_back(kAliHLTAnyDataType); | |
76 | } | |
77 | ||
78 | AliHLTComponentDataType AliHLTSampleComponent1::GetOutputDataType() | |
79 | { | |
80 | // component property: output data type | |
81 | return kAliHLTVoidDataType; | |
82 | } | |
83 | ||
84 | void AliHLTSampleComponent1::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier ) | |
85 | { | |
86 | // component property: output size estimator | |
87 | constBase = 0; | |
88 | inputMultiplier = 0; | |
89 | } | |
90 | ||
91 | void AliHLTSampleComponent1::GetOCDBObjectDescription( TMap* const targetMap) | |
92 | { | |
93 | // Get a list of OCDB object description. | |
94 | // The list of objects is provided in a TMap | |
95 | // - key: complete OCDB path, e.g. GRP/GRP/Data | |
96 | // - value: short description why the object is needed | |
97 | // Key and value objects created inside this class go into ownership of | |
98 | // target TMap. | |
99 | if (!targetMap) return; | |
100 | targetMap->Add(new TObjString("HLT/ConfigSample/SampleComponent1"), | |
101 | new TObjString("configuration object")); | |
102 | } | |
103 | ||
104 | AliHLTComponent* AliHLTSampleComponent1::Spawn() | |
105 | { | |
106 | // Spawn function, return new class instance | |
107 | return new AliHLTSampleComponent1; | |
c5318542 | 108 | } |
109 | ||
5045badf | 110 | int AliHLTSampleComponent1::DoInit( int argc, const char** argv ) |
111 | { | |
f644d3f1 | 112 | // see header file for class documentation |
5045badf | 113 | int iResult=0; |
289c6c1a | 114 | |
115 | // init stage 1: default values for all data members | |
116 | fArgument1=0; | |
117 | fArgument2=0; | |
118 | ||
119 | // init stage 2: read configuration object | |
120 | // ScanConfigurationArgument() needs to be implemented | |
121 | TString cdbPath="HLT/ConfigSample/SampleComponent1"; | |
122 | iResult=ConfigureFromCDBTObjString(cdbPath); | |
123 | ||
124 | // init stage 3: read the component arguments | |
125 | if (iResult>=0) { | |
126 | iResult=ConfigureFromArgumentString(argc, argv); | |
127 | } | |
128 | ||
129 | if (iResult>=0) { | |
130 | // implement the component initialization | |
131 | if (!fArgument1) { | |
132 | HLTError("mandatory argument \'-mandatory1\' missing"); | |
133 | iResult=-EPROTO; | |
134 | } | |
135 | if (!fArgument2) { | |
136 | HLTError("mandatory argument \'-mandatory2\' missing"); | |
137 | iResult=-EPROTO; | |
138 | } | |
139 | } | |
140 | ||
141 | if (iResult<0) { | |
142 | // implement cleanup | |
143 | } | |
144 | ||
145 | return iResult; | |
146 | } | |
147 | ||
148 | int AliHLTSampleComponent1::ScanConfigurationArgument( int argc, const char** argv ) | |
149 | { | |
150 | // see header file for class documentation | |
5045badf | 151 | TString argument=""; |
152 | TString configuration=""; | |
289c6c1a | 153 | int i=0; |
5045badf | 154 | argument=argv[i]; |
289c6c1a | 155 | if (argument.IsNull()) return 0; |
5045badf | 156 | |
157 | // -mandatory1 | |
158 | if (argument.CompareTo("-mandatory1")==0) { | |
289c6c1a | 159 | if (++i>=argc) return -EPROTO; |
5045badf | 160 | HLTInfo("got \'-mandatory1\' argument: %s", argv[i]); |
289c6c1a | 161 | fArgument1=1; |
5045badf | 162 | |
163 | // -mandatory2 | |
164 | } else if (argument.CompareTo("-mandatory2")==0) { | |
289c6c1a | 165 | fArgument2=1; |
5045badf | 166 | HLTInfo("got \'-mandatory2\' argument"); |
167 | ||
289c6c1a | 168 | // -config1 |
169 | } else if (argument.CompareTo("-config1")==0) { | |
170 | if (++i>=argc) return -EPROTO; | |
171 | HLTInfo("got \'%s\' argument: %s", argument.Data(), argv[i]); | |
5045badf | 172 | |
289c6c1a | 173 | // -config2 |
174 | } else if (argument.CompareTo("-config2")==0) { | |
175 | HLTInfo("got \'%s\' argument", argument.Data()); | |
5045badf | 176 | |
177 | } else { | |
289c6c1a | 178 | // no recognized argument |
179 | i--; | |
5045badf | 180 | } |
5045badf | 181 | |
289c6c1a | 182 | return i+1; |
c5318542 | 183 | } |
184 | ||
5045badf | 185 | int AliHLTSampleComponent1::DoDeinit() |
186 | { | |
f644d3f1 | 187 | // see header file for class documentation |
5045badf | 188 | HLTInfo("processing cleanup"); |
c5318542 | 189 | return 0; |
190 | } | |
191 | ||
8ede8717 | 192 | int AliHLTSampleComponent1::DoEvent( const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks, |
193 | AliHLTComponentTriggerData& trigData, AliHLTUInt8_t* outputPtr, | |
194 | AliHLTUInt32_t& size, vector<AliHLTComponentBlockData>& outputBlocks ) { | |
f644d3f1 | 195 | // see header file for class documentation |
5045badf | 196 | HLTInfo("processing data"); |
f644d3f1 | 197 | if (evtData.fStructSize==0 && blocks==NULL && trigData.fStructSize==0 && |
198 | outputPtr==0 && size==0) | |
199 | { | |
200 | outputBlocks.clear(); | |
201 | // this is just to get rid of the warning "unused parameter" | |
202 | } | |
c5318542 | 203 | return 0; |
204 | } | |
5045badf | 205 | int AliHLTSampleComponent1::Reconfigure(const char* cdbEntry, const char* chainId) |
206 | { | |
207 | // see header file for class documentation | |
208 | int iResult=0; | |
209 | const char* path="HLT/ConfigSample/SampleComponent1"; | |
210 | const char* defaultNotify=""; | |
211 | if (cdbEntry) { | |
212 | path=cdbEntry; | |
213 | defaultNotify=" (default)"; | |
214 | } | |
289c6c1a | 215 | |
216 | HLTInfo("reconfigure from entry %s%s, chain id %s", path, defaultNotify,(chainId!=NULL && chainId[0]!=0)?chainId:"<none>"); | |
217 | iResult=ConfigureFromCDBTObjString(path); | |
218 | ||
5045badf | 219 | return iResult; |
220 | } | |
b543e186 | 221 | |
222 | int AliHLTSampleComponent1::ReadPreprocessorValues(const char* modules) | |
223 | { | |
224 | // see header file for class documentation | |
225 | int iResult=0; | |
226 | TString detectors(modules!=NULL?modules:""); | |
227 | HLTInfo("read preprocessor values for detector(s): %s", detectors.IsNull()?"none":detectors.Data()); | |
228 | return iResult; | |
229 | } |