]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/SampleLib/AliHLTSampleComponent1.cxx
minor coding rule corrections, removed deprecated class
[u/mrichter/AliRoot.git] / HLT / SampleLib / AliHLTSampleComponent1.cxx
1 // $Id$
2
3 //**************************************************************************
4 //* This file is property of and copyright by the                          * 
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. 
26
27 #include "AliHLTSampleComponent1.h"
28 #include "TString.h"
29 #include "TObjString.h"
30 #include "TMap.h"
31
32 using namespace std;
33
34 /** ROOT macro for the implementation of ROOT specific class methods */
35 ClassImp(AliHLTSampleComponent1)
36
37 AliHLTSampleComponent1::AliHLTSampleComponent1()
38   : AliHLTProcessor()
39   , fArgument1(0)
40   , fArgument2(0)
41 {
42   // an example component which implements the ALICE HLT processor
43   // interface and illustrates the basic interface methods
44   //
45   //
46   // NOTE: all helper classes should be instantiated in DoInit()
47 }
48
49 AliHLTSampleComponent1::~AliHLTSampleComponent1()
50 {
51   // destructor
52   //
53   // NOTE: implement proper cleanup in DoDeinit()
54 }
55
56 const char* AliHLTSampleComponent1::GetComponentID()
57
58   // component property: id
59   return "Sample-component1";
60 }
61
62 void AliHLTSampleComponent1::GetInputDataTypes( vector<AliHLTComponentDataType>& list)
63 {
64   // component property: list of input data types
65     list.push_back(kAliHLTAnyDataType);
66 }
67
68 AliHLTComponentDataType AliHLTSampleComponent1::GetOutputDataType()
69 {
70   // component property: output data type
71   return kAliHLTVoidDataType;
72 }
73
74 void AliHLTSampleComponent1::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier )
75 {
76   // component property: output size estimator
77   constBase = 0;
78   inputMultiplier = 0;
79 }
80
81 void AliHLTSampleComponent1::GetOCDBObjectDescription( TMap* const targetMap)
82 {
83   // Get a list of OCDB object description.
84   // The list of objects is provided in a TMap
85   // - key: complete OCDB path, e.g. GRP/GRP/Data
86   // - value: short description why the object is needed
87   // Key and value objects created inside this class go into ownership of
88   // target TMap.
89   if (!targetMap) return;
90   targetMap->Add(new TObjString("HLT/ConfigSample/SampleComponent1"),
91                  new TObjString("configuration object"));
92 }
93
94 AliHLTComponent* AliHLTSampleComponent1::Spawn()
95 {
96   // Spawn function, return new class instance
97   return new AliHLTSampleComponent1;
98 }
99
100 int AliHLTSampleComponent1::DoInit( int argc, const char** argv )
101 {
102   // see header file for class documentation
103   int iResult=0;
104
105   // init stage 1: default values for all data members
106   fArgument1=0;
107   fArgument2=0;
108
109   // init stage 2: read configuration object
110   // ScanConfigurationArgument() needs to be implemented
111   TString cdbPath="HLT/ConfigSample/SampleComponent1";
112   iResult=ConfigureFromCDBTObjString(cdbPath);
113
114   // init stage 3: read the component arguments
115   if (iResult>=0) {
116     iResult=ConfigureFromArgumentString(argc, argv);
117   }
118
119   if (iResult>=0) {
120     // implement the component initialization
121     if (!fArgument1) {
122       HLTError("mandatory argument \'-mandatory1\' missing");
123       iResult=-EPROTO;
124     }
125     if (!fArgument2) {
126       HLTError("mandatory argument \'-mandatory2\' missing");
127       iResult=-EPROTO;
128     }
129   }
130
131   if (iResult<0) {
132     // implement cleanup
133   }
134
135   return iResult;
136 }
137
138 int AliHLTSampleComponent1::ScanConfigurationArgument( int argc, const char** argv )
139 {
140   // see header file for class documentation
141   TString argument="";
142   TString configuration=""; 
143   int i=0;
144     argument=argv[i];
145     if (argument.IsNull()) return 0;
146
147     // -mandatory1
148     if (argument.CompareTo("-mandatory1")==0) {
149       if (++i>=argc) return -EPROTO;
150       HLTInfo("got \'-mandatory1\' argument: %s", argv[i]);
151       fArgument1=1;
152
153       // -mandatory2
154     } else if (argument.CompareTo("-mandatory2")==0) {
155       fArgument2=1;
156       HLTInfo("got \'-mandatory2\' argument");
157
158       // -config1
159     } else if (argument.CompareTo("-config1")==0) {
160       if (++i>=argc) return -EPROTO;
161       HLTInfo("got \'%s\' argument: %s", argument.Data(), argv[i]);
162
163       // -config2
164     } else if (argument.CompareTo("-config2")==0) {
165       HLTInfo("got \'%s\' argument", argument.Data());
166
167     } else {
168       // no recognized argument
169       i--;
170     }
171
172   return i+1;
173 }
174
175 int AliHLTSampleComponent1::DoDeinit()
176 {
177   // see header file for class documentation
178   HLTInfo("processing cleanup");
179   return 0;
180 }
181
182 int AliHLTSampleComponent1::DoEvent( const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks, 
183                                       AliHLTComponentTriggerData& trigData, AliHLTUInt8_t* outputPtr, 
184                                       AliHLTUInt32_t& size, AliHLTComponentBlockDataList& outputBlocks ) {
185   // see header file for class documentation
186   HLTInfo("processing data");
187   if (evtData.fStructSize==0 && blocks==NULL && trigData.fStructSize==0 &&
188       outputPtr==0 && size==0)
189   {
190     outputBlocks.clear();
191     // this is just to get rid of the warning "unused parameter"
192   }
193   return 0;
194 }
195 int AliHLTSampleComponent1::Reconfigure(const char* cdbEntry, const char* chainId)
196 {
197   // see header file for class documentation
198   int iResult=0;
199   const char* path="HLT/ConfigSample/SampleComponent1";
200   const char* defaultNotify="";
201   if (cdbEntry) {
202     path=cdbEntry;
203     defaultNotify=" (default)";
204   }
205
206   HLTInfo("reconfigure from entry %s%s, chain id %s", path, defaultNotify,(chainId!=NULL && chainId[0]!=0)?chainId:"<none>");
207   iResult=ConfigureFromCDBTObjString(path);
208
209   return iResult;
210 }
211
212 int AliHLTSampleComponent1::ReadPreprocessorValues(const char* modules)
213 {
214   // see header file for class documentation
215   int iResult=0;
216   TString detectors(modules!=NULL?modules:"");
217   HLTInfo("read preprocessor values for detector(s): %s", detectors.IsNull()?"none":detectors.Data());
218   return iResult;
219 }