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"
38 /** ROOT macro for the implementation of ROOT specific class methods */
39 ClassImp(AliHLTConfiguration)
41 AliHLTConfiguration::AliHLTConfiguration()
53 // see header file for function documentation
54 fListSrcElement=fListSources.begin();
57 AliHLTConfiguration::AliHLTConfiguration(const char* id, const char* component, const char* sources, const char* arguments)
60 fComponent(component),
61 fStringSources(sources),
65 fArguments(arguments),
69 // see header file for function documentation
70 fListSrcElement=fListSources.begin();
71 if (id && component) {
72 if (fgConfigurationHandler) {
73 fgConfigurationHandler->RegisterConfiguration(this);
75 HLTError("no configuration handler set, abort registration");
80 AliHLTConfiguration::AliHLTConfiguration(const AliHLTConfiguration& src)
85 fComponent(src.fComponent),
86 fStringSources(src.fStringSources),
90 fArguments(src.fArguments),
94 // see header file for function documentation
95 fListSrcElement=fListSources.begin();
98 AliHLTConfiguration& AliHLTConfiguration::operator=(const AliHLTConfiguration& src)
100 // see header file for function documentation
102 fComponent=src.fComponent;
103 fStringSources=src.fStringSources;
105 fArguments=src.fArguments;
111 AliHLTConfiguration::~AliHLTConfiguration()
113 // see header file for function documentation
114 if (fgConfigurationHandler) {
115 if (fgConfigurationHandler->FindConfiguration(fID.Data())!=NULL) {
116 fgConfigurationHandler->RemoveConfiguration(this);
121 for (int i=0; i<fArgc; i++) {
130 /* the global configuration handler which is used to automatically register the configuration
132 AliHLTConfigurationHandler* AliHLTConfiguration::fgConfigurationHandler=NULL;
134 int AliHLTConfiguration::GlobalInit(AliHLTConfigurationHandler* pHandler)
136 // see header file for function documentation
138 if (fgConfigurationHandler!=NULL) {
139 fgConfigurationHandler->Logging(kHLTLogWarning, "AliHLTConfiguration::GlobalInit", HLT_DEFAULT_LOG_KEYWORD, "configuration handler already initialized, overriding object %p with %p", fgConfigurationHandler, pHandler);
141 fgConfigurationHandler=pHandler;
145 int AliHLTConfiguration::GlobalDeinit(AliHLTConfigurationHandler* pHandler)
147 // see header file for function documentation
149 if (pHandler!=NULL && fgConfigurationHandler!=pHandler) {
150 fgConfigurationHandler->Logging(kHLTLogWarning, "AliHLTConfiguration::GlobalDeinit", HLT_DEFAULT_LOG_KEYWORD, "handler %p is not set, skip ...", pHandler);
153 fgConfigurationHandler=NULL;
157 const char* AliHLTConfiguration::GetName() const
159 // see header file for function documentation
162 return TObject::GetName();
165 AliHLTConfiguration* AliHLTConfiguration::GetSource(const char* id)
167 // see header file for function documentation
168 AliHLTConfiguration* pSrc=NULL;
170 // first check the current element
171 if (fListSrcElement!=fListSources.end() && strcmp(id, (*fListSrcElement)->GetName())==0) {
172 pSrc=*fListSrcElement;
176 pSrc=GetFirstSource();
178 if (strcmp(id, pSrc->GetName())==0)
180 pSrc=GetNextSource();
187 AliHLTConfiguration* AliHLTConfiguration::GetFirstSource()
189 // see header file for function documentation
190 AliHLTConfiguration* pSrc=NULL;
191 if (fNofSources>=0 || ExtractSources()) {
192 fListSrcElement=fListSources.begin();
193 if (fListSrcElement!=fListSources.end()) pSrc=*fListSrcElement;
198 AliHLTConfiguration* AliHLTConfiguration::GetNextSource()
200 // see header file for function documentation
201 AliHLTConfiguration* pSrc=NULL;
203 if (fListSrcElement!=fListSources.end() && (++fListSrcElement)!=fListSources.end())
204 pSrc=*fListSrcElement;
209 int AliHLTConfiguration::SourcesResolved(int bAuto)
211 // see header file for function documentation
213 if (fNofSources>=0 || bAuto && (iResult=ExtractSources())>=0) {
214 //HLTDebug("fNofSources=%d", fNofSources);
215 //HLTDebug("list size = %d", fListSources.size());
216 iResult=fNofSources==(int)fListSources.size();
221 int AliHLTConfiguration::InvalidateSource(AliHLTConfiguration* pConf)
223 // see header file for function documentation
226 vector<AliHLTConfiguration*>::iterator element=fListSources.begin();
227 while (element!=fListSources.end()) {
228 if (*element==pConf) {
229 fListSources.erase(element);
230 fListSrcElement=fListSources.end();
231 // there is no need to re-evaluate until there was a new configuration registered
232 // -> postpone the invalidation, its done in AliHLTConfigurationHandler::RegisterConfiguration
233 //InvalidateSources();
244 void AliHLTConfiguration::PrintStatus()
246 // see header file for function documentation
247 HLTLogKeyword("configuration status");
248 HLTMessage("status of configuration \"%s\" (%p)", GetName(), this);
249 if (!fComponent.IsNull()) HLTMessage(" - component: \"%s\"", fComponent.Data());
250 else HLTMessage(" - component string invalid");
251 if (!fStringSources.IsNull()) HLTMessage(" - sources: \"%s\"", fStringSources.Data());
252 else HLTMessage(" - no sources");
253 if (SourcesResolved(1)<=0)
254 HLTMessage(" there are unresolved sources");
255 AliHLTConfiguration* pSrc=GetFirstSource();
257 HLTMessage(" source \"%s\" (%p) resolved", pSrc->GetName(), pSrc);
258 pSrc=GetNextSource();
262 int AliHLTConfiguration::GetArguments(const char*** pArgv)
264 // see header file for function documentation
268 if ((iResult=ExtractArguments())<0) {
269 HLTError("error extracting arguments for configuration %s", GetName());
272 } else if (fArgc<0) {
273 HLTError("previous argument extraction failed");
275 //HLTDebug("%s fArgc %d", GetName(), fArgc);
277 *pArgv=(const char**)fArgv;
279 HLTError("invalid parameter");
286 int AliHLTConfiguration::ExtractSources()
288 // see header file for function documentation
291 if (!fStringSources.IsNull()) {
292 vector<char*> tgtList;
293 fListSources.clear();
294 if ((iResult=InterpreteString(fStringSources.Data(), tgtList))>=0) {
295 fNofSources=tgtList.size();
296 vector<char*>::iterator element=tgtList.begin();
297 while ((element=tgtList.begin())!=tgtList.end()) {
298 if (fgConfigurationHandler) {
299 AliHLTConfiguration* pConf=fgConfigurationHandler->FindConfiguration(*element);
301 HLTDebug("source \"%s\" inserted", pConf->GetName());
302 fListSources.push_back(pConf);
304 HLTError("can not find source \"%s\"", (*element));
307 } else if (iResult>=0) {
309 HLTFatal("global configuration handler not initialized, can not resolve sources");
312 tgtList.erase(element);
314 fListSrcElement=fListSources.begin();
320 int AliHLTConfiguration::ExtractArguments()
322 // see header file for function documentation
324 if (!fArguments.IsNull()) {
325 vector<char*> tgtList;
326 if ((iResult=InterpreteString(fArguments, tgtList))>=0) {
327 fArgc=tgtList.size();
328 //HLTDebug("configuration %s: extracted %d arguments from \"%s\"", GetName(), fArgc, fArguments);
330 fArgv = new char*[fArgc];
332 vector<char*>::iterator element=tgtList.begin();
334 while (element!=tgtList.end()) {
335 //HLTDebug("assign arguments %d (%s)", i, *element);
336 fArgv[i++]=(*element);
345 // there are zero arguments
351 int AliHLTConfiguration::InterpreteString(const char* arg, vector<char*>& argList)
353 // see header file for function documentation
356 //HLTDebug("interprete \"%s\"", arg);
361 //HLTDebug("%d %x", i, arg[i]);
362 if (arg[i]=='\'' && bQuote==0) {
364 } else if (arg[i]==0 ||
365 (arg[i]==' ' && bQuote==0) ||
366 (arg[i]=='\'' && bQuote==1)) {
369 char* pEntry= new char[i-prec+1];
371 strncpy(pEntry, &arg[prec], i-prec);
372 pEntry[i-prec]=0; // terminate string
373 //HLTDebug("create string \"%s\", insert at %d", pEntry, argList.size());
374 argList.push_back(pEntry);
379 } else if (prec==-1) prec=i;
380 } while (arg[i++]!=0 && iResult>=0);
387 int AliHLTConfiguration::FollowDependency(const char* id, TList* pTgtList)
389 // see header file for function documentation
392 AliHLTConfiguration* pDep=NULL;
393 if ((pDep=GetSource(id))!=NULL) {
394 if (pTgtList) pTgtList->Add(pDep);
397 pDep=GetFirstSource();
398 while (pDep && iResult==0) {
399 if ((iResult=pDep->FollowDependency(id, pTgtList))>0) {
400 if (pTgtList) pTgtList->AddFirst(pDep);
403 pDep=GetNextSource();
412 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
414 /** ROOT macro for the implementation of ROOT specific class methods */
417 AliHLTTask::AliHLTTask()
419 fpConfiguration(NULL),
424 fpBlockDataArray(NULL),
425 fBlockDataArraySize(0)
427 // see header file for function documentation
430 AliHLTTask::AliHLTTask(AliHLTConfiguration* pConf)
432 fpConfiguration(pConf),
437 fpBlockDataArray(NULL),
438 fBlockDataArraySize(0)
440 // see header file for function documentation
443 AliHLTTask::AliHLTTask(const AliHLTTask&)
447 fpConfiguration(NULL),
452 fpBlockDataArray(NULL),
453 fBlockDataArraySize(0)
455 HLTFatal("copy constructor untested");
458 AliHLTTask& AliHLTTask::operator=(const AliHLTTask&)
460 // see header file for function documentation
461 HLTFatal("assignment operator untested");
465 AliHLTTask::~AliHLTTask()
467 if (fpComponent) delete fpComponent;
469 if (fpBlockDataArray) delete[] fpBlockDataArray;
470 fpBlockDataArray=NULL;
473 int AliHLTTask::Init(AliHLTConfiguration* pConf, AliHLTComponentHandler* pCH)
475 // see header file for function documentation
477 if (fpConfiguration!=NULL && pConf!=NULL && fpConfiguration!=pConf) {
478 HLTWarning("overriding existing reference to configuration object %p (%s) by %p",
479 fpConfiguration, GetName(), pConf);
481 if (pConf!=NULL) fpConfiguration=pConf;
482 if (fpConfiguration) {
485 const char** argv=NULL;
486 if ((iResult=fpConfiguration->GetArguments(&argv))>=0) {
487 argc=iResult; // just to make it clear
488 // TODO: we have to think about the optional environment parameter,
489 // currently just set to NULL.
490 iResult=pCH->CreateComponent(fpConfiguration->GetComponentID(), NULL, argc, argv, fpComponent);
491 if (fpComponent || iResult<=0) {
493 HLTError("can not find component \"%s\" (%d)", fpConfiguration->GetComponentID(), iResult);
496 HLTError("can not get argument list for configuration %s (%s)", fpConfiguration->GetName(), fpConfiguration->GetComponentID());
500 HLTError("component handler instance needed for task initialization");
504 HLTError("configuration object instance needed for task initialization");
510 int AliHLTTask::Deinit()
512 // see header file for function documentation
514 AliHLTComponent* pComponent=GetComponent();
517 pComponent->Deinit();
520 HLTWarning("task %s (%p) doesn't seem to be in initialized", GetName(), this);
525 const char *AliHLTTask::GetName() const
527 // see header file for function documentation
529 return fpConfiguration->GetName();
530 return TObject::GetName();
533 AliHLTConfiguration* AliHLTTask::GetConf() const
535 // see header file for function documentation
536 return fpConfiguration;
539 AliHLTComponent* AliHLTTask::GetComponent() const
541 // see header file for function documentation
545 AliHLTTask* AliHLTTask::FindDependency(const char* id)
547 // see header file for function documentation
548 AliHLTTask* pTask=NULL;
550 pTask=(AliHLTTask*)fListDependencies.FindObject(id);
555 int AliHLTTask::FollowDependency(const char* id, TList* pTgtList)
557 // see header file for function documentation
560 AliHLTTask* pDep=NULL;
561 if ((pDep=(AliHLTTask*)fListDependencies.FindObject(id))!=NULL) {
562 if (pTgtList) pTgtList->Add(pDep);
565 TObjLink* lnk=fListDependencies.FirstLink();
566 while (lnk && iResult==0) {
567 pDep=(AliHLTTask*)lnk->GetObject();
569 if ((iResult=pDep->FollowDependency(id, pTgtList))>0) {
570 if (pTgtList) pTgtList->AddFirst(pDep);
585 void AliHLTTask::PrintDependencyTree(const char* id, int bFromConfiguration)
587 // see header file for function documentation
588 HLTLogKeyword("task dependencies");
591 if (bFromConfiguration) {
593 iResult=fpConfiguration->FollowDependency(id, &tgtList);
597 iResult=FollowDependency(id, &tgtList);
599 HLTMessage(" task \"%s\": dependency level %d ", GetName(), iResult);
600 TObjLink* lnk=tgtList.FirstLink();
602 char* pSpace = new char[iResult+1];
604 memset(pSpace, 32, iResult);
607 TObject* obj=lnk->GetObject();
608 HLTMessage(" %s^-- %s ", &pSpace[i--], obj->GetName());
618 int AliHLTTask::SetDependency(AliHLTTask* pDep)
620 // see header file for function documentation
623 if (FindDependency(pDep->GetName())==NULL) {
624 fListDependencies.Add(pDep);
634 int AliHLTTask::CheckDependencies()
636 // see header file for function documentation
638 AliHLTConfiguration* pSrc=fpConfiguration->GetFirstSource();
640 if (FindDependency(pSrc->GetName())==NULL) {
641 //HLTDebug("dependency \"%s\" unresolved", pSrc->GetName());
644 pSrc=fpConfiguration->GetNextSource();
650 int AliHLTTask::Depends(AliHLTTask* pTask)
652 // see header file for function documentation
655 if (fpConfiguration) {
656 iResult=fpConfiguration->GetSource(pTask->GetName())!=NULL;
658 //HLTDebug("task \"%s\" depends on \"%s\"", GetName(), pTask->GetName());
660 //HLTDebug("task \"%s\" independend of \"%s\"", GetName(), pTask->GetName());
671 AliHLTTask* AliHLTTask::FindTarget(const char* id)
673 // see header file for function documentation
674 AliHLTTask* pTask=NULL;
676 pTask=(AliHLTTask*)fListTargets.FindObject(id);
681 int AliHLTTask::SetTarget(AliHLTTask* pTgt)
683 // see header file for function documentation
686 if (FindTarget(pTgt->GetName())==NULL) {
687 fListTargets.Add(pTgt);
697 int AliHLTTask::StartRun()
699 // see header file for function documentation
701 int iNofInputDataBlocks=0;
702 AliHLTComponent* pComponent=GetComponent();
704 // determine the number of input data blocks provided from the source tasks
705 TObjLink* lnk=fListDependencies.FirstLink();
706 while (lnk && iResult>=0) {
707 AliHLTTask* pSrcTask=(AliHLTTask*)lnk->GetObject();
709 if ((iResult=pSrcTask->GetNofMatchingDataTypes(this))>0) {
710 iNofInputDataBlocks+=iResult;
711 } else if (iResult==0) {
712 HLTWarning("source task %s (%p) does not provide any matching data type for task %s (%p)", pSrcTask->GetName(), pSrcTask, GetName(), this);
714 HLTError("task %s (%p): error getting matching data types for source task %s (%p)", GetName(), this, pSrcTask->GetName(), pSrcTask);
721 if (fpBlockDataArray) {
722 HLTWarning("block data array for task %s (%p) was not cleaned", GetName(), this);
723 delete [] fpBlockDataArray;
724 fpBlockDataArray=NULL;
725 fBlockDataArraySize=0;
729 // the initialization of the component is done by the ComponentHandler after creation
731 //iResult=Init( AliHLTComponentEnvironment* environ, void* environ_param, int argc, const char** argv );
733 // allocate internal task variables for bookkeeping aso.
734 // we allocate the BlockData array with at least one member
735 if (iNofInputDataBlocks==0) iNofInputDataBlocks=1;
736 fpBlockDataArray=new AliHLTComponentBlockData[iNofInputDataBlocks];
737 if (fpBlockDataArray) {
738 fBlockDataArraySize=iNofInputDataBlocks;
740 HLTError("memory allocation failed");
744 // allocate the data buffer, which controls the output buffer and subscriptions
746 fpDataBuffer=new AliHLTDataBuffer;
747 if (fpDataBuffer!=NULL) {
748 HLTDebug("created data buffer %p for task %s (%p)", fpDataBuffer, GetName(), this);
749 TObjLink* lnk=fListTargets.FirstLink();
750 while (lnk && iResult>=0) {
751 AliHLTTask* pTgtTask=(AliHLTTask*)lnk->GetObject();
753 if ((iResult=fpDataBuffer->SetConsumer(pTgtTask->GetComponent()))>=0) {
762 HLTFatal("can not create data buffer object, memory allocation failed");
768 HLTError("task %s (%p) does not have a component", GetName(), this);
774 int AliHLTTask::EndRun()
776 // see header file for function documentation
778 if (fpBlockDataArray) {
779 fBlockDataArraySize=0;
780 delete [] fpBlockDataArray;
783 HLTWarning("task %s (%p) doesn't seem to be in running mode", GetName(), this);
786 AliHLTDataBuffer* pBuffer=fpDataBuffer;
793 int AliHLTTask::ProcessTask(Int_t eventNo)
795 // see header file for function documentation
797 AliHLTComponent* pComponent=GetComponent();
798 if (pComponent && fpDataBuffer) {
799 HLTDebug("Processing task %s (%p) fpDataBuffer %p", GetName(), this, fpDataBuffer);
800 fpDataBuffer->Reset();
801 int iSourceDataBlock=0;
802 int iInputDataVolume=0;
804 int iNofInputDataBlocks=0;
805 /* TODO: the assumption of only one output data type per component is the current constraint
806 * later it should be checked how many output blocks of the source component match the input
807 * data types of the consumer component (GetNofMatchingDataBlocks). If one assumes that a
808 * certain output block is always been produced, the initialization could be done in the
809 * StartRun. Otherwise the fpBlockDataArray has to be adapted each time.
811 iNofInputDataBlocks=fListDependencies.GetSize(); // one block per source
812 // is not been used since the allocation was done in StartRun, but check the size
813 if (iNofInputDataBlocks>fBlockDataArraySize) {
814 HLTError("block data array too small");
817 AliHLTTask* pSrcTask=NULL;
818 TList subscribedTaskList;
819 TObjLink* lnk=fListDependencies.FirstLink();
821 // subscribe to all source tasks
822 while (lnk && iResult>=0) {
823 pSrcTask=(AliHLTTask*)lnk->GetObject();
825 int iMatchingDB=pSrcTask->GetNofMatchingDataBlocks(this);
826 if (iMatchingDB<=fBlockDataArraySize-iSourceDataBlock) {
827 if (fpBlockDataArray) {
828 if ((iResult=pSrcTask->Subscribe(this, &fpBlockDataArray[iSourceDataBlock],fBlockDataArraySize-iSourceDataBlock))>0) {
829 for (int i=0; i<iResult; i++) {
830 iInputDataVolume+=fpBlockDataArray[i+iSourceDataBlock].fSize;
831 // put the source task as many times into the list as it provides data blocks
832 // makes the bookkeeping for the data release easier
833 subscribedTaskList.Add(pSrcTask);
835 iSourceDataBlock+=iResult;
836 HLTDebug("Task %s (%p) successfully subscribed to %d data block(s) of task %s (%p)", GetName(), this, iResult, pSrcTask->GetName(), pSrcTask);
839 HLTError("Task %s (%p): subscription to task %s (%p) failed with error %d", GetName(), this, pSrcTask->GetName(), pSrcTask, iResult);
843 HLTFatal("Task %s (%p): BlockData array not allocated", GetName(), this);
847 HLTFatal("Task %s (%p): too little space in data block array for subscription to task %s (%p)", GetName(), this, pSrcTask->GetName(), pSrcTask);
848 HLTDebug("#data types=%d, array size=%d, current index=%d", iMatchingDB, fBlockDataArraySize, iSourceDataBlock);
852 HLTFatal("fatal internal error in ROOT list handling");
860 long unsigned int iConstBase=0;
861 double fInputMultiplier=0;
862 if (pComponent->GetComponentType()!=AliHLTComponent::kSink)
863 pComponent->GetOutputDataSize(iConstBase, fInputMultiplier);
864 int iOutputDataSize=int(fInputMultiplier*iInputDataVolume) + iConstBase;
865 //HLTDebug("task %s: reqired output size %d", GetName(), iOutputDataSize);
866 AliHLTUInt8_t* pTgtBuffer=NULL;
867 if (iOutputDataSize>0) pTgtBuffer=fpDataBuffer->GetTargetBuffer(iOutputDataSize);
868 //HLTDebug("provided raw buffer %p", pTgtBuffer);
869 AliHLTComponentEventData evtData;
870 AliHLTComponent::FillEventData(evtData);
871 evtData.fEventID=(AliHLTEventID_t)eventNo;
872 evtData.fBlockCnt=iSourceDataBlock;
873 AliHLTComponentTriggerData trigData;
874 AliHLTUInt32_t size=iOutputDataSize;
875 AliHLTUInt32_t outputBlockCnt=0;
876 AliHLTComponentBlockData* outputBlocks=NULL;
877 AliHLTComponentEventDoneData* edd;
878 if (pTgtBuffer!=NULL || iOutputDataSize==0) {
879 iResult=pComponent->ProcessEvent(evtData, fpBlockDataArray, trigData, pTgtBuffer, size, outputBlockCnt, outputBlocks, edd);
880 HLTDebug("task %s: component %s ProcessEvent finnished (%d): size=%d blocks=%d", GetName(), pComponent->GetComponentID(), iResult, size, outputBlockCnt);
881 if (iResult>=0 && pTgtBuffer) {
882 iResult=fpDataBuffer->SetSegments(pTgtBuffer, outputBlocks, outputBlockCnt);
885 HLTError("task %s: no target buffer available", GetName());
890 // now release all buffers which we have subscribed to
892 lnk=subscribedTaskList.FirstLink();
894 pSrcTask=(AliHLTTask*)lnk->GetObject();
897 if ((iTempRes=pSrcTask->Release(&fpBlockDataArray[iSourceDataBlock], this))>=0) {
898 HLTDebug("Task %s (%p) successfully released task %s (%p)", GetName(), this, pSrcTask->GetName(), pSrcTask);
900 HLTError("Task %s (%p): realease of task %s (%p) failed with error %d", GetName(), this, pSrcTask->GetName(), pSrcTask, iTempRes);
903 HLTFatal("task %s (%p): internal error in ROOT list handling", GetName(), this);
904 if (iResult>=0) iResult=-EFAULT;
906 subscribedTaskList.Remove(lnk);
907 lnk=subscribedTaskList.FirstLink();
910 if (subscribedTaskList.GetSize()>0) {
911 HLTError("task %s (%p): could not release all data buffers", GetName(), this);
914 HLTError("task %s (%p): internal failure (not initialized component %p, data buffer %p)", GetName(), this, fpComponent, fpDataBuffer);
920 int AliHLTTask::GetNofMatchingDataBlocks(const AliHLTTask* pConsumerTask) const
922 // see header file for function documentation
926 iResult=fpDataBuffer->FindMatchingDataBlocks(pConsumerTask->GetComponent(), NULL);
928 HLTFatal("internal data buffer missing");
937 int AliHLTTask::GetNofMatchingDataTypes(const AliHLTTask* pConsumerTask) const
939 // see header file for function documentation
942 AliHLTComponent* pComponent=GetComponent();
945 HLTError("component not initialized");
949 iResult=pComponent->FindMatchingDataTypes(pConsumerTask->GetComponent(), NULL);
951 HLTFatal("task initialization failed");
960 int AliHLTTask::Subscribe(const AliHLTTask* pConsumerTask, AliHLTComponentBlockData* pBlockDesc, int iArraySize)
962 // see header file for function documentation
966 iResult=fpDataBuffer->Subscribe(pConsumerTask->GetComponent(), pBlockDesc, iArraySize);
968 HLTFatal("internal data buffer missing");
977 int AliHLTTask::Release(AliHLTComponentBlockData* pBlockDesc, const AliHLTTask* pConsumerTask)
979 // see header file for function documentation
981 if (pConsumerTask && pBlockDesc) {
983 iResult=fpDataBuffer->Release(pBlockDesc, pConsumerTask->GetComponent());
985 HLTFatal("internal data buffer missing");
994 void AliHLTTask::PrintStatus()
996 // see header file for function documentation
997 HLTLogKeyword("task properties");
998 AliHLTComponent* pComponent=GetComponent();
1000 HLTMessage(" component: %s (%p)", pComponent->GetComponentID(), pComponent);
1002 HLTMessage(" no component set!");
1004 if (fpConfiguration) {
1005 AliHLTConfiguration* pSrc=fpConfiguration->GetFirstSource();
1007 const char* pQualifier="unresolved";
1008 if (FindDependency(pSrc->GetName()))
1009 pQualifier="resolved";
1010 HLTMessage(" source: %s (%s)", pSrc->GetName(), pQualifier);
1011 pSrc=fpConfiguration->GetNextSource();
1013 TObjLink* lnk = fListTargets.FirstLink();
1015 TObject *obj = lnk->GetObject();
1016 HLTMessage(" target: %s", obj->GetName());
1020 HLTMessage(" task \"%s\" not initialized", GetName());
1024 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1026 /** ROOT macro for the implementation of ROOT specific class methods */
1027 ClassImp(AliHLTConfigurationHandler)
1029 AliHLTConfigurationHandler::AliHLTConfigurationHandler()
1031 // see header file for function documentation
1032 SetLocalLogLevel(kHLTLogInfo);
1035 AliHLTConfigurationHandler::~AliHLTConfigurationHandler()
1037 // see header file for function documentation
1038 TObjLink* lnk=fgListConfigurations.FirstLink();
1040 TObject* obj=lnk->GetObject();
1041 if (fgListConfigurations.FindObject(obj->GetName())==NULL) {
1042 HLTDebug("delete configuration \"%s\"", obj->GetName());
1049 int AliHLTConfigurationHandler::RegisterConfiguration(AliHLTConfiguration* pConf)
1051 // see header file for function documentation
1054 if (FindConfiguration(pConf->GetName()) == NULL) {
1055 AliHLTConfiguration* pClone=new AliHLTConfiguration(*pConf);
1056 fgListConfigurations.Add(pClone);
1057 HLTDebug("configuration \"%s\" registered", pClone->GetName());
1059 // mark all configurations with unresolved dependencies for re-evaluation
1060 TObjLink* lnk=fgListConfigurations.FirstLink();
1062 AliHLTConfiguration* pSrc=(AliHLTConfiguration*)lnk->GetObject();
1063 if (pSrc && pSrc!=pClone && pSrc->SourcesResolved()!=1) {
1064 pSrc->InvalidateSources();
1070 HLTWarning("configuration \"%s\" already registered", pConf->GetName());
1078 int AliHLTConfigurationHandler::CreateConfiguration(const char* id, const char* component, const char* sources, const char* arguments)
1080 // see header file for function documentation
1082 AliHLTConfiguration* pConf= new AliHLTConfiguration(id, component, sources, arguments);
1084 // the configuration will be registered automatically, if this failes the configuration
1085 // is missing -> delete it
1086 if (FindConfiguration(id)==NULL) {
1092 HLTError("system error: object allocation failed");
1098 void AliHLTConfigurationHandler::PrintConfigurations()
1100 // see header file for function documentation
1101 HLTLogKeyword("configuration listing");
1102 HLTMessage("registered configurations:");
1103 TObjLink *lnk = fgListConfigurations.FirstLink();
1105 TObject *obj = lnk->GetObject();
1106 HLTMessage(" %s", obj->GetName());
1111 int AliHLTConfigurationHandler::RemoveConfiguration(const char* id)
1113 // see header file for function documentation
1116 AliHLTConfiguration* pConf=NULL;
1117 if ((pConf=FindConfiguration(id))!=NULL) {
1118 iResult=RemoveConfiguration(pConf);
1122 HLTWarning("can not find configuration \"%s\"", id);
1131 int AliHLTConfigurationHandler::RemoveConfiguration(AliHLTConfiguration* pConf)
1133 // see header file for function documentation
1136 // remove the configuration from the list
1137 HLTDebug("remove configuration \"%s\"", pConf->GetName());
1138 fgListConfigurations.Remove(pConf);
1139 // remove cross links in the remaining configurations
1140 TObjLink* lnk=fgListConfigurations.FirstLink();
1141 while (lnk && iResult>=0) {
1142 AliHLTConfiguration* pRem=(AliHLTConfiguration*)lnk->GetObject();
1144 pRem->InvalidateSource(pConf);
1154 AliHLTConfiguration* AliHLTConfigurationHandler::FindConfiguration(const char* id)
1156 // see header file for function documentation
1157 AliHLTConfiguration* pConf=NULL;
1159 pConf=(AliHLTConfiguration*)fgListConfigurations.FindObject(id);