3 /**************************************************************************
4 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
6 * Authors: Matthias Richter <Matthias.Richter@ift.uib.no> *
7 * for The ALICE Off-line Project. *
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 **************************************************************************/
18 /** @file AliHLTConfiguration.cxx
19 @author Matthias Richter
21 @brief Implementation of HLT configuration handler.
29 #include "AliHLTConfiguration.h"
30 #include "AliHLTConfigurationHandler.h"
31 #include "AliHLTTask.h"
32 #include "AliHLTComponent.h"
33 #include "AliHLTComponentHandler.h"
37 /** ROOT macro for the implementation of ROOT specific class methods */
38 ClassImp(AliHLTConfiguration)
40 AliHLTConfiguration::AliHLTConfiguration()
52 fListSrcElement=fListSources.begin();
55 AliHLTConfiguration::AliHLTConfiguration(const char* id, const char* component, const char* sources, const char* arguments)
58 fComponent(component),
59 fStringSources(sources),
63 fArguments(arguments),
67 fListSrcElement=fListSources.begin();
68 if (id && component) {
69 if (fConfigurationHandler) {
70 fConfigurationHandler->RegisterConfiguration(this);
72 HLTError("no configuration handler set, abort registration");
77 AliHLTConfiguration::AliHLTConfiguration(const AliHLTConfiguration&)
91 fListSrcElement=fListSources.begin();
92 HLTFatal("copy constructor untested");
95 AliHLTConfiguration& AliHLTConfiguration::operator=(const AliHLTConfiguration&)
97 HLTFatal("assignment operator untested");
101 AliHLTConfiguration::~AliHLTConfiguration()
103 if (fConfigurationHandler) {
104 if (fConfigurationHandler->FindConfiguration(fID)!=NULL) {
105 fConfigurationHandler->RemoveConfiguration(this);
110 for (int i=0; i<fArgc; i++) {
119 /* the global configuration handler which is used to automatically register the configuration
121 AliHLTConfigurationHandler* AliHLTConfiguration::fConfigurationHandler=NULL;
123 int AliHLTConfiguration::GlobalInit(AliHLTConfigurationHandler* pHandler)
126 if (fConfigurationHandler!=NULL) {
127 fConfigurationHandler->Logging(kHLTLogWarning, "AliHLTConfiguration::GlobalInit", HLT_DEFAULT_LOG_KEYWORD, "configuration handler already initialized, overriding object %p", fConfigurationHandler);
129 fConfigurationHandler=pHandler;
133 int AliHLTConfiguration::GlobalDeinit()
136 fConfigurationHandler=NULL;
140 const char* AliHLTConfiguration::GetName() const {
143 return TObject::GetName();
146 AliHLTConfiguration* AliHLTConfiguration::GetSource(const char* id)
148 AliHLTConfiguration* pSrc=NULL;
150 // first check the current element
151 if (fListSrcElement!=fListSources.end() && strcmp(id, (*fListSrcElement)->GetName())==0) {
152 pSrc=*fListSrcElement;
156 pSrc=GetFirstSource();
158 if (strcmp(id, pSrc->GetName())==0)
160 pSrc=GetNextSource();
167 AliHLTConfiguration* AliHLTConfiguration::GetFirstSource()
169 AliHLTConfiguration* pSrc=NULL;
170 if (fNofSources>=0 || ExtractSources()) {
171 fListSrcElement=fListSources.begin();
172 if (fListSrcElement!=fListSources.end()) pSrc=*fListSrcElement;
177 AliHLTConfiguration* AliHLTConfiguration::GetNextSource()
179 AliHLTConfiguration* pSrc=NULL;
181 if (fListSrcElement!=fListSources.end() && (++fListSrcElement)!=fListSources.end())
182 pSrc=*fListSrcElement;
187 int AliHLTConfiguration::SourcesResolved(int bAuto)
190 if (fNofSources>=0 || bAuto && (iResult=ExtractSources())>=0) {
191 //HLTDebug("fNofSources=%d", fNofSources);
192 //HLTDebug("list size = %d", fListSources.size());
193 iResult=fNofSources==(int)fListSources.size();
198 int AliHLTConfiguration::InvalidateSource(AliHLTConfiguration* pConf)
202 vector<AliHLTConfiguration*>::iterator element=fListSources.begin();
203 while (element!=fListSources.end()) {
204 if (*element==pConf) {
205 fListSources.erase(element);
206 fListSrcElement=fListSources.end();
207 // there is no need to re-evaluate until there was a new configuration registered
208 // -> postpone the invalidation, its done in AliHLTConfigurationHandler::RegisterConfiguration
209 //InvalidateSources();
220 void AliHLTConfiguration::PrintStatus()
222 HLTLogKeyword("configuration status");
223 HLTMessage("status of configuration \"%s\" (%p)", GetName(), this);
224 if (fComponent) HLTMessage(" - component: \"%s\"", fComponent);
225 else HLTMessage(" - component string invalid");
226 if (fStringSources) HLTMessage(" - sources: \"%s\"", fStringSources);
227 else HLTMessage(" - no sources");
228 if (SourcesResolved(1)<=0)
229 HLTMessage(" there are unresolved sources");
230 AliHLTConfiguration* pSrc=GetFirstSource();
232 HLTMessage(" source \"%s\" (%p) resolved", pSrc->GetName(), pSrc);
233 pSrc=GetNextSource();
237 int AliHLTConfiguration::GetArguments(const char*** pArgv)
242 if ((iResult=ExtractArguments())<0) {
243 HLTError("error extracting arguments for configuration %s", GetName());
246 } else if (fArgc<0) {
247 HLTError("previous argument extraction failed");
249 //HLTDebug("%s fArgc %d", GetName(), fArgc);
251 *pArgv=(const char**)fArgv;
253 HLTError("invalid parameter");
260 int AliHLTConfiguration::ExtractSources()
264 if (fStringSources!=NULL) {
265 vector<char*> tgtList;
266 fListSources.clear();
267 if ((iResult=InterpreteString(fStringSources, tgtList))>=0) {
268 fNofSources=tgtList.size();
269 vector<char*>::iterator element=tgtList.begin();
270 while ((element=tgtList.begin())!=tgtList.end()) {
271 if (fConfigurationHandler) {
272 AliHLTConfiguration* pConf=fConfigurationHandler->FindConfiguration(*element);
274 HLTDebug("source \"%s\" inserted", pConf->GetName());
275 fListSources.push_back(pConf);
277 HLTError("can not find source \"%s\"", (*element));
280 } else if (iResult>=0) {
282 HLTFatal("global configuration handler not initialized, can not resolve sources");
285 tgtList.erase(element);
287 fListSrcElement=fListSources.begin();
293 int AliHLTConfiguration::ExtractArguments()
296 if (fArguments!=NULL) {
297 vector<char*> tgtList;
298 if ((iResult=InterpreteString(fArguments, tgtList))>=0) {
299 fArgc=tgtList.size();
300 //HLTDebug("configuration %s: extracted %d arguments from \"%s\"", GetName(), fArgc, fArguments);
302 fArgv = new char*[fArgc];
304 vector<char*>::iterator element=tgtList.begin();
306 while (element!=tgtList.end()) {
307 //HLTDebug("assign arguments %d (%s)", i, *element);
308 fArgv[i++]=(*element);
317 // there are zero arguments
323 int AliHLTConfiguration::InterpreteString(const char* arg, vector<char*>& argList)
327 //HLTDebug("interprete \"%s\"", arg);
331 if (arg[i]==0 || arg[i]==' ') {
333 char* pEntry= new char[i-prec+1];
335 strncpy(pEntry, &arg[prec], i-prec);
336 pEntry[i-prec]=0; // terminate string
337 //HLTDebug("create string \"%s\", insert at %d", pEntry, argList.size());
338 argList.push_back(pEntry);
343 } else if (prec==-1) prec=i;
344 } while (arg[i++]!=0 && iResult>=0);
351 int AliHLTConfiguration::FollowDependency(const char* id, TList* pTgtList)
355 AliHLTConfiguration* pDep=NULL;
356 if ((pDep=GetSource(id))!=NULL) {
357 if (pTgtList) pTgtList->Add(pDep);
360 pDep=GetFirstSource();
361 while (pDep && iResult==0) {
362 if ((iResult=pDep->FollowDependency(id, pTgtList))>0) {
363 if (pTgtList) pTgtList->AddFirst(pDep);
366 pDep=GetNextSource();
375 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
377 /** ROOT macro for the implementation of ROOT specific class methods */
380 AliHLTTask::AliHLTTask()
382 fpConfiguration(NULL),
387 fpBlockDataArray(NULL),
388 fBlockDataArraySize(0)
392 AliHLTTask::AliHLTTask(AliHLTConfiguration* pConf)
394 fpConfiguration(pConf),
399 fpBlockDataArray(NULL),
400 fBlockDataArraySize(0)
404 AliHLTTask::AliHLTTask(const AliHLTTask&)
408 fpConfiguration(NULL),
413 fpBlockDataArray(NULL),
414 fBlockDataArraySize(0)
416 HLTFatal("copy constructor untested");
419 AliHLTTask& AliHLTTask::operator=(const AliHLTTask&)
421 HLTFatal("assignment operator untested");
425 AliHLTTask::~AliHLTTask()
427 if (fpComponent) delete fpComponent;
429 if (fpBlockDataArray) delete[] fpBlockDataArray;
430 fpBlockDataArray=NULL;
433 int AliHLTTask::Init(AliHLTConfiguration* pConf, AliHLTComponentHandler* pCH)
436 if (fpConfiguration!=NULL && pConf!=NULL && fpConfiguration!=pConf) {
437 HLTWarning("overriding existing reference to configuration object %p (%s) by %p",
438 fpConfiguration, GetName(), pConf);
440 if (pConf!=NULL) fpConfiguration=pConf;
441 if (fpConfiguration) {
444 const char** argv=NULL;
445 if ((iResult=fpConfiguration->GetArguments(&argv))>=0) {
446 argc=iResult; // just to make it clear
447 // TODO: we have to think about the optional environment parameter,
448 // currently just set to NULL.
449 iResult=pCH->CreateComponent(fpConfiguration->GetComponentID(), NULL, argc, argv, fpComponent);
450 if (fpComponent || iResult<=0) {
452 HLTError("can not find component \"%s\" (%d)", fpConfiguration->GetComponentID(), iResult);
455 HLTError("can not get argument list for configuration %s (%s)", fpConfiguration->GetName(), fpConfiguration->GetComponentID());
459 HLTError("component handler instance needed for task initialization");
463 HLTError("configuration object instance needed for task initialization");
469 int AliHLTTask::Deinit()
472 AliHLTComponent* pComponent=GetComponent();
475 pComponent->Deinit();
478 HLTWarning("task %s (%p) doesn't seem to be in initialized", GetName(), this);
483 const char *AliHLTTask::GetName() const
486 return fpConfiguration->GetName();
487 return TObject::GetName();
490 AliHLTConfiguration* AliHLTTask::GetConf() const
492 return fpConfiguration;
495 AliHLTComponent* AliHLTTask::GetComponent() const
500 AliHLTTask* AliHLTTask::FindDependency(const char* id)
502 AliHLTTask* pTask=NULL;
504 pTask=(AliHLTTask*)fListDependencies.FindObject(id);
509 int AliHLTTask::FollowDependency(const char* id, TList* pTgtList)
513 AliHLTTask* pDep=NULL;
514 if ((pDep=(AliHLTTask*)fListDependencies.FindObject(id))!=NULL) {
515 if (pTgtList) pTgtList->Add(pDep);
518 TObjLink* lnk=fListDependencies.FirstLink();
519 while (lnk && iResult==0) {
520 pDep=(AliHLTTask*)lnk->GetObject();
522 if ((iResult=pDep->FollowDependency(id, pTgtList))>0) {
523 if (pTgtList) pTgtList->AddFirst(pDep);
538 void AliHLTTask::PrintDependencyTree(const char* id, int bFromConfiguration)
540 HLTLogKeyword("task dependencies");
543 if (bFromConfiguration) {
545 iResult=fpConfiguration->FollowDependency(id, &tgtList);
549 iResult=FollowDependency(id, &tgtList);
551 HLTMessage(" task \"%s\": dependency level %d ", GetName(), iResult);
552 TObjLink* lnk=tgtList.FirstLink();
554 char* pSpace = new char[iResult+1];
556 memset(pSpace, 32, iResult);
559 TObject* obj=lnk->GetObject();
560 HLTMessage(" %s^-- %s ", &pSpace[i--], obj->GetName());
570 int AliHLTTask::SetDependency(AliHLTTask* pDep)
574 if (FindDependency(pDep->GetName())==NULL) {
575 fListDependencies.Add(pDep);
585 int AliHLTTask::CheckDependencies()
588 AliHLTConfiguration* pSrc=fpConfiguration->GetFirstSource();
590 if (FindDependency(pSrc->GetName())==NULL) {
591 //HLTDebug("dependency \"%s\" unresolved", pSrc->GetName());
594 pSrc=fpConfiguration->GetNextSource();
600 int AliHLTTask::Depends(AliHLTTask* pTask)
604 if (fpConfiguration) {
605 iResult=fpConfiguration->GetSource(pTask->GetName())!=NULL;
607 //HLTDebug("task \"%s\" depends on \"%s\"", GetName(), pTask->GetName());
609 //HLTDebug("task \"%s\" independend of \"%s\"", GetName(), pTask->GetName());
620 AliHLTTask* AliHLTTask::FindTarget(const char* id)
622 AliHLTTask* pTask=NULL;
624 pTask=(AliHLTTask*)fListTargets.FindObject(id);
629 int AliHLTTask::SetTarget(AliHLTTask* pTgt)
633 if (FindTarget(pTgt->GetName())==NULL) {
634 fListTargets.Add(pTgt);
644 int AliHLTTask::StartRun()
647 int iNofInputDataBlocks=0;
648 AliHLTComponent* pComponent=GetComponent();
650 // determine the number of input data blocks provided from the source tasks
651 TObjLink* lnk=fListDependencies.FirstLink();
652 while (lnk && iResult>=0) {
653 AliHLTTask* pSrcTask=(AliHLTTask*)lnk->GetObject();
655 if ((iResult=pSrcTask->GetNofMatchingDataTypes(this))>0) {
656 iNofInputDataBlocks+=iResult;
657 } else if (iResult==0) {
658 HLTWarning("source task %s (%p) does not provide any matching data type for task %s (%p)", pSrcTask->GetName(), pSrcTask, GetName(), this);
660 HLTError("task %s (%p): error getting matching data types for source task %s (%p)", GetName(), this, pSrcTask->GetName(), pSrcTask);
667 if (fpBlockDataArray) {
668 HLTWarning("block data array for task %s (%p) was not cleaned", GetName(), this);
669 delete [] fpBlockDataArray;
670 fpBlockDataArray=NULL;
671 fBlockDataArraySize=0;
675 // the initialization of the component is done by the ComponentHandler after creation
677 //iResult=Init( AliHLTComponentEnvironment* environ, void* environ_param, int argc, const char** argv );
679 // allocate internal task variables for bookkeeping aso.
680 // we allocate the BlockData array with at least one member
681 if (iNofInputDataBlocks==0) iNofInputDataBlocks=1;
682 fpBlockDataArray=new AliHLTComponentBlockData[iNofInputDataBlocks];
683 if (fpBlockDataArray) {
684 fBlockDataArraySize=iNofInputDataBlocks;
686 HLTError("memory allocation failed");
690 // allocate the data buffer, which controls the output buffer and subscriptions
692 fpDataBuffer=new AliHLTDataBuffer;
693 if (fpDataBuffer!=NULL) {
694 HLTDebug("created data buffer %p for task %s (%p)", fpDataBuffer, GetName(), this);
695 TObjLink* lnk=fListTargets.FirstLink();
696 while (lnk && iResult>=0) {
697 AliHLTTask* pTgtTask=(AliHLTTask*)lnk->GetObject();
699 if ((iResult=fpDataBuffer->SetConsumer(pTgtTask->GetComponent()))>=0) {
708 HLTFatal("can not create data buffer object, memory allocation failed");
714 HLTError("task %s (%p) does not have a component", GetName(), this);
720 int AliHLTTask::EndRun()
723 if (fpBlockDataArray) {
724 fBlockDataArraySize=0;
725 delete [] fpBlockDataArray;
728 HLTWarning("task %s (%p) doesn't seem to be in running mode", GetName(), this);
731 AliHLTDataBuffer* pBuffer=fpDataBuffer;
738 int AliHLTTask::ProcessTask(Int_t eventNo)
741 AliHLTComponent* pComponent=GetComponent();
742 if (pComponent && fpDataBuffer) {
743 HLTDebug("Processing task %s (%p) fpDataBuffer %p", GetName(), this, fpDataBuffer);
744 fpDataBuffer->Reset();
745 int iSourceDataBlock=0;
746 int iInputDataVolume=0;
748 int iNofInputDataBlocks=0;
749 /* TODO: the assumption of only one output data type per component is the current constraint
750 * later it should be checked how many output blocks of the source component match the input
751 * data types of the consumer component (GetNofMatchingDataBlocks). If one assumes that a
752 * certain output block is always been produced, the initialization could be done in the
753 * StartRun. Otherwise the fpBlockDataArray has to be adapted each time.
755 iNofInputDataBlocks=fListDependencies.GetSize(); // one block per source
756 // is not been used since the allocation was done in StartRun, but check the size
757 if (iNofInputDataBlocks>fBlockDataArraySize) {
758 HLTError("block data array too small");
761 AliHLTTask* pSrcTask=NULL;
762 TList subscribedTaskList;
763 TObjLink* lnk=fListDependencies.FirstLink();
765 // subscribe to all source tasks
766 while (lnk && iResult>=0) {
767 pSrcTask=(AliHLTTask*)lnk->GetObject();
769 int iMatchingDB=pSrcTask->GetNofMatchingDataBlocks(this);
770 if (iMatchingDB<=fBlockDataArraySize-iSourceDataBlock) {
771 if (fpBlockDataArray) {
772 if ((iResult=pSrcTask->Subscribe(this, &fpBlockDataArray[iSourceDataBlock],fBlockDataArraySize-iSourceDataBlock))>0) {
773 for (int i=0; i<iResult; i++) {
774 iInputDataVolume+=fpBlockDataArray[i+iSourceDataBlock].fSize;
775 // put the source task as many times into the list as it provides data blocks
776 // makes the bookkeeping for the data release easier
777 subscribedTaskList.Add(pSrcTask);
779 iSourceDataBlock+=iResult;
780 HLTDebug("Task %s (%p) successfully subscribed to %d data block(s) of task %s (%p)", GetName(), this, iResult, pSrcTask->GetName(), pSrcTask);
783 HLTError("Task %s (%p): subscription to task %s (%p) failed with error %d", GetName(), this, pSrcTask->GetName(), pSrcTask, iResult);
787 HLTFatal("Task %s (%p): BlockData array not allocated", GetName(), this);
791 HLTFatal("Task %s (%p): too little space in data block array for subscription to task %s (%p)", GetName(), this, pSrcTask->GetName(), pSrcTask);
792 HLTDebug("#data types=%d, array size=%d, current index=%d", iMatchingDB, fBlockDataArraySize, iSourceDataBlock);
796 HLTFatal("fatal internal error in ROOT list handling");
804 long unsigned int iConstBase=0;
805 double fInputMultiplier=0;
806 if (pComponent->GetComponentType()!=AliHLTComponent::kSink)
807 pComponent->GetOutputDataSize(iConstBase, fInputMultiplier);
808 int iOutputDataSize=int(fInputMultiplier*iInputDataVolume) + iConstBase;
809 //HLTDebug("task %s: reqired output size %d", GetName(), iOutputDataSize);
810 AliHLTUInt8_t* pTgtBuffer=NULL;
811 if (iOutputDataSize>0) pTgtBuffer=fpDataBuffer->GetTargetBuffer(iOutputDataSize);
812 //HLTDebug("provided raw buffer %p", pTgtBuffer);
813 AliHLTComponentEventData evtData;
814 AliHLTComponent::FillEventData(evtData);
815 evtData.fEventID=(AliHLTEventID_t)eventNo;
816 evtData.fBlockCnt=iSourceDataBlock;
817 AliHLTComponentTriggerData trigData;
818 AliHLTUInt32_t size=iOutputDataSize;
819 AliHLTUInt32_t outputBlockCnt=0;
820 AliHLTComponentBlockData* outputBlocks=NULL;
821 AliHLTComponentEventDoneData* edd;
822 if (pTgtBuffer!=NULL || iOutputDataSize==0) {
823 iResult=pComponent->ProcessEvent(evtData, fpBlockDataArray, trigData, pTgtBuffer, size, outputBlockCnt, outputBlocks, edd);
824 HLTDebug("task %s: component %s ProcessEvent finnished (%d): size=%d blocks=%d", GetName(), pComponent->GetComponentID(), iResult, size, outputBlockCnt);
825 if (iResult>=0 && pTgtBuffer) {
826 iResult=fpDataBuffer->SetSegments(pTgtBuffer, outputBlocks, outputBlockCnt);
829 HLTError("task %s: no target buffer available", GetName());
834 // now release all buffers which we have subscribed to
836 lnk=subscribedTaskList.FirstLink();
838 pSrcTask=(AliHLTTask*)lnk->GetObject();
841 if ((iTempRes=pSrcTask->Release(&fpBlockDataArray[iSourceDataBlock], this))>=0) {
842 HLTDebug("Task %s (%p) successfully released task %s (%p)", GetName(), this, pSrcTask->GetName(), pSrcTask);
844 HLTError("Task %s (%p): realease of task %s (%p) failed with error %d", GetName(), this, pSrcTask->GetName(), pSrcTask, iTempRes);
847 HLTFatal("task %s (%p): internal error in ROOT list handling", GetName(), this);
848 if (iResult>=0) iResult=-EFAULT;
850 subscribedTaskList.Remove(lnk);
851 lnk=subscribedTaskList.FirstLink();
854 if (subscribedTaskList.GetSize()>0) {
855 HLTError("task %s (%p): could not release all data buffers", GetName(), this);
858 HLTError("task %s (%p): internal failure (not initialized component %p, data buffer %p)", GetName(), this, fpComponent, fpDataBuffer);
864 int AliHLTTask::GetNofMatchingDataBlocks(const AliHLTTask* pConsumerTask) const
869 iResult=fpDataBuffer->FindMatchingDataBlocks(pConsumerTask->GetComponent(), NULL);
871 HLTFatal("internal data buffer missing");
880 int AliHLTTask::GetNofMatchingDataTypes(const AliHLTTask* pConsumerTask) const
884 AliHLTComponent* pComponent=GetComponent();
889 iResult=pComponent->FindMatchingDataTypes(pConsumerTask->GetComponent(), NULL);
891 HLTFatal("task initialization failed");
900 int AliHLTTask::Subscribe(const AliHLTTask* pConsumerTask, AliHLTComponentBlockData* pBlockDesc, int iArraySize)
905 iResult=fpDataBuffer->Subscribe(pConsumerTask->GetComponent(), pBlockDesc, iArraySize);
907 HLTFatal("internal data buffer missing");
916 int AliHLTTask::Release(AliHLTComponentBlockData* pBlockDesc, const AliHLTTask* pConsumerTask)
919 if (pConsumerTask && pBlockDesc) {
921 iResult=fpDataBuffer->Release(pBlockDesc, pConsumerTask->GetComponent());
923 HLTFatal("internal data buffer missing");
932 /* this function is most likely depricated
933 int AliHLTTask::ClearSourceBlocks()
940 void AliHLTTask::PrintStatus()
942 HLTLogKeyword("task properties");
943 AliHLTComponent* pComponent=GetComponent();
945 HLTMessage(" component: %s (%p)", pComponent->GetComponentID(), pComponent);
947 HLTMessage(" no component set!");
949 if (fpConfiguration) {
950 AliHLTConfiguration* pSrc=fpConfiguration->GetFirstSource();
952 const char* pQualifier="unresolved";
953 if (FindDependency(pSrc->GetName()))
954 pQualifier="resolved";
955 HLTMessage(" source: %s (%s)", pSrc->GetName(), pQualifier);
956 pSrc=fpConfiguration->GetNextSource();
958 TObjLink* lnk = fListTargets.FirstLink();
960 TObject *obj = lnk->GetObject();
961 HLTMessage(" target: %s", obj->GetName());
965 HLTMessage(" task \"%s\" not initialized", GetName());
969 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
971 TList AliHLTConfigurationHandler::fListConfigurations;
972 TList AliHLTConfigurationHandler::fListDynamicConfigurations;
974 /** ROOT macro for the implementation of ROOT specific class methods */
975 ClassImp(AliHLTConfigurationHandler)
977 AliHLTConfigurationHandler::AliHLTConfigurationHandler()
981 AliHLTConfigurationHandler::~AliHLTConfigurationHandler()
983 TObjLink* lnk=fListDynamicConfigurations.FirstLink();
985 TObject* obj=lnk->GetObject();
986 if (fListConfigurations.FindObject(obj->GetName())==NULL) {
987 HLTDebug("delete dynamic configuration \"%s\"", obj->GetName());
994 int AliHLTConfigurationHandler::RegisterConfiguration(AliHLTConfiguration* pConf)
998 if (FindConfiguration(pConf->GetName()) == NULL) {
999 fListConfigurations.Add(pConf);
1000 //HLTDebug("configuration \"%s\" registered", pConf->GetName());
1002 // mark all configurations with unresolved dependencies for re-evaluation
1003 TObjLink* lnk=fListConfigurations.FirstLink();
1005 AliHLTConfiguration* pSrc=(AliHLTConfiguration*)lnk->GetObject();
1006 if (pSrc && pSrc!=pConf && pSrc->SourcesResolved()!=1) {
1007 pSrc->InvalidateSources();
1013 HLTWarning("configuration \"%s\" already registered", pConf->GetName());
1021 int AliHLTConfigurationHandler::CreateConfiguration(const char* id, const char* component, const char* sources, const char* arguments)
1024 AliHLTConfiguration* pConf= new AliHLTConfiguration(id, component, sources, arguments);
1026 // the configuration will be registered automatically, if this failes the configuration
1027 // is missing -> delete it
1028 if (FindConfiguration(id)==NULL) {
1033 fListDynamicConfigurations.Add(pConf);
1036 HLTError("system error: object allocation failed");
1042 void AliHLTConfigurationHandler::PrintConfigurations()
1044 HLTLogKeyword("configuration listing");
1045 HLTMessage("registered configurations:");
1046 TObjLink *lnk = fListConfigurations.FirstLink();
1048 TObject *obj = lnk->GetObject();
1049 HLTMessage(" %s", obj->GetName());
1054 int AliHLTConfigurationHandler::RemoveConfiguration(const char* id)
1058 AliHLTConfiguration* pConf=NULL;
1059 if ((pConf=FindConfiguration(id))!=NULL) {
1060 iResult=RemoveConfiguration(pConf);
1062 HLTWarning("can not find configuration \"%s\"", id);
1071 int AliHLTConfigurationHandler::RemoveConfiguration(AliHLTConfiguration* pConf)
1075 // remove the configuration from the list
1076 HLTDebug("remove configuration \"%s\"", pConf->GetName());
1077 fListConfigurations.Remove(pConf);
1078 // remove cross links in the remaining configurations
1079 TObjLink* lnk=fListConfigurations.FirstLink();
1080 while (lnk && iResult>=0) {
1081 AliHLTConfiguration* pRem=(AliHLTConfiguration*)lnk->GetObject();
1083 pRem->InvalidateSource(pConf);
1093 AliHLTConfiguration* AliHLTConfigurationHandler::FindConfiguration(const char* id)
1095 AliHLTConfiguration* pConf=NULL;
1097 pConf=(AliHLTConfiguration*)fListConfigurations.FindObject(id);