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 AliHLTConfiguration.cxx
20 @author Matthias Richter
22 @brief Implementation of HLT configuration handler.
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
36 #include "AliHLTConfiguration.h"
37 #include "AliHLTConfigurationHandler.h"
38 #include "AliHLTTask.h"
39 #include "AliHLTComponent.h"
40 #include "AliHLTComponentHandler.h"
45 /** ROOT macro for the implementation of ROOT specific class methods */
46 ClassImp(AliHLTConfiguration)
48 AliHLTConfiguration::AliHLTConfiguration()
60 // see header file for class documentation
62 // refer to README to build package
64 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
66 fListSrcElement=fListSources.begin();
69 AliHLTConfiguration::AliHLTConfiguration(const char* id, const char* component, const char* sources, const char* arguments)
72 fComponent(component),
73 fStringSources(sources),
77 fArguments(arguments),
81 // see header file for function documentation
82 fListSrcElement=fListSources.begin();
83 if (id && component) {
84 if (fgConfigurationHandler) {
85 fgConfigurationHandler->RegisterConfiguration(this);
87 HLTError("no configuration handler set, abort registration");
92 AliHLTConfiguration::AliHLTConfiguration(const AliHLTConfiguration& src)
97 fComponent(src.fComponent),
98 fStringSources(src.fStringSources),
102 fArguments(src.fArguments),
106 // see header file for function documentation
107 fListSrcElement=fListSources.begin();
110 AliHLTConfiguration& AliHLTConfiguration::operator=(const AliHLTConfiguration& src)
112 // see header file for function documentation
114 fComponent=src.fComponent;
115 fStringSources=src.fStringSources;
117 fArguments=src.fArguments;
123 AliHLTConfiguration::~AliHLTConfiguration()
125 // see header file for function documentation
126 if (fgConfigurationHandler) {
127 if (fgConfigurationHandler->FindConfiguration(fID.Data())!=NULL) {
128 fgConfigurationHandler->RemoveConfiguration(this);
133 for (int i=0; i<fArgc; i++) {
141 vector<AliHLTConfiguration*>::iterator element=fListSources.begin();
142 while (element!=fListSources.end()) {
143 fListSources.erase(element);
144 element=fListSources.begin();
148 /* the global configuration handler which is used to automatically register the configuration
150 AliHLTConfigurationHandler* AliHLTConfiguration::fgConfigurationHandler=NULL;
152 int AliHLTConfiguration::GlobalInit(AliHLTConfigurationHandler* pHandler)
154 // see header file for function documentation
156 if (fgConfigurationHandler!=NULL) {
157 fgConfigurationHandler->Logging(kHLTLogWarning, "AliHLTConfiguration::GlobalInit", HLT_DEFAULT_LOG_KEYWORD, "configuration handler already initialized, overriding object %p with %p", fgConfigurationHandler, pHandler);
159 fgConfigurationHandler=pHandler;
163 int AliHLTConfiguration::GlobalDeinit(AliHLTConfigurationHandler* pHandler)
165 // see header file for function documentation
167 if (pHandler!=NULL && fgConfigurationHandler!=pHandler) {
168 fgConfigurationHandler->Logging(kHLTLogWarning, "AliHLTConfiguration::GlobalDeinit", HLT_DEFAULT_LOG_KEYWORD, "handler %p is not set, skip ...", pHandler);
171 fgConfigurationHandler=NULL;
175 const char* AliHLTConfiguration::GetName() const
177 // see header file for function documentation
180 return TObject::GetName();
183 AliHLTConfiguration* AliHLTConfiguration::GetSource(const char* id)
185 // see header file for function documentation
186 AliHLTConfiguration* pSrc=NULL;
188 // first check the current element
189 if (fListSrcElement!=fListSources.end() && strcmp(id, (*fListSrcElement)->GetName())==0) {
190 pSrc=*fListSrcElement;
194 pSrc=GetFirstSource();
196 if (strcmp(id, pSrc->GetName())==0)
198 pSrc=GetNextSource();
205 AliHLTConfiguration* AliHLTConfiguration::GetFirstSource()
207 // see header file for function documentation
208 AliHLTConfiguration* pSrc=NULL;
209 if (fNofSources>=0 || ExtractSources()) {
210 fListSrcElement=fListSources.begin();
211 if (fListSrcElement!=fListSources.end()) pSrc=*fListSrcElement;
216 AliHLTConfiguration* AliHLTConfiguration::GetNextSource()
218 // see header file for function documentation
219 AliHLTConfiguration* pSrc=NULL;
221 if (fListSrcElement!=fListSources.end() && (++fListSrcElement)!=fListSources.end())
222 pSrc=*fListSrcElement;
227 int AliHLTConfiguration::SourcesResolved(int bAuto)
229 // see header file for function documentation
231 if (fNofSources>=0 || bAuto && (iResult=ExtractSources())>=0) {
232 //HLTDebug("fNofSources=%d", fNofSources);
233 //HLTDebug("list size = %d", fListSources.size());
234 iResult=fNofSources==(int)fListSources.size();
239 int AliHLTConfiguration::InvalidateSource(AliHLTConfiguration* pConf)
241 // see header file for function documentation
244 vector<AliHLTConfiguration*>::iterator element=fListSources.begin();
245 while (element!=fListSources.end()) {
246 if (*element==pConf) {
247 fListSources.erase(element);
248 fListSrcElement=fListSources.end();
249 // there is no need to re-evaluate until there was a new configuration registered
250 // -> postpone the invalidation, its done in AliHLTConfigurationHandler::RegisterConfiguration
251 //InvalidateSources();
262 void AliHLTConfiguration::PrintStatus()
264 // see header file for function documentation
265 HLTLogKeyword("configuration status");
266 HLTMessage("status of configuration \"%s\" (%p)", GetName(), this);
267 if (!fComponent.IsNull()) HLTMessage(" - component: \"%s\"", fComponent.Data());
268 else HLTMessage(" - component string invalid");
269 if (!fStringSources.IsNull()) HLTMessage(" - sources: \"%s\"", fStringSources.Data());
270 else HLTMessage(" - no sources");
271 if (SourcesResolved(1)<=0)
272 HLTMessage(" there are unresolved sources");
273 AliHLTConfiguration* pSrc=GetFirstSource();
275 HLTMessage(" source \"%s\" (%p) resolved", pSrc->GetName(), pSrc);
276 pSrc=GetNextSource();
280 int AliHLTConfiguration::GetArguments(const char*** pArgv)
282 // see header file for function documentation
286 if ((iResult=ExtractArguments())<0) {
287 HLTError("error extracting arguments for configuration %s", GetName());
290 } else if (fArgc<0) {
291 HLTError("previous argument extraction failed");
293 //HLTDebug("%s fArgc %d", GetName(), fArgc);
295 *pArgv=(const char**)fArgv;
297 HLTError("invalid parameter");
304 int AliHLTConfiguration::ExtractSources()
306 // see header file for function documentation
309 if (!fStringSources.IsNull()) {
310 vector<char*> tgtList;
311 fListSources.clear();
312 if ((iResult=InterpreteString(fStringSources.Data(), tgtList))>=0) {
313 fNofSources=tgtList.size();
314 vector<char*>::iterator element=tgtList.begin();
315 while ((element=tgtList.begin())!=tgtList.end()) {
316 if (fgConfigurationHandler) {
317 AliHLTConfiguration* pConf=fgConfigurationHandler->FindConfiguration(*element);
319 //HLTDebug("configuration %s (%p): source \"%s\" (%p) inserted", GetName(), this, pConf->GetName(), pConf);
320 fListSources.push_back(pConf);
322 HLTError("can not find source \"%s\"", (*element));
325 } else if (iResult>=0) {
327 HLTFatal("global configuration handler not initialized, can not resolve sources");
330 tgtList.erase(element);
332 fListSrcElement=fListSources.begin();
338 int AliHLTConfiguration::ExtractArguments()
340 // see header file for function documentation
342 if (!fArguments.IsNull()) {
343 vector<char*> tgtList;
344 if ((iResult=InterpreteString(fArguments, tgtList))>=0) {
345 fArgc=tgtList.size();
346 //HLTDebug("configuration %s: extracted %d arguments from \"%s\"", GetName(), fArgc, fArguments);
348 fArgv = new char*[fArgc];
350 vector<char*>::iterator element=tgtList.begin();
352 while (element!=tgtList.end()) {
353 //HLTDebug("assign arguments %d (%s)", i, *element);
354 fArgv[i++]=(*element);
363 // there are zero arguments
369 int AliHLTConfiguration::InterpreteString(const char* arg, vector<char*>& argList)
371 // see header file for function documentation
374 //HLTDebug("interprete \"%s\"", arg);
379 //HLTDebug("%d %x", i, arg[i]);
380 if (arg[i]=='\'' && bQuote==0) {
382 } else if (arg[i]==0 ||
383 (arg[i]==' ' && bQuote==0) ||
384 (arg[i]=='\'' && bQuote==1)) {
387 char* pEntry= new char[i-prec+1];
389 strncpy(pEntry, &arg[prec], i-prec);
390 pEntry[i-prec]=0; // terminate string
391 //HLTDebug("create string \"%s\", insert at %d", pEntry, argList.size());
392 argList.push_back(pEntry);
397 } else if (prec==-1) prec=i;
398 } while (arg[i++]!=0 && iResult>=0);
405 int AliHLTConfiguration::FollowDependency(const char* id, TList* pTgtList)
407 // see header file for function documentation
410 AliHLTConfiguration* pDep=NULL;
411 if ((pDep=GetSource(id))!=NULL) {
412 if (pTgtList) pTgtList->Add(pDep);
415 pDep=GetFirstSource();
416 while (pDep && iResult==0) {
417 if ((iResult=pDep->FollowDependency(id, pTgtList))>0) {
418 if (pTgtList) pTgtList->AddFirst(pDep);
421 pDep=GetNextSource();
430 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
432 /** ROOT macro for the implementation of ROOT specific class methods */
435 AliHLTTask::AliHLTTask()
437 fpConfiguration(NULL),
444 // see header file for function documentation
447 AliHLTTask::AliHLTTask(AliHLTConfiguration* pConf)
449 fpConfiguration(pConf),
456 // see header file for function documentation
459 AliHLTTask::~AliHLTTask()
461 // see header file for function documentation
462 TObjLink* lnk=fListDependencies.FirstLink();
465 AliHLTTask* pTask=(AliHLTTask*)lnk->GetObject();
466 pTask->UnsetTarget(this);
469 lnk=fListTargets.FirstLink();
472 AliHLTTask* pTask=(AliHLTTask*)lnk->GetObject();
473 pTask->UnsetDependency(this);
477 if (fpComponent) delete fpComponent;
481 int AliHLTTask::Init(AliHLTConfiguration* pConf, AliHLTComponentHandler* pCH)
483 // see header file for function documentation
485 if (fpConfiguration!=NULL && pConf!=NULL && fpConfiguration!=pConf) {
486 HLTWarning("overriding existing reference to configuration object %p (%s) by %p",
487 fpConfiguration, GetName(), pConf);
489 if (pConf!=NULL) fpConfiguration=pConf;
490 if (fpConfiguration) {
493 const char** argv=NULL;
494 if ((iResult=fpConfiguration->GetArguments(&argv))>=0) {
495 argc=iResult; // just to make it clear
496 // TODO: we have to think about the optional environment parameter,
497 // currently just set to NULL.
498 iResult=pCH->CreateComponent(fpConfiguration->GetComponentID(), NULL, argc, argv, fpComponent);
499 if (fpComponent || iResult<=0) {
500 //HLTDebug("component %s (%p) created", fpComponent->GetComponentID(), fpComponent);
502 HLTError("can not find component \"%s\" (%d)", fpConfiguration->GetComponentID(), iResult);
505 HLTError("can not get argument list for configuration %s (%s)", fpConfiguration->GetName(), fpConfiguration->GetComponentID());
509 HLTError("component handler instance needed for task initialization");
513 HLTError("configuration object instance needed for task initialization");
519 int AliHLTTask::Deinit()
521 // see header file for function documentation
523 AliHLTComponent* pComponent=GetComponent();
526 //HLTDebug("delete component %s (%p)", pComponent->GetComponentID(), pComponent);
527 pComponent->Deinit();
530 HLTWarning("task %s (%p) doesn't seem to be in initialized", GetName(), this);
535 const char *AliHLTTask::GetName() const
537 // see header file for function documentation
539 return fpConfiguration->GetName();
540 return TObject::GetName();
543 AliHLTConfiguration* AliHLTTask::GetConf() const
545 // see header file for function documentation
546 return fpConfiguration;
549 AliHLTComponent* AliHLTTask::GetComponent() const
551 // see header file for function documentation
555 AliHLTTask* AliHLTTask::FindDependency(const char* id)
557 // see header file for function documentation
558 AliHLTTask* pTask=NULL;
560 pTask=(AliHLTTask*)fListDependencies.FindObject(id);
565 int AliHLTTask::FollowDependency(const char* id, TList* pTgtList)
567 // see header file for function documentation
570 AliHLTTask* pDep=NULL;
571 if ((pDep=(AliHLTTask*)fListDependencies.FindObject(id))!=NULL) {
572 if (pTgtList) pTgtList->Add(pDep);
575 TObjLink* lnk=fListDependencies.FirstLink();
576 while (lnk && iResult==0) {
577 pDep=(AliHLTTask*)lnk->GetObject();
579 if ((iResult=pDep->FollowDependency(id, pTgtList))>0) {
580 if (pTgtList) pTgtList->AddFirst(pDep);
595 void AliHLTTask::PrintDependencyTree(const char* id, int bFromConfiguration)
597 // see header file for function documentation
598 HLTLogKeyword("task dependencies");
601 if (bFromConfiguration) {
603 iResult=fpConfiguration->FollowDependency(id, &tgtList);
607 iResult=FollowDependency(id, &tgtList);
609 HLTMessage(" task \"%s\": dependency level %d ", GetName(), iResult);
610 TObjLink* lnk=tgtList.FirstLink();
612 char* pSpace = new char[iResult+1];
614 memset(pSpace, 32, iResult);
617 TObject* obj=lnk->GetObject();
618 HLTMessage(" %s^-- %s ", &pSpace[i--], obj->GetName());
628 int AliHLTTask::SetDependency(AliHLTTask* pDep)
630 // see header file for function documentation
633 if (FindDependency(pDep->GetName())==NULL) {
634 fListDependencies.Add(pDep);
644 int AliHLTTask::UnsetDependency(AliHLTTask* pDep)
646 // see header file for function documentation
647 fListDependencies.Remove(pDep);
648 if (fpConfiguration) {
649 fpConfiguration->InvalidateSources();
654 int AliHLTTask::CheckDependencies()
656 // see header file for function documentation
658 AliHLTConfiguration* pSrc=fpConfiguration->GetFirstSource();
660 if (FindDependency(pSrc->GetName())==NULL) {
661 //HLTDebug("dependency \"%s\" unresolved", pSrc->GetName());
664 pSrc=fpConfiguration->GetNextSource();
670 int AliHLTTask::Depends(AliHLTTask* pTask)
672 // see header file for function documentation
675 if (fpConfiguration) {
676 iResult=fpConfiguration->GetSource(pTask->GetName())!=NULL;
678 //HLTDebug("task \"%s\" depends on \"%s\"", GetName(), pTask->GetName());
680 //HLTDebug("task \"%s\" independend of \"%s\"", GetName(), pTask->GetName());
691 AliHLTTask* AliHLTTask::FindTarget(const char* id)
693 // see header file for function documentation
694 AliHLTTask* pTask=NULL;
696 pTask=(AliHLTTask*)fListTargets.FindObject(id);
701 int AliHLTTask::SetTarget(AliHLTTask* pTgt)
703 // see header file for function documentation
706 if (FindTarget(pTgt->GetName())==NULL) {
707 fListTargets.Add(pTgt);
717 int AliHLTTask::UnsetTarget(AliHLTTask* pTarget)
719 fListTargets.Remove(pTarget);
723 int AliHLTTask::StartRun()
725 // see header file for function documentation
727 int iNofInputDataBlocks=0;
728 AliHLTComponent* pComponent=GetComponent();
730 // determine the number of input data blocks provided from the source tasks
731 TObjLink* lnk=fListDependencies.FirstLink();
732 while (lnk && iResult>=0) {
733 AliHLTTask* pSrcTask=(AliHLTTask*)lnk->GetObject();
735 if ((iResult=pSrcTask->GetNofMatchingDataTypes(this))>0) {
736 iNofInputDataBlocks+=iResult;
737 } else if (iResult==0) {
738 HLTWarning("source task %s (%p) does not provide any matching data type for task %s (%p)", pSrcTask->GetName(), pSrcTask, GetName(), this);
740 HLTError("task %s (%p): error getting matching data types for source task %s (%p)", GetName(), this, pSrcTask->GetName(), pSrcTask);
747 if (fBlockDataArray.size()>0) {
748 HLTWarning("block data array for task %s (%p) was not cleaned", GetName(), this);
749 fBlockDataArray.resize(0);
753 // the initialization of the component is done by the ComponentHandler after creation
755 //iResult=Init( AliHLTComponentEnvironment* environ, void* environ_param, int argc, const char** argv );
757 // allocate internal task variables for bookkeeping aso.
758 // we allocate the BlockData array with at least one member
759 if (iNofInputDataBlocks==0) iNofInputDataBlocks=1;
760 AliHLTComponentBlockData init;
761 memset(&init, 0, sizeof(AliHLTComponentBlockData));
762 fBlockDataArray.resize(iNofInputDataBlocks, init);
764 // allocate the data buffer, which controls the output buffer and subscriptions
766 fpDataBuffer=new AliHLTDataBuffer;
767 if (fpDataBuffer!=NULL) {
768 HLTDebug("created data buffer %p for task %s (%p)", fpDataBuffer, GetName(), this);
769 TObjLink* lnk=fListTargets.FirstLink();
770 while (lnk && iResult>=0) {
771 AliHLTTask* pTgtTask=(AliHLTTask*)lnk->GetObject();
773 if ((iResult=fpDataBuffer->SetConsumer(pTgtTask->GetComponent()))>=0) {
782 HLTFatal("can not create data buffer object, memory allocation failed");
788 HLTError("task %s (%p) does not have a component", GetName(), this);
794 int AliHLTTask::EndRun()
796 // see header file for function documentation
798 if (fBlockDataArray.size()>0) {
799 fBlockDataArray.resize(0);
801 HLTWarning("task %s (%p) doesn't seem to be in running mode", GetName(), this);
804 AliHLTDataBuffer* pBuffer=fpDataBuffer;
811 int AliHLTTask::ProcessTask(Int_t eventNo)
813 // see header file for function documentation
815 AliHLTComponent* pComponent=GetComponent();
816 if (pComponent && fpDataBuffer) {
817 HLTDebug("Processing task %s (%p) fpDataBuffer %p", GetName(), this, fpDataBuffer);
818 fpDataBuffer->Reset();
819 int iSourceDataBlock=0;
820 int iInputDataVolume=0;
822 AliHLTTask* pSrcTask=NULL;
823 TList subscribedTaskList;
824 TObjLink* lnk=fListDependencies.FirstLink();
826 // subscribe to all source tasks
827 while (lnk && iResult>=0) {
828 pSrcTask=(AliHLTTask*)lnk->GetObject();
830 int iMatchingDB=pSrcTask->GetNofMatchingDataBlocks(this);
831 if (iMatchingDB>=0 && static_cast<unsigned int>(iMatchingDB)>fBlockDataArray.size()-iSourceDataBlock) {
832 AliHLTComponentBlockData init;
833 memset(&init, 0, sizeof(AliHLTComponentBlockData));
834 fBlockDataArray.resize(iSourceDataBlock+iMatchingDB, init);
837 HLTError("task %s (%p): error getting no of matching data blocks from task %s (%p), error %d", GetName(), this, pSrcTask->GetName(), pSrcTask, iMatchingDB);
840 } else if (iMatchingDB==0) {
841 HLTDebug("source task %s (%p) does not provide any matching data type for task %s (%p)", pSrcTask->GetName(), pSrcTask, GetName(), this);
844 if ((iResult=pSrcTask->Subscribe(this, &fBlockDataArray[iSourceDataBlock],fBlockDataArray.size()-iSourceDataBlock))>=0) {
845 for (int i=0; i<iResult; i++) {
846 iInputDataVolume+=fBlockDataArray[i+iSourceDataBlock].fSize;
847 // put the source task as many times into the list as it provides data blocks
848 // makes the bookkeeping for the data release easier
849 subscribedTaskList.Add(pSrcTask);
851 HLTDebug("Task %s (%p) successfully subscribed to %d data block(s) of task %s (%p)", GetName(), this, iResult, pSrcTask->GetName(), pSrcTask);
852 iSourceDataBlock+=iResult;
855 HLTError("Task %s (%p): subscription to task %s (%p) failed with error %d", GetName(), this, pSrcTask->GetName(), pSrcTask, iResult);
859 HLTFatal("fatal internal error in ROOT list handling");
866 int iNofTrial=0; // repeat processing if component returns -ENOSPC
867 AliHLTUInt32_t size=0;
870 long unsigned int iConstBase=0;
871 double fInputMultiplier=0;
872 if (pComponent->GetComponentType()!=AliHLTComponent::kSink)
873 pComponent->GetOutputDataSize(iConstBase, fInputMultiplier);
874 if (fInputMultiplier<0) {
875 HLTWarning("ignoring negative input multiplier");
878 long unsigned int iOutputDataSize=int(fInputMultiplier*iInputDataVolume) + iConstBase;
879 //HLTDebug("task %s: reqired output size %d", GetName(), iOutputDataSize);
881 // dont process again if the buffer size is the same
882 if (size==iOutputDataSize) break;
883 HLTInfo("processing task %s again with buffer size %d", GetName(), iOutputDataSize);
885 AliHLTUInt8_t* pTgtBuffer=NULL;
886 if (iOutputDataSize>0) pTgtBuffer=fpDataBuffer->GetTargetBuffer(iOutputDataSize);
887 //HLTDebug("provided raw buffer %p", pTgtBuffer);
888 AliHLTComponentEventData evtData;
889 AliHLTComponent::FillEventData(evtData);
890 evtData.fEventID=(AliHLTEventID_t)eventNo;
891 evtData.fBlockCnt=iSourceDataBlock;
892 AliHLTComponentTriggerData trigData;
893 size=iOutputDataSize;
894 AliHLTUInt32_t outputBlockCnt=0;
895 AliHLTComponentBlockData* outputBlocks=NULL;
896 AliHLTComponentEventDoneData* edd;
897 if (pTgtBuffer!=NULL || iOutputDataSize==0) {
898 iResult=pComponent->ProcessEvent(evtData, &fBlockDataArray[0], trigData, pTgtBuffer, size, outputBlockCnt, outputBlocks, edd);
899 HLTDebug("task %s: component %s ProcessEvent finnished (%d): size=%d blocks=%d", GetName(), pComponent->GetComponentID(), iResult, size, outputBlockCnt);
900 if (iResult>=0 && pTgtBuffer && outputBlocks) {
901 iResult=fpDataBuffer->SetSegments(pTgtBuffer, outputBlocks, outputBlockCnt);
902 delete [] outputBlocks; outputBlocks=NULL; outputBlockCnt=0;
904 fpDataBuffer->Reset();
907 HLTError("task %s: no target buffer available", GetName());
910 } while (iResult==-ENOSPC && iNofTrial++<1);
913 // now release all buffers which we have subscribed to
915 lnk=subscribedTaskList.FirstLink();
917 pSrcTask=(AliHLTTask*)lnk->GetObject();
920 if ((iTempRes=pSrcTask->Release(&fBlockDataArray[iSourceDataBlock], this))>=0) {
921 HLTDebug("Task %s (%p) successfully released segment of task %s (%p)", GetName(), this, pSrcTask->GetName(), pSrcTask);
923 HLTError("Task %s (%p): realease of task %s (%p) failed with error %d", GetName(), this, pSrcTask->GetName(), pSrcTask, iTempRes);
926 HLTFatal("task %s (%p): internal error in ROOT list handling", GetName(), this);
927 if (iResult>=0) iResult=-EFAULT;
929 subscribedTaskList.Remove(lnk);
930 lnk=subscribedTaskList.FirstLink();
933 if (subscribedTaskList.GetSize()>0) {
934 HLTError("task %s (%p): could not release all data buffers", GetName(), this);
937 HLTError("task %s (%p): internal failure (not initialized component %p, data buffer %p)", GetName(), this, fpComponent, fpDataBuffer);
943 int AliHLTTask::GetNofMatchingDataBlocks(const AliHLTTask* pConsumerTask) const
945 // see header file for function documentation
949 iResult=fpDataBuffer->FindMatchingDataBlocks(pConsumerTask->GetComponent(), NULL);
951 HLTFatal("internal data buffer missing");
960 int AliHLTTask::GetNofMatchingDataTypes(const AliHLTTask* pConsumerTask) const
962 // see header file for function documentation
965 AliHLTComponent* pComponent=GetComponent();
968 HLTError("component not initialized");
972 iResult=pComponent->FindMatchingDataTypes(pConsumerTask->GetComponent(), NULL);
974 HLTFatal("task initialization failed");
983 int AliHLTTask::Subscribe(const AliHLTTask* pConsumerTask, AliHLTComponentBlockData* pBlockDesc, int iArraySize)
985 // see header file for function documentation
989 iResult=fpDataBuffer->Subscribe(pConsumerTask->GetComponent(), pBlockDesc, iArraySize);
991 HLTFatal("internal data buffer missing");
1000 int AliHLTTask::Release(AliHLTComponentBlockData* pBlockDesc, const AliHLTTask* pConsumerTask)
1002 // see header file for function documentation
1004 if (pConsumerTask && pBlockDesc) {
1006 iResult=fpDataBuffer->Release(pBlockDesc, pConsumerTask->GetComponent());
1008 HLTFatal("internal data buffer missing");
1017 void AliHLTTask::PrintStatus()
1019 // see header file for function documentation
1020 HLTLogKeyword("task properties");
1021 AliHLTComponent* pComponent=GetComponent();
1023 HLTMessage(" component: %s (%p)", pComponent->GetComponentID(), pComponent);
1025 HLTMessage(" no component set!");
1027 if (fpConfiguration) {
1028 AliHLTConfiguration* pSrc=fpConfiguration->GetFirstSource();
1030 const char* pQualifier="unresolved";
1031 if (FindDependency(pSrc->GetName()))
1032 pQualifier="resolved";
1033 HLTMessage(" source: %s (%s)", pSrc->GetName(), pQualifier);
1034 pSrc=fpConfiguration->GetNextSource();
1036 TObjLink* lnk = fListTargets.FirstLink();
1038 TObject *obj = lnk->GetObject();
1039 HLTMessage(" target: %s", obj->GetName());
1043 HLTMessage(" task \"%s\" not initialized", GetName());
1047 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1049 /** ROOT macro for the implementation of ROOT specific class methods */
1050 ClassImp(AliHLTConfigurationHandler)
1052 AliHLTConfigurationHandler::AliHLTConfigurationHandler()
1054 fgListConfigurations()
1056 // see header file for function documentation
1057 SetLocalLoggingLevel(kHLTLogInfo);
1060 AliHLTConfigurationHandler::~AliHLTConfigurationHandler()
1062 // see header file for function documentation
1064 while ((lnk=fgListConfigurations.FirstLink())!=NULL) {
1065 AliHLTConfiguration* pConf=(AliHLTConfiguration*)lnk->GetObject();
1066 HLTDebug("delete configuration \"%s\"", pConf->GetName());
1067 fgListConfigurations.Remove(lnk);
1072 int AliHLTConfigurationHandler::RegisterConfiguration(AliHLTConfiguration* pConf)
1074 // see header file for function documentation
1077 if (FindConfiguration(pConf->GetName()) == NULL) {
1078 AliHLTConfiguration* pClone=new AliHLTConfiguration(*pConf);
1079 fgListConfigurations.Add(pClone);
1080 HLTDebug("configuration \"%s\" (%p) registered from %p", pClone->GetName(), pClone, pConf);
1082 // mark all configurations with unresolved dependencies for re-evaluation
1083 TObjLink* lnk=fgListConfigurations.FirstLink();
1085 AliHLTConfiguration* pSrc=(AliHLTConfiguration*)lnk->GetObject();
1086 if (pSrc && pSrc!=pClone && pSrc->SourcesResolved()!=1) {
1087 pSrc->InvalidateSources();
1093 HLTWarning("configuration \"%s\" already registered", pConf->GetName());
1101 int AliHLTConfigurationHandler::CreateConfiguration(const char* id, const char* component, const char* sources, const char* arguments)
1103 // see header file for function documentation
1105 AliHLTConfiguration* pConf= new AliHLTConfiguration(id, component, sources, arguments);
1107 // the configuration will be registered automatically, if this failes the configuration
1108 // is missing -> delete it
1109 if (FindConfiguration(id)==NULL) {
1115 HLTError("system error: object allocation failed");
1121 void AliHLTConfigurationHandler::PrintConfigurations()
1123 // see header file for function documentation
1124 HLTLogKeyword("configuration listing");
1125 HLTMessage("registered configurations:");
1126 TObjLink *lnk = fgListConfigurations.FirstLink();
1128 TObject *obj = lnk->GetObject();
1129 HLTMessage(" %s", obj->GetName());
1134 int AliHLTConfigurationHandler::RemoveConfiguration(const char* id)
1136 // see header file for function documentation
1139 AliHLTConfiguration* pConf=NULL;
1140 if ((pConf=FindConfiguration(id))!=NULL) {
1141 iResult=RemoveConfiguration(pConf);
1145 HLTWarning("can not find configuration \"%s\"", id);
1154 int AliHLTConfigurationHandler::RemoveConfiguration(AliHLTConfiguration* pConf)
1156 // see header file for function documentation
1159 // remove the configuration from the list
1160 HLTDebug("remove configuration \"%s\"", pConf->GetName());
1161 fgListConfigurations.Remove(pConf);
1162 // remove cross links in the remaining configurations
1163 TObjLink* lnk=fgListConfigurations.FirstLink();
1164 while (lnk && iResult>=0) {
1165 AliHLTConfiguration* pRem=(AliHLTConfiguration*)lnk->GetObject();
1167 pRem->InvalidateSource(pConf);
1177 AliHLTConfiguration* AliHLTConfigurationHandler::FindConfiguration(const char* id)
1179 // see header file for function documentation
1180 AliHLTConfiguration* pConf=NULL;
1182 pConf=(AliHLTConfiguration*)fgListConfigurations.FindObject(id);