]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/shuttle/AliHLTPreprocessor.cxx
moved AliHLTModulePreprocessor to base library and introduced abstract interface...
[u/mrichter/AliRoot.git] / HLT / shuttle / AliHLTPreprocessor.cxx
1 // $Id: AliHLTPreprocessor.cxx 23039 2007-12-13 20:53:02Z richterm $
2
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 //*                  for The ALICE HLT 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
19 /**
20  * @file   AliHLTPreprocessor.cxx
21  * @author Matthias Richter
22  * @date   2008-01-22
23  * @brief  Container for HLT module preprocessors, acts to the outside as
24  *         HLT preprocessor used by the Offline Shuttle 
25  */
26
27 #include "AliHLTPreprocessor.h"
28 #include "AliHLTModulePreprocessor.h"
29 #include "AliHLTSystem.h"
30 #include "AliHLTModuleAgent.h"
31 #include "TSystem.h"
32
33 ClassImp(AliHLTPreprocessor)
34
35 AliHLTPreprocessor::AliHLTPreprocessor(AliShuttleInterface* shuttle) 
36   :
37   AliPreprocessor(fgkHLTPreproc, shuttle),
38   fProcessors()
39 {
40   // see header file for class documentation
41   // or
42   // refer to README to build package
43   // or
44   // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
45
46   fProcessors.SetOwner();
47 }
48
49 const char* AliHLTPreprocessor::fgkHLTPreproc = "HLT";
50
51 /** HLT default component libraries */
52 const char* AliHLTPreprocessor::fgkHLTDefaultShuttleLibs[]= {
53   "libAliHLTUtil.so", 
54   "libAliHLTTPC.so", 
55   "libAliHLTComp.so", 
56   "libAliHLTSample.so",
57   //"libAliHLTPHOS.so",
58   //"libAliHLTMUON.so",
59   "libAliHLTTRD.so",
60   NULL
61 };
62
63 AliHLTPreprocessor::~AliHLTPreprocessor()
64 {
65   // see header file for function documentation
66 }
67
68 void AliHLTPreprocessor::Initialize(Int_t run, UInt_t startTime, 
69                         UInt_t endTime) 
70 {
71   // see header file for function documentation
72   fRun = run;
73   fStartTime = startTime;
74   fEndTime = endTime;
75
76 //   TString msg("Preprocessor for HLT initialized for run: ");
77 //   msg += run;
78 //   Log(msg.Data());
79
80   // load component libraries
81   TString libs;
82   const char** deflib=fgkHLTDefaultShuttleLibs;
83   while (*deflib) {
84     if (gSystem->Load(*deflib)==0) {
85       Log(Form("HLT component library %s loaded", *deflib));
86     }
87   }
88
89   AliHLTModuleAgent* pAgent=AliHLTModuleAgent::GetFirstAgent();
90   while (pAgent) {
91     AliHLTModulePreprocessor* pProc=pAgent->GetPreprocessor();
92     if (pProc) {
93       pProc->SetShuttleInterface(this);
94       pProc->Initialize(run, startTime, endTime);
95       fProcessors.Add(pProc);
96       TString msg;
97       msg.Form("added preprocessor %p for module %p", pProc, pAgent);
98       Log(msg.Data());
99     }
100   }
101 }
102
103 UInt_t AliHLTPreprocessor::Process(TMap* dcsAliasMap)
104 {
105   // see header file for function documentation
106   UInt_t retVal = 0;
107
108   if (!GetHLTStatus()) {
109     return 0;
110   }
111
112   bool bAllFailed=true;
113   TObjLink *lnk = NULL;
114   lnk=fProcessors.FirstLink();
115   while (lnk) {
116     AliHLTModulePreprocessor* pProc=dynamic_cast<AliHLTModulePreprocessor*>(lnk->GetObject());
117     if (pProc) {
118       UInt_t result=pProc->Process(dcsAliasMap);
119       if (result) {
120         TString msg;
121         msg.Form("preprocessor for module %s failed with error code %d", pProc->GetName(), result);
122         Log(msg.Data());
123       } else {
124         bAllFailed=false;
125       }
126     }
127     lnk = lnk->Next();
128   }
129
130   if (bAllFailed) return 1;
131   return retVal;
132 }
133
134
135 Bool_t AliHLTPreprocessor::ProcessDCS()
136 {
137   // see header file for function documentation
138   return kFALSE;
139 }