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 (nofInstances==0) delete this;
91 int AliHLTConfigurationHandler::RegisterConfiguration(AliHLTConfiguration* pConf)
93 // see header file for function documentation
96 AliHLTConfiguration* pExisting=NULL;
97 if ((pExisting=FindConfiguration(pConf->GetName())) == NULL) {
98 AliHLTConfiguration* pClone=new AliHLTConfiguration(*pConf);
99 fgListConfigurations.Add(pClone);
100 HLTDebug("configuration \"%s\" (%p) registered from %p", pClone->GetName(), pClone, pConf);
102 // mark all configurations with unresolved dependencies for re-evaluation
103 TObjLink* lnk=fgListConfigurations.FirstLink();
105 AliHLTConfiguration* pSrc=(AliHLTConfiguration*)lnk->GetObject();
106 if (pSrc && pSrc!=pClone && pSrc->SourcesResolved()!=1) {
107 pSrc->InvalidateSources();
112 if ((*pExisting)!=(*pConf)) {
114 HLTWarning("configuration \"%s\" already registered with different properties", pConf->GetName());
123 int AliHLTConfigurationHandler::CreateConfiguration(const char* id, const char* component, const char* sources, const char* arguments)
125 // see header file for function documentation
127 AliHLTConfiguration* pConf= new AliHLTConfiguration(id, component, sources, arguments);
129 // the configuration will be registered automatically, if this failes the configuration
130 // is missing -> delete it
131 if (FindConfiguration(id)==NULL) {
137 HLTError("system error: object allocation failed");
143 void AliHLTConfigurationHandler::PrintConfigurations()
145 // see header file for function documentation
146 HLTLogKeyword("configuration listing");
147 HLTMessage("registered configurations:");
148 TObjLink *lnk = fgListConfigurations.FirstLink();
150 TObject *obj = lnk->GetObject();
151 HLTMessage(" %s", obj->GetName());
156 int AliHLTConfigurationHandler::RemoveConfiguration(const char* id)
158 // see header file for function documentation
161 AliHLTConfiguration* pConf=NULL;
162 if ((pConf=FindConfiguration(id))!=NULL) {
163 iResult=RemoveConfiguration(pConf);
167 HLTWarning("can not find configuration \"%s\"", id);
176 int AliHLTConfigurationHandler::RemoveConfiguration(AliHLTConfiguration* pConf)
178 // see header file for function documentation
181 // remove the configuration from the list
182 HLTDebug("remove configuration \"%s\"", pConf->GetName());
183 fgListConfigurations.Remove(pConf);
184 // remove cross links in the remaining configurations
185 TObjLink* lnk=fgListConfigurations.FirstLink();
186 while (lnk && iResult>=0) {
187 AliHLTConfiguration* pRem=(AliHLTConfiguration*)lnk->GetObject();
189 pRem->InvalidateSource(pConf);
199 AliHLTConfiguration* AliHLTConfigurationHandler::FindConfiguration(const char* id)
201 // see header file for function documentation
202 AliHLTConfiguration* pConf=NULL;
204 pConf=(AliHLTConfiguration*)fgListConfigurations.FindObject(id);