2 // splitted from AliHLTConfiguration.cxx,v 1.25 2007/10/12 13:24:47
3 /**************************************************************************
4 * This file is property of and copyright by the ALICE HLT Project *
5 * ALICE Experiment at CERN, All rights reserved. *
7 * Primary Authors: Matthias Richter <Matthias.Richter@ift.uib.no> *
8 * for The ALICE HLT Project. *
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 **************************************************************************/
19 /** @file AliHLTConfigurationHandler.cxx
20 @author Matthias Richter
22 @brief Implementation of HLT tasks.
25 // see header file for class documentation
27 // refer to README to build package
29 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
38 #include "AliHLTConfigurationHandler.h"
39 #include "AliHLTConfiguration.h"
41 /** ROOT macro for the implementation of ROOT specific class methods */
42 ClassImp(AliHLTConfigurationHandler)
44 AliHLTConfigurationHandler::AliHLTConfigurationHandler()
46 fgListConfigurations()
48 // see header file for class documentation
50 // refer to README to build package
52 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
53 SetLocalLoggingLevel(kHLTLogInfo);
56 AliHLTConfigurationHandler::~AliHLTConfigurationHandler()
58 // see header file for function documentation
60 while ((lnk=fgListConfigurations.FirstLink())!=NULL) {
61 AliHLTConfiguration* pConf=(AliHLTConfiguration*)lnk->GetObject();
62 HLTDebug("delete configuration \"%s\"", pConf->GetName());
63 fgListConfigurations.Remove(lnk);
68 AliHLTConfigurationHandler* AliHLTConfigurationHandler::fgpInstance=NULL;
69 int AliHLTConfigurationHandler::fgNofInstances=0;
71 AliHLTConfigurationHandler* AliHLTConfigurationHandler::CreateHandler()
73 // see header file for class documentation
74 if (!fgpInstance) fgpInstance=new AliHLTConfigurationHandler;
79 int AliHLTConfigurationHandler::Destroy()
81 // see header file for class documentation
83 if (fgpInstance==this) {
84 nofInstances=fgNofInstances--;
86 if (fgNofInstances==0) {
94 int AliHLTConfigurationHandler::RegisterConfiguration(AliHLTConfiguration* pConf)
96 // see header file for function documentation
99 AliHLTConfiguration* pExisting=NULL;
100 if ((pExisting=FindConfiguration(pConf->GetName())) == NULL) {
101 AliHLTConfiguration* pClone=new AliHLTConfiguration(*pConf);
102 fgListConfigurations.Add(pClone);
103 HLTDebug("configuration \"%s\" (%p) registered from %p", pClone->GetName(), pClone, pConf);
105 // mark all configurations with unresolved dependencies for re-evaluation
106 TObjLink* lnk=fgListConfigurations.FirstLink();
108 AliHLTConfiguration* pSrc=(AliHLTConfiguration*)lnk->GetObject();
109 if (pSrc && pSrc!=pClone && pSrc->SourcesResolved()!=1) {
110 pSrc->InvalidateSources();
115 if ((*pExisting)!=(*pConf)) {
117 HLTWarning("configuration \"%s\" already registered with different properties", pConf->GetName());
126 int AliHLTConfigurationHandler::CreateConfiguration(const char* id, const char* component, const char* sources, const char* arguments)
128 // see header file for function documentation
130 AliHLTConfiguration* pConf= new AliHLTConfiguration(id, component, sources, arguments);
132 // the configuration will be registered automatically, if this failes the configuration
133 // is missing -> delete it
134 if (FindConfiguration(id)==NULL) {
140 HLTError("system error: object allocation failed");
146 void AliHLTConfigurationHandler::PrintConfigurations()
148 // see header file for function documentation
149 HLTLogKeyword("configuration listing");
150 HLTMessage("registered configurations:");
151 TObjLink *lnk = fgListConfigurations.FirstLink();
153 TObject *obj = lnk->GetObject();
154 HLTMessage(" %s", obj->GetName());
159 int AliHLTConfigurationHandler::RemoveConfiguration(const char* id)
161 // see header file for function documentation
164 AliHLTConfiguration* pConf=NULL;
165 if ((pConf=FindConfiguration(id))!=NULL) {
166 iResult=RemoveConfiguration(pConf);
170 HLTWarning("can not find configuration \"%s\"", id);
179 int AliHLTConfigurationHandler::RemoveConfiguration(AliHLTConfiguration* pConf)
181 // see header file for function documentation
184 // remove the configuration from the list
185 HLTDebug("remove configuration \"%s\"", pConf->GetName());
186 fgListConfigurations.Remove(pConf);
187 // remove cross links in the remaining configurations
188 TObjLink* lnk=fgListConfigurations.FirstLink();
189 while (lnk && iResult>=0) {
190 AliHLTConfiguration* pRem=(AliHLTConfiguration*)lnk->GetObject();
192 pRem->InvalidateSource(pConf);
202 AliHLTConfiguration* AliHLTConfigurationHandler::FindConfiguration(const char* id)
204 // see header file for function documentation
205 AliHLTConfiguration* pConf=NULL;
207 pConf=(AliHLTConfiguration*)fgListConfigurations.FindObject(id);