// $Id$ // splitted from AliHLTConfiguration.cxx,v 1.25 2007/10/12 13:24:47 /************************************************************************** * This file is property of and copyright by the ALICE HLT Project * * ALICE Experiment at CERN, All rights reserved. * * * * Primary Authors: Matthias Richter * * for The ALICE HLT Project. * * * * Permission to use, copy, modify and distribute this software and its * * documentation strictly for non-commercial purposes is hereby granted * * without fee, provided that the above copyright notice appears in all * * copies and that both the copyright notice and this permission notice * * appear in the supporting documentation. The authors make no claims * * about the suitability of this software for any purpose. It is * * provided "as is" without express or implied warranty. * **************************************************************************/ /** @file AliHLTConfigurationHandler.cxx @author Matthias Richter @date @brief Implementation of HLT tasks. */ // see header file for class documentation // or // refer to README to build package // or // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt #if __GNUC__>= 3 using namespace std; #endif #include #include #include #include "AliHLTConfigurationHandler.h" #include "AliHLTConfiguration.h" /** ROOT macro for the implementation of ROOT specific class methods */ ClassImp(AliHLTConfigurationHandler) AliHLTConfigurationHandler::AliHLTConfigurationHandler() : fgListConfigurations() { // see header file for class documentation // or // refer to README to build package // or // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt SetLocalLoggingLevel(kHLTLogInfo); } AliHLTConfigurationHandler::~AliHLTConfigurationHandler() { // see header file for function documentation TObjLink* lnk=NULL; while ((lnk=fgListConfigurations.FirstLink())!=NULL) { AliHLTConfiguration* pConf=(AliHLTConfiguration*)lnk->GetObject(); HLTDebug("delete configuration \"%s\"", pConf->GetName()); fgListConfigurations.Remove(lnk); delete pConf; } } int AliHLTConfigurationHandler::RegisterConfiguration(AliHLTConfiguration* pConf) { // see header file for function documentation int iResult=0; if (pConf) { if (FindConfiguration(pConf->GetName()) == NULL) { AliHLTConfiguration* pClone=new AliHLTConfiguration(*pConf); fgListConfigurations.Add(pClone); HLTDebug("configuration \"%s\" (%p) registered from %p", pClone->GetName(), pClone, pConf); // mark all configurations with unresolved dependencies for re-evaluation TObjLink* lnk=fgListConfigurations.FirstLink(); while (lnk) { AliHLTConfiguration* pSrc=(AliHLTConfiguration*)lnk->GetObject(); if (pSrc && pSrc!=pClone && pSrc->SourcesResolved()!=1) { pSrc->InvalidateSources(); } lnk=lnk->Next(); } } else { iResult=-EEXIST; HLTWarning("configuration \"%s\" already registered", pConf->GetName()); } } else { iResult=-EINVAL; } return iResult; } int AliHLTConfigurationHandler::CreateConfiguration(const char* id, const char* component, const char* sources, const char* arguments) { // see header file for function documentation int iResult=0; AliHLTConfiguration* pConf= new AliHLTConfiguration(id, component, sources, arguments); if (pConf) { // the configuration will be registered automatically, if this failes the configuration // is missing -> delete it if (FindConfiguration(id)==NULL) { delete pConf; pConf=NULL; iResult=-EEXIST; } } else { HLTError("system error: object allocation failed"); iResult=-ENOMEM; } return iResult; } void AliHLTConfigurationHandler::PrintConfigurations() { // see header file for function documentation HLTLogKeyword("configuration listing"); HLTMessage("registered configurations:"); TObjLink *lnk = fgListConfigurations.FirstLink(); while (lnk) { TObject *obj = lnk->GetObject(); HLTMessage(" %s", obj->GetName()); lnk = lnk->Next(); } } int AliHLTConfigurationHandler::RemoveConfiguration(const char* id) { // see header file for function documentation int iResult=0; if (id) { AliHLTConfiguration* pConf=NULL; if ((pConf=FindConfiguration(id))!=NULL) { iResult=RemoveConfiguration(pConf); delete pConf; pConf=NULL; } else { HLTWarning("can not find configuration \"%s\"", id); iResult=-ENOENT; } } else { iResult=-EINVAL; } return iResult; } int AliHLTConfigurationHandler::RemoveConfiguration(AliHLTConfiguration* pConf) { // see header file for function documentation int iResult=0; if (pConf) { // remove the configuration from the list HLTDebug("remove configuration \"%s\"", pConf->GetName()); fgListConfigurations.Remove(pConf); // remove cross links in the remaining configurations TObjLink* lnk=fgListConfigurations.FirstLink(); while (lnk && iResult>=0) { AliHLTConfiguration* pRem=(AliHLTConfiguration*)lnk->GetObject(); if (pRem) { pRem->InvalidateSource(pConf); } else { iResult=-EFAULT; } lnk=lnk->Next(); } } return iResult; } AliHLTConfiguration* AliHLTConfigurationHandler::FindConfiguration(const char* id) { // see header file for function documentation AliHLTConfiguration* pConf=NULL; if (id) { pConf=(AliHLTConfiguration*)fgListConfigurations.FindObject(id); } return pConf; }