]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/BASE/AliHLTSystem.cxx
- Changed module names to be the same as the libraries names;
[u/mrichter/AliRoot.git] / HLT / BASE / AliHLTSystem.cxx
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  *          for The ALICE Off-line Project.                               *
8  *                                                                        *
9  * Permission to use, copy, modify and distribute this software and its   *
10  * documentation strictly for non-commercial purposes is hereby granted   *
11  * without fee, provided that the above copyright notice appears in all   *
12  * copies and that both the copyright notice and this permission notice   *
13  * appear in the supporting documentation. The authors make no claims     *
14  * about the suitability of this software for any purpose. It is          *
15  * provided "as is" without express or implied warranty.                  *
16  **************************************************************************/
17
18 /** @file   AliHLTSystem.cxx
19     @author Matthias Richter
20     @date   
21     @brief  Implementation of HLT module management.
22 */
23
24 #if __GNUC__>= 3
25 using namespace std;
26 #endif
27
28 #include "AliHLTStdIncludes.h"
29 #include "AliHLTSystem.h"
30 #include "AliHLTComponentHandler.h"
31 #include "AliHLTComponent.h"
32 #include "AliHLTConfiguration.h"
33 #include "AliHLTConfigurationHandler.h"
34 #include "AliHLTTask.h"
35 #include "AliHLTModuleAgent.h"
36 #include "AliHLTOfflineInterface.h"
37 #include <TObjArray.h>
38 #include <TObjString.h>
39 #include <TString.h>
40 #include <TStopwatch.h>
41
42 /** ROOT macro for the implementation of ROOT specific class methods */
43 ClassImp(AliHLTSystem)
44
45 AliHLTSystem::AliHLTSystem()
46   :
47   fpComponentHandler(new AliHLTComponentHandler()),
48   fpConfigurationHandler(new AliHLTConfigurationHandler()),
49   fTaskList(),
50   fState(0)
51 {
52   // see header file for class documentation
53   // or
54   // refer to README to build package
55   // or
56   // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
57
58   if (fgNofInstances++>0)
59     HLTWarning("multiple instances of AliHLTSystem, you should not use more than one at a time");
60
61   SetGlobalLoggingLevel(kHLTLogDefault);
62   if (fpComponentHandler) {
63     AliHLTComponentEnvironment env;
64     memset(&env, 0, sizeof(AliHLTComponentEnvironment));
65     env.fAllocMemoryFunc=AliHLTSystem::AllocMemory;
66     env.fLoggingFunc=NULL;
67     AliHLTComponentLogSeverity loglevel=fpComponentHandler->GetLocalLoggingLevel();
68     fpComponentHandler->SetLocalLoggingLevel(kHLTLogError);
69     fpComponentHandler->SetEnvironment(&env);
70     fpComponentHandler->LoadLibrary("libAliHLTUtil.so");
71     fgAliLoggingFunc=(AliHLTLogging::AliHLTDynamicMessage)fpComponentHandler->FindSymbol("libAliHLTUtil.so", "AliDynamicMessage");
72     fpComponentHandler->SetLocalLoggingLevel(loglevel);
73     if (fgAliLoggingFunc==NULL) {
74       HLTError("symbol lookp failure: can not find AliDynamicMessage, switching to HLT logging system");
75     }
76     fpComponentHandler->AnnounceVersion();
77   } else {
78     HLTFatal("can not create Component Handler");
79   }
80   if (fpConfigurationHandler) {
81     AliHLTConfiguration::GlobalInit(fpConfigurationHandler);
82   } else {
83     HLTFatal("can not create Configuration Handler");
84   }
85 }
86
87 AliHLTSystem::AliHLTSystem(const AliHLTSystem&)
88   :
89   AliHLTLogging(),
90   fpComponentHandler(NULL),
91   fpConfigurationHandler(NULL),
92   fTaskList(),
93   fState(0)
94 {
95   // see header file for class documentation
96   if (fgNofInstances++>0)
97     HLTWarning("multiple instances of AliHLTSystem, you should not use more than one at a time");
98
99   HLTFatal("copy constructor untested");
100 }
101
102 AliHLTSystem& AliHLTSystem::operator=(const AliHLTSystem&)
103
104   // see header file for class documentation
105   HLTFatal("assignment operator untested");
106   return *this;
107 }
108
109 AliHLTSystem::~AliHLTSystem()
110 {
111   // see header file for class documentation
112   fgNofInstances--;
113   CleanTaskList();
114   AliHLTConfiguration::GlobalDeinit(fpConfigurationHandler);
115   if (fpConfigurationHandler) {
116     delete fpConfigurationHandler;
117   }
118   fpConfigurationHandler=NULL;
119   
120   if (fpComponentHandler) {
121     delete fpComponentHandler;
122   }
123   fpComponentHandler=NULL;
124 }
125
126 int AliHLTSystem::fgNofInstances=0;
127
128 int AliHLTSystem::AddConfiguration(AliHLTConfiguration* pConf)
129 {
130   // see header file for class documentation
131   int iResult=0;
132   if (pConf) {
133   } else {
134     iResult=-EINVAL;
135   }
136   return iResult;
137 }
138
139 int AliHLTSystem::InsertConfiguration(AliHLTConfiguration* pConf, AliHLTConfiguration* pPrec)
140 {
141   // see header file for class documentation
142   int iResult=0;
143   if (pConf) {
144     if (pPrec) {
145       // find the position
146     }
147   } else {
148     iResult=-EINVAL;
149   }
150   return iResult;
151 }
152
153 int AliHLTSystem::DeleteConfiguration(AliHLTConfiguration* pConf)
154 {
155   // see header file for class documentation
156   int iResult=0;
157   if (pConf) {
158   } else {
159     iResult=-EINVAL;
160   }
161   return iResult;
162 }
163
164 int AliHLTSystem::BuildTaskList(const char* id)
165 {
166   // see header file for class documentation
167   int iResult=0;
168   if (id) {
169     if (fpConfigurationHandler) {
170       AliHLTConfiguration* pConf=fpConfigurationHandler->FindConfiguration(id);
171       if (pConf) {
172         iResult=BuildTaskList(pConf);
173       } else {
174         HLTError("unknown configuration \"%s\"", id);
175         iResult=-EEXIST;
176       }
177     } else {
178       iResult=-EFAULT;
179     }
180   } else {
181     iResult=-EINVAL;
182   }
183   return iResult;
184 }
185
186 int AliHLTSystem::BuildTaskList(AliHLTConfiguration* pConf)
187 {
188   // see header file for class documentation
189   int iResult=0;
190   if (pConf) {
191     AliHLTTask* pTask=NULL;
192     if ((pTask=FindTask(pConf->GetName()))!=NULL) {
193       if (pTask->GetConf()!=pConf) {
194         HLTError("configuration missmatch, there is already a task with configuration name \"%s\", but it is different. Most likely configuration %p is not registered properly", pConf->GetName(), pConf);
195         iResult=-EEXIST;
196         pTask=NULL;
197       }
198     } else if (pConf->SourcesResolved(1)!=1) {
199         HLTError("configuration \"%s\" has unresolved sources, aborting ...", pConf->GetName());
200         iResult=-ENOLINK;
201     } else {
202       pTask=new AliHLTTask(pConf);
203       if (pTask==NULL) {
204         iResult=-ENOMEM;
205       }
206     }
207     if (pTask) {
208       // check for circular dependencies
209       if ((iResult=pConf->FollowDependency(pConf->GetName()))>0) {
210         HLTError("detected circular dependency for configuration \"%s\"", pTask->GetName());
211         pTask->PrintDependencyTree(pTask->GetName(), 1/*use the configuration list*/);
212         HLTError("aborted ...");
213         iResult=-ELOOP;
214       }
215       if (iResult>=0) {
216         // check whether all dependencies are already in the task list
217         // create the missing ones
218         // this step is an iterative process which calls this function again for the missing
219         // configurations, in order to avoid the currently processed task to be created
220         // again it is added to the list temporarily and removed afterwards
221         // This is of high importance to preserve the order of the tasks. Furthermore, the
222         // InsertTask method has to be used in order to set all the cross links right 
223         fTaskList.Add(pTask);
224         AliHLTConfiguration* pDep=pConf->GetFirstSource();
225         while (pDep!=NULL && iResult>=0) {
226           if (FindTask(pDep->GetName())==NULL) {
227             iResult=BuildTaskList(pDep);
228           }
229           pDep=pConf->GetNextSource();
230         }
231         // remove the temporarily added task
232         fTaskList.Remove(pTask);
233
234         // insert the task and set the cross-links
235         if (iResult>=0) {
236           iResult=InsertTask(pTask);
237         }
238       } else {
239         delete pTask;
240         pTask=NULL;
241       }
242     }
243   } else {
244     iResult=-EINVAL;
245   }
246   return iResult;
247 }
248
249 int AliHLTSystem::CleanTaskList()
250 {
251   // see header file for class documentation
252   int iResult=0;
253   TObjLink* lnk=NULL;
254   while ((lnk=fTaskList.LastLink())!=NULL) {
255     delete (lnk->GetObject());
256     fTaskList.Remove(lnk);
257   }
258   return iResult;
259 }
260
261 int AliHLTSystem::InsertTask(AliHLTTask* pTask)
262 {
263   // see header file for class documentation
264   int iResult=0;
265   TObjLink *lnk = NULL;
266   if ((iResult=pTask->CheckDependencies())>0)
267     lnk=fTaskList.FirstLink();
268   while (lnk && iResult>0) {
269     AliHLTTask* pCurr = (AliHLTTask*)lnk->GetObject();
270     //HLTDebug("checking  \"%s\"", pCurr->GetName());
271     iResult=pTask->Depends(pCurr);
272     if (iResult>0) {
273       iResult=pTask->SetDependency(pCurr);
274       pCurr->SetTarget(pTask);
275       HLTDebug("set dependency  \"%s\" for configuration \"%s\"", pCurr->GetName(), pTask->GetName());
276     }
277     if (pCurr->Depends(pTask)) {
278       // circular dependency
279       HLTError("circular dependency: can not resolve dependencies for configuration \"%s\"", pTask->GetName());
280       iResult=-ELOOP;
281     } else if ((iResult=pTask->CheckDependencies())>0) {
282       lnk = lnk->Next();
283     }
284   }
285   if (iResult==0) {
286       if (lnk) {
287         fTaskList.AddAfter(lnk, pTask);
288       } else {
289         fTaskList.AddFirst(pTask);
290       }
291       HLTDebug("task \"%s\" (%p) inserted (size %d)", pTask->GetName(), pTask, sizeof(AliHLTTask));
292   } else if (iResult>0) {
293     HLTError("can not resolve dependencies for configuration \"%s\" (%d unresolved)", pTask->GetName(), iResult);
294     iResult=-ENOLINK;
295   }
296   return iResult;
297 }
298
299 AliHLTTask* AliHLTSystem::FindTask(const char* id)
300 {
301   // see header file for class documentation
302   AliHLTTask* pTask=NULL;
303   if (id) {
304     pTask=(AliHLTTask*)fTaskList.FindObject(id); 
305   }
306   return pTask;
307 }
308
309 void AliHLTSystem::PrintTaskList()
310 {
311   // see header file for class documentation
312   HLTLogKeyword("task list");
313   TObjLink *lnk = NULL;
314   HLTMessage("Task List");
315   lnk=fTaskList.FirstLink();
316   while (lnk) {
317     TObject* obj=lnk->GetObject();
318     if (obj) {
319       HLTMessage("  %s - status:", obj->GetName());
320       AliHLTTask* pTask=(AliHLTTask*)obj;
321       pTask->PrintStatus();
322     } else {
323     }
324     lnk = lnk->Next();
325   }
326 }
327
328 int AliHLTSystem::Run(Int_t iNofEvents) 
329 {
330   // see header file for class documentation
331   int iResult=0;
332   int iCount=0;
333   SetStatusFlags(kRunning);
334   TStopwatch StopwatchBase; StopwatchBase.Reset();
335   TStopwatch StopwatchDA; StopwatchDA.Reset();
336   TStopwatch StopwatchInput; StopwatchInput.Reset();
337   TStopwatch StopwatchOutput; StopwatchOutput.Reset();
338   TObjArray Stopwatches;
339   Stopwatches.AddAt(&StopwatchBase, (int)AliHLTComponent::kSWBase);
340   Stopwatches.AddAt(&StopwatchDA, (int)AliHLTComponent::kSWDA);
341   Stopwatches.AddAt(&StopwatchInput, (int)AliHLTComponent::kSWInput);
342   Stopwatches.AddAt(&StopwatchOutput, (int)AliHLTComponent::kSWOutput);
343   if ((iResult=InitTasks())>=0 && (iResult=InitBenchmarking(&Stopwatches))>=0) {
344     if ((iResult=StartTasks())>=0) {
345       for (int i=0; i<iNofEvents && iResult>=0; i++) {
346         iResult=ProcessTasks(i);
347         if (iResult>=0) {
348           HLTInfo("Event %d successfully finished (%d)", i, iResult);
349           iResult=0;
350           iCount++;
351         } else {
352           HLTError("Processing of event %d failed (%d)", i, iResult);
353           // TODO: define different running modes to either ignore errors in
354           // event processing or not
355           // currently ignored 
356           //iResult=0;
357         }
358       }
359       StopTasks();
360     } else {
361       HLTError("can not start task list");
362     }
363     DeinitTasks();
364   } else if (iResult!=-ENOENT) {
365     HLTError("can not initialize task list");
366   }
367   if (iResult>=0) {
368     iResult=iCount;
369     HLTInfo("HLT statistics:\n"
370             "    base:              R:%.3fs C:%.3fs\n"
371             "    input:             R:%.3fs C:%.3fs\n"
372             "    output:            R:%.3fs C:%.3fs\n"
373             "    event processing : R:%.3fs C:%.3fs"
374             , StopwatchBase.RealTime(),StopwatchBase.CpuTime()
375             , StopwatchInput.RealTime(),StopwatchInput.CpuTime()
376             , StopwatchOutput.RealTime(),StopwatchOutput.CpuTime()
377             , StopwatchDA.RealTime(),StopwatchDA.CpuTime());
378   }
379   ClearStatusFlags(kRunning);
380   return iResult;
381 }
382
383 int AliHLTSystem::InitTasks()
384 {
385   // see header file for class documentation
386   int iResult=0;
387   TObjLink *lnk=fTaskList.FirstLink();
388   if (lnk==NULL) {
389     HLTWarning("Task list is empty, aborting ...");
390     return -ENOENT;
391   }
392   while (lnk && iResult>=0) {
393     TObject* obj=lnk->GetObject();
394     if (obj) {
395       AliHLTTask* pTask=(AliHLTTask*)obj;
396       iResult=pTask->Init(NULL, fpComponentHandler);
397     } else {
398     }
399     lnk = lnk->Next();
400   }
401   if (iResult<0) {
402   }
403   return iResult;
404 }
405
406 int AliHLTSystem::InitBenchmarking(TObjArray* pStopwatches)
407 {
408   // see header file for class documentation
409   if (pStopwatches==NULL) return -EINVAL;
410
411   int iResult=0;
412   TObjLink *lnk=fTaskList.FirstLink();
413   while (lnk && iResult>=0) {
414     TObject* obj=lnk->GetObject();
415     if (obj) {
416       AliHLTTask* pTask=(AliHLTTask*)obj;
417       AliHLTComponent* pComp=NULL;
418       if (iResult>=0 && (pComp=pTask->GetComponent())!=NULL) {
419         switch (pComp->GetComponentType()) {
420         case AliHLTComponent::kProcessor:
421           pComp->SetStopwatches(pStopwatches);
422           break;
423         case AliHLTComponent::kSource:
424           {
425             // this switch determines whether the time consumption of the
426             // AliHLTComponent base methods should be counted to the input
427             // stopwatch or base stopwatch.
428             //int inputBase=(int)AliHLTComponent::kSWBase;
429             int inputBase=(int)AliHLTComponent::kSWInput;
430             pComp->SetStopwatch(pStopwatches->At(inputBase), AliHLTComponent::kSWBase);
431             pComp->SetStopwatch(pStopwatches->At((int)AliHLTComponent::kSWInput), AliHLTComponent::kSWDA);
432           }
433           break;
434         case AliHLTComponent::kSink:
435           {
436             // this switch determines whether the time consumption of the
437             // AliHLTComponent base methods should be counted to the output
438             // stopwatch or base stopwatch.
439             //int outputBase=(int)AliHLTComponent::kSWBase;
440             int outputBase=(int)AliHLTComponent::kSWOutput;
441             pComp->SetStopwatch(pStopwatches->At(outputBase), AliHLTComponent::kSWBase);
442             pComp->SetStopwatch(pStopwatches->At((int)AliHLTComponent::kSWOutput), AliHLTComponent::kSWDA);
443           }
444           break;
445         default:
446           HLTWarning("unknown component type %d", (int)pComp->GetComponentType());
447         }
448       }
449     } else {
450     }
451     lnk = lnk->Next();
452   }
453   return iResult;
454 }
455
456 int AliHLTSystem::StartTasks()
457 {
458   // see header file for class documentation
459   int iResult=0;
460   TObjLink *lnk=fTaskList.FirstLink();
461   while (lnk && iResult>=0) {
462     TObject* obj=lnk->GetObject();
463     if (obj) {
464       AliHLTTask* pTask=(AliHLTTask*)obj;
465       iResult=pTask->StartRun();
466     } else {
467     }
468     lnk = lnk->Next();
469   }
470   if (iResult<0) {
471   }
472   return iResult;
473 }
474
475 int AliHLTSystem::ProcessTasks(Int_t eventNo)
476 {
477   // see header file for class documentation
478   int iResult=0;
479   HLTDebug("processing event no %d", eventNo);
480   TObjLink *lnk=fTaskList.FirstLink();
481   while (lnk && iResult>=0) {
482     TObject* obj=lnk->GetObject();
483     if (obj) {
484       AliHLTTask* pTask=(AliHLTTask*)obj;
485       iResult=pTask->ProcessTask(eventNo);
486       HLTDebug("task %s finnished (%d)", pTask->GetName(), iResult);
487     } else {
488     }
489     lnk = lnk->Next();
490   }
491   return iResult;
492 }
493
494 int AliHLTSystem::StopTasks()
495 {
496   // see header file for class documentation
497   int iResult=0;
498   TObjLink *lnk=fTaskList.FirstLink();
499   while (lnk && iResult>=0) {
500     TObject* obj=lnk->GetObject();
501     if (obj) {
502       AliHLTTask* pTask=(AliHLTTask*)obj;
503       iResult=pTask->EndRun();
504     } else {
505     }
506     lnk = lnk->Next();
507   }
508   return iResult;
509 }
510
511 int AliHLTSystem::DeinitTasks()
512 {
513   // see header file for class documentation
514   int iResult=0;
515   TObjLink *lnk=fTaskList.FirstLink();
516   while (lnk && iResult>=0) {
517     TObject* obj=lnk->GetObject();
518     if (obj) {
519       AliHLTTask* pTask=(AliHLTTask*)obj;
520       iResult=pTask->Deinit();
521     } else {
522     }
523     lnk = lnk->Next();
524   }
525   return iResult;
526 }
527
528 void* AliHLTSystem::AllocMemory( void* param, unsigned long size )
529 {
530   // see header file for class documentation
531   if (param==NULL) {
532     // get rid of 'unused parameter' warning
533   }
534   return (void*)new char[size];
535 }
536
537 int AliHLTSystem::Reconstruct(int nofEvents, AliRunLoader* runLoader, 
538                               AliRawReader* rawReader)
539 {
540   // see header file for class documentation
541   int iResult=0;
542   if (runLoader) {
543     HLTInfo("Run Loader %p, Raw Reader %p , %d events", runLoader, rawReader, nofEvents);
544     if (CheckStatus(kReady)) {
545       if ((iResult=AliHLTOfflineInterface::SetParamsToComponents(runLoader, rawReader))>=0) {
546         iResult=Run(nofEvents);
547       }
548     } else {
549       HLTError("wrong state %#x, required flags %#x", GetStatusFlags(), kReady);
550     }
551   } else {
552     HLTError("missing run loader instance");
553     iResult=-EINVAL;
554   }
555   return iResult;
556 }
557
558 int AliHLTSystem::FillESD(int eventNo, AliRunLoader* runLoader, AliESD* esd)
559 {
560   // see header file for class documentation
561   int iResult=0;
562   if (runLoader) {
563     HLTInfo("Event %d: Run Loader %p, ESD %p", eventNo, runLoader, esd);
564     iResult=AliHLTOfflineInterface::FillComponentESDs(eventNo, runLoader, esd);
565   } else {
566     HLTError("missing run loader/ESD instance(s)");
567     iResult=-EINVAL;
568   }
569   return iResult;
570 }
571
572 int AliHLTSystem::LoadComponentLibraries(const char* libraries)
573 {
574   // see header file for class documentation
575   int iResult=0;
576   if (libraries) {
577     if (fpComponentHandler) {
578       TString libs(libraries);
579       TObjArray* pTokens=libs.Tokenize(" ");
580       if (pTokens) {
581         int iEntries=pTokens->GetEntries();
582         for (int i=0; i<iEntries && iResult>=0; i++) {
583           iResult=fpComponentHandler->LoadLibrary((((TObjString*)pTokens->At(i))->GetString()).Data());
584         }
585         delete pTokens;
586       }
587       if (iResult>=0) {
588         SetStatusFlags(kLibrariesLoaded);
589       } else {
590         // lets see if we need this, probably not
591         //fpComponentHandler->UnloadLibraries();
592         ClearStatusFlags(kLibrariesLoaded);
593       }
594     } else {
595       iResult=-EFAULT;
596       HLTFatal("no component handler available");
597     }
598   } else {
599     iResult=-EINVAL;
600   }
601   return iResult;
602 }
603
604 int AliHLTSystem::Configure(AliRunLoader* runloader)
605 {
606   // see header file for class documentation
607   int iResult=0;
608   if (CheckStatus(kRunning)) {
609     HLTError("HLT system in running state, can not configure");
610     return -EBUSY;
611   }
612   if (CheckFilter(kHLTLogDebug))
613     AliHLTModuleAgent::PrintStatus();
614   ClearStatusFlags(kConfigurationLoaded|kTaskListCreated);
615   iResult=LoadConfigurations(runloader);
616   if (iResult>=0) {
617     SetStatusFlags(kConfigurationLoaded);
618     iResult=BuildTaskListsFromTopConfigurations(runloader);
619     if (iResult>=0) {
620       SetStatusFlags(kTaskListCreated);
621     }
622   }
623   if (iResult<0) SetStatusFlags(kError);
624   
625   return iResult;
626 }
627
628 int AliHLTSystem::Reset(int bForce)
629 {
630   // see header file for class documentation
631   int iResult=0;
632   if (!bForce && CheckStatus(kRunning)) {
633     HLTError("HLT system in running state, can not configure");
634     return -EBUSY;
635   }
636   CleanTaskList();
637   ClearStatusFlags(~kUninitialized);
638   return iResult;
639 }
640
641 int AliHLTSystem::LoadConfigurations(AliRunLoader* runloader)
642 {
643   // see header file for class documentation
644   if (CheckStatus(kRunning)) {
645     HLTError("HLT system in running state, can not configure");
646     return -EBUSY;
647   }
648   int iResult=0;
649   AliHLTModuleAgent* pAgent=AliHLTModuleAgent::GetFirstAgent();
650   while (pAgent && iResult>=0) {
651     const char* deplibs=pAgent->GetRequiredComponentLibraries();
652     if (deplibs) {
653       HLTDebug("load libraries \'%s\' for agent %s (%p)", deplibs, pAgent->GetName(), pAgent);
654       iResult=LoadComponentLibraries(deplibs);
655     }
656     if (iResult>=0) {
657       HLTDebug("load configurations for agent %s (%p)", pAgent->GetName(), pAgent);
658       pAgent->CreateConfigurations(fpConfigurationHandler, runloader);
659       pAgent=AliHLTModuleAgent::GetNextAgent();
660     }
661   }
662   return iResult;
663 }
664
665 int AliHLTSystem::BuildTaskListsFromTopConfigurations(AliRunLoader* runloader)
666 {
667   // see header file for class documentation
668   if (CheckStatus(kRunning)) {
669     HLTError("HLT system in running state, can not configure");
670     return -EBUSY;
671   }
672   if (!CheckStatus(kConfigurationLoaded)) {
673     HLTWarning("configurations not yet loaded");
674     return 0;
675   }
676
677   int iResult=0;
678   AliHLTModuleAgent* pAgent=AliHLTModuleAgent::GetFirstAgent();
679   while (pAgent && iResult>=0) {
680     TString tops=pAgent->GetLocalRecConfigurations(runloader);
681     HLTDebug("top configurations for agent %s (%p): %s", pAgent->GetName(), pAgent, tops.Data());
682     TObjArray* pTokens=tops.Tokenize(" ");
683     if (pTokens) {
684       int iEntries=pTokens->GetEntries();
685       for (int i=0; i<iEntries && iResult>=0; i++) {
686         const char* pCID=((TObjString*)pTokens->At(i))->GetString().Data();
687         AliHLTConfiguration* pConf=fpConfigurationHandler->FindConfiguration(pCID);
688         if (pConf) {
689           iResult=BuildTaskList(pConf);
690         } else {
691           HLTWarning("can not find top configuration %s", pCID);
692         }
693       }
694       delete pTokens;
695     }
696     
697     pAgent=AliHLTModuleAgent::GetNextAgent();
698   }
699   if (iResult>=0) SetStatusFlags(kTaskListCreated);
700
701   return iResult;
702 }
703
704 int AliHLTSystem::CheckStatus(int flag)
705 {
706   // see header file for class documentation
707   if (flag==kUninitialized && flag==fState) return 1;
708   if ((fState&flag)==flag) return 1;
709   return 0;
710 }
711
712 int AliHLTSystem::GetStatusFlags()
713 {
714   // see header file for class documentation
715   return fState;
716 }
717
718 int AliHLTSystem::SetStatusFlags(int flags)
719 {
720   // see header file for class documentation
721   fState|=flags;
722   return fState;
723 }
724
725 int AliHLTSystem::ClearStatusFlags(int flags)
726 {
727   // see header file for class documentation
728   fState&=~flags;
729   return fState;
730 }
731
732 void* AliHLTSystem::FindDynamicSymbol(const char* library, const char* symbol)
733 {
734   if (fpComponentHandler==NULL) return NULL;
735   return fpComponentHandler->FindSymbol(library, symbol);
736 }