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.
30 #include "AliHLTConfiguration.h"
31 #include "AliHLTConfigurationHandler.h"
32 #include "AliHLTTask.h"
33 #include "AliHLTComponent.h"
34 #include "AliHLTComponentHandler.h"
39 /** ROOT macro for the implementation of ROOT specific class methods */
40 ClassImp(AliHLTConfiguration)
42 AliHLTConfiguration::AliHLTConfiguration()
54 // see header file for function documentation
55 fListSrcElement=fListSources.begin();
58 AliHLTConfiguration::AliHLTConfiguration(const char* id, const char* component, const char* sources, const char* arguments)
61 fComponent(component),
62 fStringSources(sources),
66 fArguments(arguments),
70 // see header file for function documentation
71 fListSrcElement=fListSources.begin();
72 if (id && component) {
73 if (fgConfigurationHandler) {
74 fgConfigurationHandler->RegisterConfiguration(this);
76 HLTError("no configuration handler set, abort registration");
81 AliHLTConfiguration::AliHLTConfiguration(const AliHLTConfiguration& src)
86 fComponent(src.fComponent),
87 fStringSources(src.fStringSources),
91 fArguments(src.fArguments),
95 // see header file for function documentation
96 fListSrcElement=fListSources.begin();
99 AliHLTConfiguration& AliHLTConfiguration::operator=(const AliHLTConfiguration& src)
101 // see header file for function documentation
103 fComponent=src.fComponent;
104 fStringSources=src.fStringSources;
106 fArguments=src.fArguments;
112 AliHLTConfiguration::~AliHLTConfiguration()
114 // see header file for function documentation
115 if (fgConfigurationHandler) {
116 if (fgConfigurationHandler->FindConfiguration(fID.Data())!=NULL) {
117 fgConfigurationHandler->RemoveConfiguration(this);
122 for (int i=0; i<fArgc; i++) {
130 vector<AliHLTConfiguration*>::iterator element=fListSources.begin();
131 while (element!=fListSources.end()) {
132 fListSources.erase(element);
133 element=fListSources.begin();
137 /* the global configuration handler which is used to automatically register the configuration
139 AliHLTConfigurationHandler* AliHLTConfiguration::fgConfigurationHandler=NULL;
141 int AliHLTConfiguration::GlobalInit(AliHLTConfigurationHandler* pHandler)
143 // see header file for function documentation
145 if (fgConfigurationHandler!=NULL) {
146 fgConfigurationHandler->Logging(kHLTLogWarning, "AliHLTConfiguration::GlobalInit", HLT_DEFAULT_LOG_KEYWORD, "configuration handler already initialized, overriding object %p with %p", fgConfigurationHandler, pHandler);
148 fgConfigurationHandler=pHandler;
152 int AliHLTConfiguration::GlobalDeinit(AliHLTConfigurationHandler* pHandler)
154 // see header file for function documentation
156 if (pHandler!=NULL && fgConfigurationHandler!=pHandler) {
157 fgConfigurationHandler->Logging(kHLTLogWarning, "AliHLTConfiguration::GlobalDeinit", HLT_DEFAULT_LOG_KEYWORD, "handler %p is not set, skip ...", pHandler);
160 fgConfigurationHandler=NULL;
164 const char* AliHLTConfiguration::GetName() const
166 // see header file for function documentation
169 return TObject::GetName();
172 AliHLTConfiguration* AliHLTConfiguration::GetSource(const char* id)
174 // see header file for function documentation
175 AliHLTConfiguration* pSrc=NULL;
177 // first check the current element
178 if (fListSrcElement!=fListSources.end() && strcmp(id, (*fListSrcElement)->GetName())==0) {
179 pSrc=*fListSrcElement;
183 pSrc=GetFirstSource();
185 if (strcmp(id, pSrc->GetName())==0)
187 pSrc=GetNextSource();
194 AliHLTConfiguration* AliHLTConfiguration::GetFirstSource()
196 // see header file for function documentation
197 AliHLTConfiguration* pSrc=NULL;
198 if (fNofSources>=0 || ExtractSources()) {
199 fListSrcElement=fListSources.begin();
200 if (fListSrcElement!=fListSources.end()) pSrc=*fListSrcElement;
205 AliHLTConfiguration* AliHLTConfiguration::GetNextSource()
207 // see header file for function documentation
208 AliHLTConfiguration* pSrc=NULL;
210 if (fListSrcElement!=fListSources.end() && (++fListSrcElement)!=fListSources.end())
211 pSrc=*fListSrcElement;
216 int AliHLTConfiguration::SourcesResolved(int bAuto)
218 // see header file for function documentation
220 if (fNofSources>=0 || bAuto && (iResult=ExtractSources())>=0) {
221 //HLTDebug("fNofSources=%d", fNofSources);
222 //HLTDebug("list size = %d", fListSources.size());
223 iResult=fNofSources==(int)fListSources.size();
228 int AliHLTConfiguration::InvalidateSource(AliHLTConfiguration* pConf)
230 // see header file for function documentation
233 vector<AliHLTConfiguration*>::iterator element=fListSources.begin();
234 while (element!=fListSources.end()) {
235 if (*element==pConf) {
236 fListSources.erase(element);
237 fListSrcElement=fListSources.end();
238 // there is no need to re-evaluate until there was a new configuration registered
239 // -> postpone the invalidation, its done in AliHLTConfigurationHandler::RegisterConfiguration
240 //InvalidateSources();
251 void AliHLTConfiguration::PrintStatus()
253 // see header file for function documentation
254 HLTLogKeyword("configuration status");
255 HLTMessage("status of configuration \"%s\" (%p)", GetName(), this);
256 if (!fComponent.IsNull()) HLTMessage(" - component: \"%s\"", fComponent.Data());
257 else HLTMessage(" - component string invalid");
258 if (!fStringSources.IsNull()) HLTMessage(" - sources: \"%s\"", fStringSources.Data());
259 else HLTMessage(" - no sources");
260 if (SourcesResolved(1)<=0)
261 HLTMessage(" there are unresolved sources");
262 AliHLTConfiguration* pSrc=GetFirstSource();
264 HLTMessage(" source \"%s\" (%p) resolved", pSrc->GetName(), pSrc);
265 pSrc=GetNextSource();
269 int AliHLTConfiguration::GetArguments(const char*** pArgv)
271 // see header file for function documentation
275 if ((iResult=ExtractArguments())<0) {
276 HLTError("error extracting arguments for configuration %s", GetName());
279 } else if (fArgc<0) {
280 HLTError("previous argument extraction failed");
282 //HLTDebug("%s fArgc %d", GetName(), fArgc);
284 *pArgv=(const char**)fArgv;
286 HLTError("invalid parameter");
293 int AliHLTConfiguration::ExtractSources()
295 // see header file for function documentation
298 if (!fStringSources.IsNull()) {
299 vector<char*> tgtList;
300 fListSources.clear();
301 if ((iResult=InterpreteString(fStringSources.Data(), tgtList))>=0) {
302 fNofSources=tgtList.size();
303 vector<char*>::iterator element=tgtList.begin();
304 while ((element=tgtList.begin())!=tgtList.end()) {
305 if (fgConfigurationHandler) {
306 AliHLTConfiguration* pConf=fgConfigurationHandler->FindConfiguration(*element);
308 //HLTDebug("configuration %s (%p): source \"%s\" (%p) inserted", GetName(), this, pConf->GetName(), pConf);
309 fListSources.push_back(pConf);
311 HLTError("can not find source \"%s\"", (*element));
314 } else if (iResult>=0) {
316 HLTFatal("global configuration handler not initialized, can not resolve sources");
319 tgtList.erase(element);
321 fListSrcElement=fListSources.begin();
327 int AliHLTConfiguration::ExtractArguments()
329 // see header file for function documentation
331 if (!fArguments.IsNull()) {
332 vector<char*> tgtList;
333 if ((iResult=InterpreteString(fArguments, tgtList))>=0) {
334 fArgc=tgtList.size();
335 //HLTDebug("configuration %s: extracted %d arguments from \"%s\"", GetName(), fArgc, fArguments);
337 fArgv = new char*[fArgc];
339 vector<char*>::iterator element=tgtList.begin();
341 while (element!=tgtList.end()) {
342 //HLTDebug("assign arguments %d (%s)", i, *element);
343 fArgv[i++]=(*element);
352 // there are zero arguments
358 int AliHLTConfiguration::InterpreteString(const char* arg, vector<char*>& argList)
360 // see header file for function documentation
363 //HLTDebug("interprete \"%s\"", arg);
368 //HLTDebug("%d %x", i, arg[i]);
369 if (arg[i]=='\'' && bQuote==0) {
371 } else if (arg[i]==0 ||
372 (arg[i]==' ' && bQuote==0) ||
373 (arg[i]=='\'' && bQuote==1)) {
376 char* pEntry= new char[i-prec+1];
378 strncpy(pEntry, &arg[prec], i-prec);
379 pEntry[i-prec]=0; // terminate string
380 //HLTDebug("create string \"%s\", insert at %d", pEntry, argList.size());
381 argList.push_back(pEntry);
386 } else if (prec==-1) prec=i;
387 } while (arg[i++]!=0 && iResult>=0);
394 int AliHLTConfiguration::FollowDependency(const char* id, TList* pTgtList)
396 // see header file for function documentation
399 AliHLTConfiguration* pDep=NULL;
400 if ((pDep=GetSource(id))!=NULL) {
401 if (pTgtList) pTgtList->Add(pDep);
404 pDep=GetFirstSource();
405 while (pDep && iResult==0) {
406 if ((iResult=pDep->FollowDependency(id, pTgtList))>0) {
407 if (pTgtList) pTgtList->AddFirst(pDep);
410 pDep=GetNextSource();
419 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
421 /** ROOT macro for the implementation of ROOT specific class methods */
424 AliHLTTask::AliHLTTask()
426 fpConfiguration(NULL),
431 fpBlockDataArray(NULL),
432 fBlockDataArraySize(0)
434 // see header file for function documentation
437 AliHLTTask::AliHLTTask(AliHLTConfiguration* pConf)
439 fpConfiguration(pConf),
444 fpBlockDataArray(NULL),
445 fBlockDataArraySize(0)
447 // see header file for function documentation
450 AliHLTTask::AliHLTTask(const AliHLTTask&)
454 fpConfiguration(NULL),
459 fpBlockDataArray(NULL),
460 fBlockDataArraySize(0)
462 HLTFatal("copy constructor untested");
465 AliHLTTask& AliHLTTask::operator=(const AliHLTTask&)
467 // see header file for function documentation
468 HLTFatal("assignment operator untested");
472 AliHLTTask::~AliHLTTask()
474 TObjLink* lnk=fListDependencies.FirstLink();
477 AliHLTTask* pTask=(AliHLTTask*)lnk->GetObject();
478 pTask->UnsetTarget(this);
481 lnk=fListTargets.FirstLink();
484 AliHLTTask* pTask=(AliHLTTask*)lnk->GetObject();
485 pTask->UnsetDependency(this);
489 if (fpComponent) delete fpComponent;
491 if (fpBlockDataArray) delete[] fpBlockDataArray;
492 fpBlockDataArray=NULL;
495 int AliHLTTask::Init(AliHLTConfiguration* pConf, AliHLTComponentHandler* pCH)
497 // see header file for function documentation
499 if (fpConfiguration!=NULL && pConf!=NULL && fpConfiguration!=pConf) {
500 HLTWarning("overriding existing reference to configuration object %p (%s) by %p",
501 fpConfiguration, GetName(), pConf);
503 if (pConf!=NULL) fpConfiguration=pConf;
504 if (fpConfiguration) {
507 const char** argv=NULL;
508 if ((iResult=fpConfiguration->GetArguments(&argv))>=0) {
509 argc=iResult; // just to make it clear
510 // TODO: we have to think about the optional environment parameter,
511 // currently just set to NULL.
512 iResult=pCH->CreateComponent(fpConfiguration->GetComponentID(), NULL, argc, argv, fpComponent);
513 if (fpComponent || iResult<=0) {
514 //HLTDebug("component %s (%p) created", fpComponent->GetComponentID(), fpComponent);
516 HLTError("can not find component \"%s\" (%d)", fpConfiguration->GetComponentID(), iResult);
519 HLTError("can not get argument list for configuration %s (%s)", fpConfiguration->GetName(), fpConfiguration->GetComponentID());
523 HLTError("component handler instance needed for task initialization");
527 HLTError("configuration object instance needed for task initialization");
533 int AliHLTTask::Deinit()
535 // see header file for function documentation
537 AliHLTComponent* pComponent=GetComponent();
540 //HLTDebug("delete component %s (%p)", pComponent->GetComponentID(), pComponent);
541 pComponent->Deinit();
544 HLTWarning("task %s (%p) doesn't seem to be in initialized", GetName(), this);
549 const char *AliHLTTask::GetName() const
551 // see header file for function documentation
553 return fpConfiguration->GetName();
554 return TObject::GetName();
557 AliHLTConfiguration* AliHLTTask::GetConf() const
559 // see header file for function documentation
560 return fpConfiguration;
563 AliHLTComponent* AliHLTTask::GetComponent() const
565 // see header file for function documentation
569 AliHLTTask* AliHLTTask::FindDependency(const char* id)
571 // see header file for function documentation
572 AliHLTTask* pTask=NULL;
574 pTask=(AliHLTTask*)fListDependencies.FindObject(id);
579 int AliHLTTask::FollowDependency(const char* id, TList* pTgtList)
581 // see header file for function documentation
584 AliHLTTask* pDep=NULL;
585 if ((pDep=(AliHLTTask*)fListDependencies.FindObject(id))!=NULL) {
586 if (pTgtList) pTgtList->Add(pDep);
589 TObjLink* lnk=fListDependencies.FirstLink();
590 while (lnk && iResult==0) {
591 pDep=(AliHLTTask*)lnk->GetObject();
593 if ((iResult=pDep->FollowDependency(id, pTgtList))>0) {
594 if (pTgtList) pTgtList->AddFirst(pDep);
609 void AliHLTTask::PrintDependencyTree(const char* id, int bFromConfiguration)
611 // see header file for function documentation
612 HLTLogKeyword("task dependencies");
615 if (bFromConfiguration) {
617 iResult=fpConfiguration->FollowDependency(id, &tgtList);
621 iResult=FollowDependency(id, &tgtList);
623 HLTMessage(" task \"%s\": dependency level %d ", GetName(), iResult);
624 TObjLink* lnk=tgtList.FirstLink();
626 char* pSpace = new char[iResult+1];
628 memset(pSpace, 32, iResult);
631 TObject* obj=lnk->GetObject();
632 HLTMessage(" %s^-- %s ", &pSpace[i--], obj->GetName());
642 int AliHLTTask::SetDependency(AliHLTTask* pDep)
644 // see header file for function documentation
647 if (FindDependency(pDep->GetName())==NULL) {
648 fListDependencies.Add(pDep);
658 int AliHLTTask::UnsetDependency(AliHLTTask* pDep)
660 fListDependencies.Remove(pDep);
661 if (fpConfiguration) {
662 fpConfiguration->InvalidateSources();
667 int AliHLTTask::CheckDependencies()
669 // see header file for function documentation
671 AliHLTConfiguration* pSrc=fpConfiguration->GetFirstSource();
673 if (FindDependency(pSrc->GetName())==NULL) {
674 //HLTDebug("dependency \"%s\" unresolved", pSrc->GetName());
677 pSrc=fpConfiguration->GetNextSource();
683 int AliHLTTask::Depends(AliHLTTask* pTask)
685 // see header file for function documentation
688 if (fpConfiguration) {
689 iResult=fpConfiguration->GetSource(pTask->GetName())!=NULL;
691 //HLTDebug("task \"%s\" depends on \"%s\"", GetName(), pTask->GetName());
693 //HLTDebug("task \"%s\" independend of \"%s\"", GetName(), pTask->GetName());
704 AliHLTTask* AliHLTTask::FindTarget(const char* id)
706 // see header file for function documentation
707 AliHLTTask* pTask=NULL;
709 pTask=(AliHLTTask*)fListTargets.FindObject(id);
714 int AliHLTTask::SetTarget(AliHLTTask* pTgt)
716 // see header file for function documentation
719 if (FindTarget(pTgt->GetName())==NULL) {
720 fListTargets.Add(pTgt);
730 int AliHLTTask::UnsetTarget(AliHLTTask* pTarget)
732 fListTargets.Remove(pTarget);
736 int AliHLTTask::StartRun()
738 // see header file for function documentation
740 int iNofInputDataBlocks=0;
741 AliHLTComponent* pComponent=GetComponent();
743 // determine the number of input data blocks provided from the source tasks
744 TObjLink* lnk=fListDependencies.FirstLink();
745 while (lnk && iResult>=0) {
746 AliHLTTask* pSrcTask=(AliHLTTask*)lnk->GetObject();
748 if ((iResult=pSrcTask->GetNofMatchingDataTypes(this))>0) {
749 iNofInputDataBlocks+=iResult;
750 } else if (iResult==0) {
751 HLTWarning("source task %s (%p) does not provide any matching data type for task %s (%p)", pSrcTask->GetName(), pSrcTask, GetName(), this);
753 HLTError("task %s (%p): error getting matching data types for source task %s (%p)", GetName(), this, pSrcTask->GetName(), pSrcTask);
760 if (fpBlockDataArray) {
761 HLTWarning("block data array for task %s (%p) was not cleaned", GetName(), this);
762 delete [] fpBlockDataArray;
763 fpBlockDataArray=NULL;
764 fBlockDataArraySize=0;
768 // the initialization of the component is done by the ComponentHandler after creation
770 //iResult=Init( AliHLTComponentEnvironment* environ, void* environ_param, int argc, const char** argv );
772 // allocate internal task variables for bookkeeping aso.
773 // we allocate the BlockData array with at least one member
774 if (iNofInputDataBlocks==0) iNofInputDataBlocks=1;
775 fpBlockDataArray=new AliHLTComponentBlockData[iNofInputDataBlocks];
776 if (fpBlockDataArray) {
777 fBlockDataArraySize=iNofInputDataBlocks;
779 HLTError("memory allocation failed");
783 // allocate the data buffer, which controls the output buffer and subscriptions
785 fpDataBuffer=new AliHLTDataBuffer;
786 if (fpDataBuffer!=NULL) {
787 HLTDebug("created data buffer %p for task %s (%p)", fpDataBuffer, GetName(), this);
788 TObjLink* lnk=fListTargets.FirstLink();
789 while (lnk && iResult>=0) {
790 AliHLTTask* pTgtTask=(AliHLTTask*)lnk->GetObject();
792 if ((iResult=fpDataBuffer->SetConsumer(pTgtTask->GetComponent()))>=0) {
801 HLTFatal("can not create data buffer object, memory allocation failed");
807 HLTError("task %s (%p) does not have a component", GetName(), this);
813 int AliHLTTask::EndRun()
815 // see header file for function documentation
817 if (fpBlockDataArray) {
818 fBlockDataArraySize=0;
819 delete [] fpBlockDataArray;
822 HLTWarning("task %s (%p) doesn't seem to be in running mode", GetName(), this);
825 AliHLTDataBuffer* pBuffer=fpDataBuffer;
832 int AliHLTTask::ProcessTask(Int_t eventNo)
834 // see header file for function documentation
836 AliHLTComponent* pComponent=GetComponent();
837 if (pComponent && fpDataBuffer) {
838 HLTDebug("Processing task %s (%p) fpDataBuffer %p", GetName(), this, fpDataBuffer);
839 fpDataBuffer->Reset();
840 int iSourceDataBlock=0;
841 int iInputDataVolume=0;
843 int iNofInputDataBlocks=0;
844 /* TODO: the assumption of only one output data type per component is the current constraint
845 * later it should be checked how many output blocks of the source component match the input
846 * data types of the consumer component (GetNofMatchingDataBlocks). If one assumes that a
847 * certain output block is always been produced, the initialization could be done in the
848 * StartRun. Otherwise the fpBlockDataArray has to be adapted each time.
850 iNofInputDataBlocks=fListDependencies.GetSize(); // one block per source
851 // is not been used since the allocation was done in StartRun, but check the size
852 if (iNofInputDataBlocks>fBlockDataArraySize) {
853 HLTError("block data array too small");
856 AliHLTTask* pSrcTask=NULL;
857 TList subscribedTaskList;
858 TObjLink* lnk=fListDependencies.FirstLink();
860 // subscribe to all source tasks
861 while (lnk && iResult>=0) {
862 pSrcTask=(AliHLTTask*)lnk->GetObject();
864 int iMatchingDB=pSrcTask->GetNofMatchingDataBlocks(this);
865 if (iMatchingDB<=fBlockDataArraySize-iSourceDataBlock) {
866 if (fpBlockDataArray) {
867 if ((iResult=pSrcTask->Subscribe(this, &fpBlockDataArray[iSourceDataBlock],fBlockDataArraySize-iSourceDataBlock))>0) {
868 for (int i=0; i<iResult; i++) {
869 iInputDataVolume+=fpBlockDataArray[i+iSourceDataBlock].fSize;
870 // put the source task as many times into the list as it provides data blocks
871 // makes the bookkeeping for the data release easier
872 subscribedTaskList.Add(pSrcTask);
874 iSourceDataBlock+=iResult;
875 HLTDebug("Task %s (%p) successfully subscribed to %d data block(s) of task %s (%p)", GetName(), this, iResult, pSrcTask->GetName(), pSrcTask);
878 HLTError("Task %s (%p): subscription to task %s (%p) failed with error %d", GetName(), this, pSrcTask->GetName(), pSrcTask, iResult);
882 HLTFatal("Task %s (%p): BlockData array not allocated", GetName(), this);
886 HLTFatal("Task %s (%p): too little space in data block array for subscription to task %s (%p)", GetName(), this, pSrcTask->GetName(), pSrcTask);
887 HLTDebug("#data types=%d, array size=%d, current index=%d", iMatchingDB, fBlockDataArraySize, iSourceDataBlock);
891 HLTFatal("fatal internal error in ROOT list handling");
899 long unsigned int iConstBase=0;
900 double fInputMultiplier=0;
901 if (pComponent->GetComponentType()!=AliHLTComponent::kSink)
902 pComponent->GetOutputDataSize(iConstBase, fInputMultiplier);
903 int iOutputDataSize=int(fInputMultiplier*iInputDataVolume) + iConstBase;
904 //HLTDebug("task %s: reqired output size %d", GetName(), iOutputDataSize);
905 AliHLTUInt8_t* pTgtBuffer=NULL;
906 if (iOutputDataSize>0) pTgtBuffer=fpDataBuffer->GetTargetBuffer(iOutputDataSize);
907 //HLTDebug("provided raw buffer %p", pTgtBuffer);
908 AliHLTComponentEventData evtData;
909 AliHLTComponent::FillEventData(evtData);
910 evtData.fEventID=(AliHLTEventID_t)eventNo;
911 evtData.fBlockCnt=iSourceDataBlock;
912 AliHLTComponentTriggerData trigData;
913 AliHLTUInt32_t size=iOutputDataSize;
914 AliHLTUInt32_t outputBlockCnt=0;
915 AliHLTComponentBlockData* outputBlocks=NULL;
916 AliHLTComponentEventDoneData* edd;
917 if (pTgtBuffer!=NULL || iOutputDataSize==0) {
918 iResult=pComponent->ProcessEvent(evtData, fpBlockDataArray, trigData, pTgtBuffer, size, outputBlockCnt, outputBlocks, edd);
919 HLTDebug("task %s: component %s ProcessEvent finnished (%d): size=%d blocks=%d", GetName(), pComponent->GetComponentID(), iResult, size, outputBlockCnt);
920 if (iResult>=0 && pTgtBuffer) {
921 iResult=fpDataBuffer->SetSegments(pTgtBuffer, outputBlocks, outputBlockCnt);
922 delete [] outputBlocks; outputBlocks=NULL; outputBlockCnt=0;
925 HLTError("task %s: no target buffer available", GetName());
930 // now release all buffers which we have subscribed to
932 lnk=subscribedTaskList.FirstLink();
934 pSrcTask=(AliHLTTask*)lnk->GetObject();
937 if ((iTempRes=pSrcTask->Release(&fpBlockDataArray[iSourceDataBlock], this))>=0) {
938 HLTDebug("Task %s (%p) successfully released task %s (%p)", GetName(), this, pSrcTask->GetName(), pSrcTask);
940 HLTError("Task %s (%p): realease of task %s (%p) failed with error %d", GetName(), this, pSrcTask->GetName(), pSrcTask, iTempRes);
943 HLTFatal("task %s (%p): internal error in ROOT list handling", GetName(), this);
944 if (iResult>=0) iResult=-EFAULT;
946 subscribedTaskList.Remove(lnk);
947 lnk=subscribedTaskList.FirstLink();
950 if (subscribedTaskList.GetSize()>0) {
951 HLTError("task %s (%p): could not release all data buffers", GetName(), this);
954 HLTError("task %s (%p): internal failure (not initialized component %p, data buffer %p)", GetName(), this, fpComponent, fpDataBuffer);
960 int AliHLTTask::GetNofMatchingDataBlocks(const AliHLTTask* pConsumerTask) const
962 // see header file for function documentation
966 iResult=fpDataBuffer->FindMatchingDataBlocks(pConsumerTask->GetComponent(), NULL);
968 HLTFatal("internal data buffer missing");
977 int AliHLTTask::GetNofMatchingDataTypes(const AliHLTTask* pConsumerTask) const
979 // see header file for function documentation
982 AliHLTComponent* pComponent=GetComponent();
985 HLTError("component not initialized");
989 iResult=pComponent->FindMatchingDataTypes(pConsumerTask->GetComponent(), NULL);
991 HLTFatal("task initialization failed");
1000 int AliHLTTask::Subscribe(const AliHLTTask* pConsumerTask, AliHLTComponentBlockData* pBlockDesc, int iArraySize)
1002 // see header file for function documentation
1004 if (pConsumerTask) {
1006 iResult=fpDataBuffer->Subscribe(pConsumerTask->GetComponent(), pBlockDesc, iArraySize);
1008 HLTFatal("internal data buffer missing");
1017 int AliHLTTask::Release(AliHLTComponentBlockData* pBlockDesc, const AliHLTTask* pConsumerTask)
1019 // see header file for function documentation
1021 if (pConsumerTask && pBlockDesc) {
1023 iResult=fpDataBuffer->Release(pBlockDesc, pConsumerTask->GetComponent());
1025 HLTFatal("internal data buffer missing");
1034 void AliHLTTask::PrintStatus()
1036 // see header file for function documentation
1037 HLTLogKeyword("task properties");
1038 AliHLTComponent* pComponent=GetComponent();
1040 HLTMessage(" component: %s (%p)", pComponent->GetComponentID(), pComponent);
1042 HLTMessage(" no component set!");
1044 if (fpConfiguration) {
1045 AliHLTConfiguration* pSrc=fpConfiguration->GetFirstSource();
1047 const char* pQualifier="unresolved";
1048 if (FindDependency(pSrc->GetName()))
1049 pQualifier="resolved";
1050 HLTMessage(" source: %s (%s)", pSrc->GetName(), pQualifier);
1051 pSrc=fpConfiguration->GetNextSource();
1053 TObjLink* lnk = fListTargets.FirstLink();
1055 TObject *obj = lnk->GetObject();
1056 HLTMessage(" target: %s", obj->GetName());
1060 HLTMessage(" task \"%s\" not initialized", GetName());
1064 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1066 /** ROOT macro for the implementation of ROOT specific class methods */
1067 ClassImp(AliHLTConfigurationHandler)
1069 AliHLTConfigurationHandler::AliHLTConfigurationHandler()
1071 fgListConfigurations()
1073 // see header file for function documentation
1074 SetLocalLoggingLevel(kHLTLogInfo);
1077 AliHLTConfigurationHandler::~AliHLTConfigurationHandler()
1079 // see header file for function documentation
1081 while (lnk=fgListConfigurations.FirstLink()) {
1082 AliHLTConfiguration* pConf=(AliHLTConfiguration*)lnk->GetObject();
1083 HLTDebug("delete configuration \"%s\"", pConf->GetName());
1084 fgListConfigurations.Remove(lnk);
1089 int AliHLTConfigurationHandler::RegisterConfiguration(AliHLTConfiguration* pConf)
1091 // see header file for function documentation
1094 if (FindConfiguration(pConf->GetName()) == NULL) {
1095 AliHLTConfiguration* pClone=new AliHLTConfiguration(*pConf);
1096 fgListConfigurations.Add(pClone);
1097 HLTDebug("configuration \"%s\" (%p) registered from %p", pClone->GetName(), pClone, pConf);
1099 // mark all configurations with unresolved dependencies for re-evaluation
1100 TObjLink* lnk=fgListConfigurations.FirstLink();
1102 AliHLTConfiguration* pSrc=(AliHLTConfiguration*)lnk->GetObject();
1103 if (pSrc && pSrc!=pClone && pSrc->SourcesResolved()!=1) {
1104 pSrc->InvalidateSources();
1110 HLTWarning("configuration \"%s\" already registered", pConf->GetName());
1118 int AliHLTConfigurationHandler::CreateConfiguration(const char* id, const char* component, const char* sources, const char* arguments)
1120 // see header file for function documentation
1122 AliHLTConfiguration* pConf= new AliHLTConfiguration(id, component, sources, arguments);
1124 // the configuration will be registered automatically, if this failes the configuration
1125 // is missing -> delete it
1126 if (FindConfiguration(id)==NULL) {
1132 HLTError("system error: object allocation failed");
1138 void AliHLTConfigurationHandler::PrintConfigurations()
1140 // see header file for function documentation
1141 HLTLogKeyword("configuration listing");
1142 HLTMessage("registered configurations:");
1143 TObjLink *lnk = fgListConfigurations.FirstLink();
1145 TObject *obj = lnk->GetObject();
1146 HLTMessage(" %s", obj->GetName());
1151 int AliHLTConfigurationHandler::RemoveConfiguration(const char* id)
1153 // see header file for function documentation
1156 AliHLTConfiguration* pConf=NULL;
1157 if ((pConf=FindConfiguration(id))!=NULL) {
1158 iResult=RemoveConfiguration(pConf);
1162 HLTWarning("can not find configuration \"%s\"", id);
1171 int AliHLTConfigurationHandler::RemoveConfiguration(AliHLTConfiguration* pConf)
1173 // see header file for function documentation
1176 // remove the configuration from the list
1177 HLTDebug("remove configuration \"%s\"", pConf->GetName());
1178 fgListConfigurations.Remove(pConf);
1179 // remove cross links in the remaining configurations
1180 TObjLink* lnk=fgListConfigurations.FirstLink();
1181 while (lnk && iResult>=0) {
1182 AliHLTConfiguration* pRem=(AliHLTConfiguration*)lnk->GetObject();
1184 pRem->InvalidateSource(pConf);
1194 AliHLTConfiguration* AliHLTConfigurationHandler::FindConfiguration(const char* id)
1196 // see header file for function documentation
1197 AliHLTConfiguration* pConf=NULL;
1199 pConf=(AliHLTConfiguration*)fgListConfigurations.FindObject(id);