3 /**************************************************************************
4 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
6 * Authors: Matthias Richter <Matthias.Richter@ift.uib.no> *
7 * Timm Steinbeck <timm@kip.uni-heidelberg.de> *
8 * Artur Szostak <artursz@iafrica.com> *
9 * for The ALICE Off-line Project. *
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 **************************************************************************/
20 ///////////////////////////////////////////////////////////////////////////////
22 // global HLT module management //
24 ///////////////////////////////////////////////////////////////////////////////
32 #include "AliL3StandardIncludes.h"
33 #include "AliHLTSystem.h"
34 #include "AliHLTComponentHandler.h"
35 #include "AliHLTComponent.h"
36 #include "AliHLTConfiguration.h"
38 ClassImp(AliHLTSystem)
40 AliHLTSystem::AliHLTSystem()
42 fpComponentHandler=new AliHLTComponentHandler();
43 if (fpComponentHandler) {
44 AliHLTComponentEnvironment env;
45 memset(&env, 0, sizeof(AliHLTComponentEnvironment));
46 env.fLoggingFunc=AliHLTLogging::Message;
47 fpComponentHandler->SetEnvironment(&env);
49 // init logging function in AliHLTLogging
50 Init(AliHLTLogging::Message);
52 DebugMsg("create hlt object %s %p", "AliHLTSystem", this);
57 AliHLTSystem::~AliHLTSystem()
61 int AliHLTSystem::AddConfiguration(AliHLTConfiguration* pConf)
67 // int AliHLTSystem::InsertConfiguration(AliHLTConfiguration* pConf, AliHLTConfiguration* pPrec)
73 int AliHLTSystem::DeleteConfiguration(AliHLTConfiguration* pConf)
79 int AliHLTSystem::BuildTaskList(AliHLTConfiguration* pConf)
83 AliHLTTask* pTask=NULL;
84 if ((pTask=FindTask(pConf->GetName()))!=NULL) {
85 if (pTask->GetConf()!=pConf) {
86 Logging(kHLTLogError, "BASE", "AliHLTSystem", "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);
90 } else if (pConf->SourcesResolved(1)!=1) {
91 Logging(kHLTLogError, "BASE", "AliHLTSystem", "configuration \"%s\" has unresolved sources, aborting ...", pConf->GetName());
94 pTask=new AliHLTTask(pConf, NULL);
100 // check for ring dependencies
101 if ((iResult=pConf->FollowDependency(pConf->GetName()))>0) {
102 Logging(kHLTLogError, "BASE", "AliHLTSystem", "detected ring dependency for configuration \"%s\"", pTask->GetName());
103 pTask->PrintDependencyTree(pTask->GetName(), 1/*use the configuration list*/);
104 Logging(kHLTLogError, "BASE", "AliHLTSystem", "aborted ...");
108 // check whether all dependencies are already in the task list
109 // create the missing ones
110 fTaskList.Add(pTask);
111 AliHLTConfiguration* pDep=pConf->GetFirstSource();
112 while (pDep!=NULL && iResult>=0) {
113 if (FindTask(pDep->GetName())==NULL) {
114 iResult=BuildTaskList(pDep);
116 pDep=pConf->GetNextSource();
118 fTaskList.Remove(pTask);
120 // insert the task and set the cross-links
122 iResult=InsertTask(pTask);
135 int AliHLTSystem::CleanTaskList()
139 while ((lnk=fTaskList.FirstLink())!=NULL) {
140 fTaskList.Remove(lnk);
141 delete (lnk->GetObject());
146 int AliHLTSystem::InsertTask(AliHLTTask* pTask)
149 TObjLink *lnk = NULL;
150 if ((iResult=pTask->CheckDependencies())>0)
151 lnk=fTaskList.FirstLink();
152 while (lnk && iResult>0) {
153 AliHLTTask* pCurr = (AliHLTTask*)lnk->GetObject();
154 //Logging(kHLTLogDebug, "BASE", "AliHLTSystem", "checking \"%s\"", pCurr->GetName());
155 iResult=pTask->Depends(pCurr);
157 iResult=pTask->SetDependency(pCurr);
158 pCurr->SetTarget(pTask);
159 Logging(kHLTLogDebug, "BASE", "AliHLTSystem", "set dependency \"%s\" for configuration \"%s\"", pCurr->GetName(), pTask->GetName());
161 if (pCurr->Depends(pTask)) {
163 Logging(kHLTLogError, "BASE", "AliHLTSystem", "ring dependency: can not resolve dependencies for configuration \"%s\"", pTask->GetName());
165 } else if ((iResult=pTask->CheckDependencies())>0) {
171 fTaskList.AddAfter(lnk, pTask);
173 fTaskList.AddFirst(pTask);
175 Logging(kHLTLogDebug, "BASE", "AliHLTSystem", "task \"%s\" inserted", pTask->GetName());
176 } else if (iResult>0) {
177 Logging(kHLTLogError, "BASE", "AliHLTSystem", "can not resolve dependencies for configuration \"%s\" (%d unresolved)", pTask->GetName(), iResult);
183 AliHLTTask* AliHLTSystem::FindTask(const char* id)
185 AliHLTTask* pTask=NULL;
187 pTask=(AliHLTTask*)fTaskList.FindObject(id);
192 void AliHLTSystem::PrintTaskList()
194 TObjLink *lnk = NULL;
195 Logging(kHLTLogInfo, "BASE", "AliHLTSystem", "Task List");
196 lnk=fTaskList.FirstLink();
198 TObject* obj=lnk->GetObject();
200 Logging(kHLTLogInfo, "BASE", "AliHLTSystem", " %s - status:", obj->GetName());
201 AliHLTTask* pTask=(AliHLTTask*)obj;
202 pTask->PrintStatus();