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 AliHLTOUT.cxx
20 @author Matthias Richter
22 @brief The control class for HLTOUT data.
27 #include "AliHLTOUT.h"
28 #include "AliHLTMessage.h"
33 /** ROOT macro for the implementation of ROOT specific class methods */
36 AliHLTOUT::AliHLTOUT()
38 fSearchDataType(kAliHLTVoidDataType),
39 fSearchSpecification(kAliHLTVoidDataSpec),
40 fSearchHandlerType(AliHLTModuleAgent::kUnknownOutput),
41 fFlags(kSkipProcessed),
49 , fpObjectBuffer(NULL)
50 , fObjectBufferSize(0)
51 , fCurrentEventId(kAliHLTVoidEventID)
53 // see header file for class documentation
55 // refer to README to build package
57 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
60 AliHLTOUT::~AliHLTOUT()
62 // see header file for class documentation
63 if (CheckStatusFlag(kIsSubCollection)) {
64 fLog.LoggingVarargs(kHLTLogWarning, "AliHLTOUT", "~AliHLTOUT" , __FILE__ , __LINE__ , "severe internal error: collection has not been released, potential crash due to invalid pointer");
68 fLog.LoggingVarargs(kHLTLogWarning, "AliHLTOUT", "GetDataObject" , __FILE__ , __LINE__ , "data object has not been released, potential memory leak");
72 AliHLTOUT* AliHLTOUT::fgGlobalInstance=NULL;
76 // see header file for class documentation
79 // ignore if already initialized
80 if (fBlockDescList.size()>0) {
81 fLog.LoggingVarargs(kHLTLogWarning, "AliHLTOUT", "Init" , __FILE__ , __LINE__ , "instance %p already initialized, skipping ...", this);
85 SetStatusFlag(kCollecting);
86 if ((iResult=GenerateIndex())>=0) {
87 if ((iResult=InitHandlers())>=0) {
90 ClearStatusFlag(kCollecting);
94 int AliHLTOUT::GetNofDataBlocks()
96 // see header file for class documentation
97 return fBlockDescList.size();
100 int AliHLTOUT::SelectFirstDataBlock(AliHLTComponentDataType dt, AliHLTUInt32_t spec,
101 AliHLTModuleAgent::AliHLTOUTHandlerType handlerType,
104 // see header file for class documentation
107 fSearchSpecification=spec;
108 fSearchHandlerType=handlerType;
109 if (skipProcessed) SetStatusFlag(kSkipProcessed);
110 else ClearStatusFlag(kSkipProcessed);
111 return FindAndSelectDataBlock();
114 int AliHLTOUT::SelectNextDataBlock()
116 // see header file for class documentation
117 if (fCurrent>=fBlockDescList.size()) return -ENOENT;
119 return FindAndSelectDataBlock();
122 int AliHLTOUT::FindAndSelectDataBlock()
124 // see header file for class documentation
125 if (CheckStatusFlag(kLocked)) return -EPERM;
127 while (fCurrent<fBlockDescList.size() && iResult==-ENOENT) {
128 if (fBlockDescList[fCurrent]==fSearchDataType &&
129 (fSearchSpecification==kAliHLTVoidDataSpec || fBlockDescList[fCurrent]==fSearchSpecification) &&
130 (fSearchHandlerType==AliHLTModuleAgent::kUnknownOutput || FindHandlerDesc(fCurrent)==fSearchHandlerType) &&
131 (!CheckStatusFlag(kBlockSelection) || fBlockDescList[fCurrent].IsSelected()) &&
132 (!CheckStatusFlag(kSkipProcessed) || !fBlockDescList[fCurrent].IsProcessed())) {
133 iResult=fBlockDescList[fCurrent].GetIndex();
134 // TODO: check the byte order on the current system and the byte order of the
135 // data block, print warning when mismatch and user did not check
136 //AliHLTOUTByteOrder blockBO=CheckByteOrder();
139 if (blockBO!=fByteOrder) {
140 SetStatusFlag(kByteOrderWarning);
144 ClearStatusFlag(kByteOrderChecked);
146 // TODO: check the alignment on the current system and the alignment of the
147 // data block, print warning when mismatch and user did not check
148 ClearStatusFlag(kAlignmentChecked);
157 int AliHLTOUT::GetDataBlockDescription(AliHLTComponentDataType& dt, AliHLTUInt32_t& spec)
159 // see header file for class documentation
161 if (fCurrent<fBlockDescList.size()) {
163 dt=fBlockDescList[fCurrent];
164 spec=fBlockDescList[fCurrent];
169 const AliHLTOUT::AliHLTOUTHandlerListEntry& AliHLTOUT::GetDataBlockHandlerDesc()
171 // see header file for class documentation
172 return FindHandlerDesc(fCurrent);
175 AliHLTModuleAgent::AliHLTOUTHandlerType AliHLTOUT::GetDataBlockHandlerType()
177 // see header file for class documentation
178 AliHLTModuleAgent::AliHLTOUTHandlerDesc desc=FindHandlerDesc(fCurrent);
179 AliHLTModuleAgent::AliHLTOUTHandlerType type=desc;
183 AliHLTUInt32_t AliHLTOUT::GetDataBlockIndex()
185 // see header file for class documentation
186 if (fCurrent>=fBlockDescList.size()) return AliHLTOUTInvalidIndex;
187 return fBlockDescList[fCurrent].GetIndex();
190 int AliHLTOUT::GetDataBuffer(const AliHLTUInt8_t* &pBuffer, AliHLTUInt32_t& size)
192 // see header file for class documentation
196 if (fCurrent<fBlockDescList.size()) {
197 if ((iResult=fBlockDescList[fCurrent].GetDataBuffer(pBuffer, size))>=0) {
204 int AliHLTOUT::ReleaseDataBuffer(const AliHLTUInt8_t* pBuffer)
206 // see header file for class documentation
208 if (pBuffer==fpBuffer) {
211 fLog.LoggingVarargs(kHLTLogWarning, "AliHLTOUT", "ReleaseDataBuffer" , __FILE__ , __LINE__ , "buffer %p does not match the provided one %p", pBuffer, fpBuffer);
216 AliHLTModuleAgent* AliHLTOUT::GetAgent()
218 // see header file for class documentation
219 AliHLTModuleAgent* pAgent=NULL;
220 pAgent=FindHandlerDesc(fCurrent);
224 AliHLTOUTHandler* AliHLTOUT::GetHandler()
226 // see header file for class documentation
227 AliHLTOUTHandler* pHandler=NULL;
228 pHandler=FindHandlerDesc(fCurrent);
232 int AliHLTOUT::WriteESD(const AliHLTUInt8_t* /*pBuffer*/, AliHLTUInt32_t /*size*/, AliHLTComponentDataType /*dt*/, AliESDEvent* /*tgtesd*/) const
234 // see header file for class documentation
235 fLog.LoggingVarargs(kHLTLogWarning, "AliHLTOUT", "WriteESD" , __FILE__ , __LINE__ , "method not implemented in base class");
239 int AliHLTOUT::AddBlockDescriptor(const AliHLTOUTBlockDescriptor desc)
241 // see header file for class documentation
242 if (!CheckStatusFlag(kCollecting)) return -EPERM;
244 fBlockDescList.push_back(desc);
248 AliHLTOUT::AliHLTOUTByteOrder AliHLTOUT::CheckByteOrder()
250 // see header file for class documentation
251 if (fCurrent<fBlockDescList.size()) {
252 SetStatusFlag(kByteOrderChecked);
253 AliHLTOUT::AliHLTOUTByteOrder order=CheckBlockByteOrder(fBlockDescList[fCurrent].GetIndex());
256 return kInvalidByteOrder;
259 int AliHLTOUT::CheckAlignment(AliHLTOUT::AliHLTOUTDataType type)
261 // see header file for class documentation
262 if (fCurrent<fBlockDescList.size()) {
263 SetStatusFlag(kAlignmentChecked);
264 int alignment=CheckBlockAlignment(fBlockDescList[fCurrent].GetIndex(), type);
270 int AliHLTOUT::InitHandlers()
272 // see header file for class documentation
274 AliHLTOUTIndexList remnants;
276 for (int havedata=SelectFirstDataBlock(kAliHLTAnyDataType, kAliHLTVoidDataSpec); havedata>=0; havedata=SelectNextDataBlock()) {
278 remnants.push_back(GetDataBlockIndex());
279 AliHLTComponentDataType dt=kAliHLTVoidDataType;
280 AliHLTUInt32_t spec=kAliHLTVoidDataSpec;
281 if (GetDataBlockDescription(dt, spec)<0) break;
282 bool bHaveHandler=false;
283 for (AliHLTModuleAgent* pAgent=AliHLTModuleAgent::GetFirstAgent(); pAgent && iResult>=0; pAgent=AliHLTModuleAgent::GetNextAgent()) {
284 AliHLTModuleAgent::AliHLTOUTHandlerDesc handlerDesc;
285 if (pAgent->GetHandlerDescription(dt, spec, handlerDesc)>0) {
286 AliHLTOUTHandlerListEntry entry(pAgent->GetOutputHandler(dt, spec), handlerDesc, pAgent, GetDataBlockIndex());
287 InsertHandler(fDataHandlers, entry);
293 if (!bHaveHandler && (dt==kAliHLTDataTypeESDObject || dt==kAliHLTDataTypeESDTree)) {
294 // ESDs are handled by the framework
299 // warning if some of the data blocks are not selected by the kAliHLTAnyDataType
301 if (GetNofDataBlocks()>iCount) {
302 fLog.LoggingVarargs(kHLTLogWarning, "AliHLTOUT", "InitHandlers" , __FILE__ , __LINE__ , "incomplete data type in %d out of %d data block(s)", GetNofDataBlocks()-iCount, GetNofDataBlocks());
305 // warning if handler not found
306 if (remnants.size()>0) {
307 fLog.LoggingVarargs(kHLTLogWarning, "AliHLTOUT", "InitHandlers" , __FILE__ , __LINE__ , "no handlers found for %d data blocks out of %d", remnants.size(), iCount);
308 AliHLTOUTBlockDescriptorVector::iterator block=fBlockDescList.begin();
309 for (AliHLTOUTIndexList::iterator element=remnants.begin(); element!=remnants.end(); element++) {
310 for (int trials=0; trials<2; trials++) {
312 // we start searching the index from the current position in the block list
313 if ((*block).GetIndex()==*element) break;
314 } while ((++block)!=fBlockDescList.end());
315 if (block==fBlockDescList.end()) {
316 // rewind and try again
317 block=fBlockDescList.begin();
320 assert(block!=fBlockDescList.end());
321 if (block!=fBlockDescList.end()) {
322 //HLTDebug(" %s", AliHLTComponent::DataType2Text((AliHLTComponentDataType)*block).c_str());
329 int AliHLTOUT::InsertHandler(AliHLTOUTHandlerListEntryVector& list, const AliHLTOUTHandlerListEntry &entry)
331 // see header file for class documentation
333 AliHLTOUTHandlerListEntryVector::iterator element=list.begin();
334 for (; element!=list.end();
336 if (entry==(*element)) break;
338 if (element==list.end()) {
339 list.push_back(entry);
341 element->AddIndex(const_cast<AliHLTOUTHandlerListEntry&>(entry));
346 int AliHLTOUT::FillHandlerList(AliHLTOUTHandlerListEntryVector& list, AliHLTModuleAgent::AliHLTOUTHandlerType handlerType)
348 // see header file for class documentation
350 for (iResult=SelectFirstDataBlock(kAliHLTAnyDataType, kAliHLTVoidDataSpec, handlerType);
352 iResult=SelectNextDataBlock()) {
353 AliHLTComponentDataType dt=kAliHLTVoidDataType;
354 AliHLTUInt32_t spec=kAliHLTVoidDataSpec;
355 GetDataBlockDescription(dt, spec);
356 AliHLTOUTHandler* pHandler=GetHandler();
358 fLog.LoggingVarargs(kHLTLogWarning, "AliHLTOUT", "FillHandlerList" , __FILE__ , __LINE__ ,
359 "missing HLTOUT handler for block of type kChain: agent %s, data type %s, specification %#x, ... skipping data block",
360 GetAgent()?GetAgent()->GetModuleId():"invalid",
361 AliHLTComponent::DataType2Text(dt).c_str(), spec);
363 InsertHandler(list, GetDataBlockHandlerDesc());
366 // TODO: the return value of SelectFirst/NextDataBlock must be
367 // changed in order to avoid this check
368 if (iResult==-ENOENT) iResult=0;
373 int AliHLTOUT::RemoveEmptyDuplicateHandlers(AliHLTOUTHandlerListEntryVector& list)
375 // see header file for class documentation
377 AliHLTOUTHandlerListEntryVector::iterator element=list.begin();
378 while (element!=list.end()) {
379 if (element->IsEmpty()) {
380 AliHLTOUTHandler* pHandler=*element;
381 AliHLTModuleAgent* pAgent=*element;
382 AliHLTModuleAgent::AliHLTOUTHandlerDesc desc=*element;
383 if (FindHandler(list, desc)>=0) {
384 element=list.erase(element);
386 pAgent->DeleteOutputHandler(pHandler);
388 // we are already at the next element
397 int AliHLTOUT::FindHandler(AliHLTOUTHandlerListEntryVector& list, const AliHLTModuleAgent::AliHLTOUTHandlerDesc desc)
399 // see header file for class documentation
400 for (int i=0; i<(int)list.size(); i++) {
401 if (list[i]==desc) return i;
406 int AliHLTOUT::InvalidateBlocks(AliHLTOUTHandlerListEntryVector& list)
408 // see header file for class documentation
409 for (AliHLTOUTHandlerListEntryVector::iterator element=list.begin();
412 element->InvalidateBlocks();
417 const AliHLTOUT::AliHLTOUTHandlerListEntry& AliHLTOUT::FindHandlerDesc(AliHLTUInt32_t blockIndex)
419 // see header file for class documentation
420 if (blockIndex<fBlockDescList.size()) {
421 return fBlockDescList[blockIndex].GetHandlerDesc();
423 return const_cast<AliHLTOUT::AliHLTOUTHandlerListEntry&>(AliHLTOUT::AliHLTOUTHandlerListEntry::fgkVoidHandlerListEntry);
426 AliHLTOUT::AliHLTOUTHandlerListEntry::AliHLTOUTHandlerListEntry()
433 // see header file for class documentation
436 AliHLTOUT::AliHLTOUTHandlerListEntry::AliHLTOUTHandlerListEntry(AliHLTOUTHandler* pHandler,
437 AliHLTModuleAgent::AliHLTOUTHandlerDesc& handlerDesc,
438 AliHLTModuleAgent* pAgent,
439 AliHLTUInt32_t index)
442 fpHandlerDesc(new AliHLTModuleAgent::AliHLTOUTHandlerDesc),
446 // see header file for class documentation
447 *fpHandlerDesc=handlerDesc;
448 fBlocks.push_back(index);
451 AliHLTOUT::AliHLTOUTHandlerListEntry::AliHLTOUTHandlerListEntry(const AliHLTOUTHandlerListEntry& src)
453 fpHandler(src.fpHandler),
454 fpHandlerDesc(new AliHLTModuleAgent::AliHLTOUTHandlerDesc),
455 fpAgent(src.fpAgent),
458 // see header file for class documentation
459 *fpHandlerDesc=*src.fpHandlerDesc;
460 fBlocks.assign(src.fBlocks.begin(), src.fBlocks.end());
463 AliHLTOUT::AliHLTOUTHandlerListEntry::~AliHLTOUTHandlerListEntry()
465 // see header file for class documentation
466 if (fpHandlerDesc) delete fpHandlerDesc;
470 AliHLTOUT::AliHLTOUTHandlerListEntry& AliHLTOUT::AliHLTOUTHandlerListEntry::operator=(const AliHLTOUTHandlerListEntry& src)
472 // see header file for class documentation
473 fpHandler=src.fpHandler;
474 if (src.fpHandlerDesc)
475 *fpHandlerDesc=*src.fpHandlerDesc;
477 fBlocks.assign(src.fBlocks.begin(), src.fBlocks.end());
481 AliHLTUInt32_t AliHLTOUT::AliHLTOUTHandlerListEntry::operator[](int i) const
483 // see header file for class documentation
484 return (int)fBlocks.size()>i?fBlocks[i]:AliHLTOUTInvalidIndex;
487 bool AliHLTOUT::AliHLTOUTHandlerListEntry::operator==(const AliHLTOUTHandlerListEntry& entry) const
489 // see header file for class documentation
490 if (entry.fpHandler!=fpHandler || fpHandler==NULL) return false;
491 assert(entry.fpAgent==fpAgent);
492 if (entry.fpAgent!=fpAgent) return false;
496 bool AliHLTOUT::AliHLTOUTHandlerListEntry::operator==(const AliHLTModuleAgent::AliHLTOUTHandlerType handlerType) const
498 // see header file for class documentation
499 if (!fpHandlerDesc) return false;
500 return *fpHandlerDesc==handlerType;
503 bool AliHLTOUT::AliHLTOUTHandlerListEntry::operator==(const AliHLTModuleAgent::AliHLTOUTHandlerDesc desc) const
505 // see header file for class documentation
506 if (!fpHandlerDesc) return false;
507 return *fpHandlerDesc==desc;
510 void AliHLTOUT::AliHLTOUTHandlerListEntry::AddIndex(AliHLTOUT::AliHLTOUTHandlerListEntry &desc)
512 // see header file for class documentation
513 AliHLTOUTIndexList::iterator element;
514 for (element=desc.fBlocks.begin(); element!=desc.fBlocks.end(); element++) {
519 void AliHLTOUT::AliHLTOUTHandlerListEntry::AddIndex(AliHLTUInt32_t index)
521 // see header file for class documentation
522 fBlocks.push_back(index);
525 bool AliHLTOUT::AliHLTOUTHandlerListEntry::HasIndex(AliHLTUInt32_t index) const
527 // see header file for class documentation
528 AliHLTOUTIndexList::iterator element;
529 for (unsigned int i=0; i<fBlocks.size(); i++) {
530 if (fBlocks[i]==index) return true;
535 const AliHLTOUT::AliHLTOUTHandlerListEntry AliHLTOUT::AliHLTOUTHandlerListEntry::fgkVoidHandlerListEntry;
537 AliHLTUInt64_t AliHLTOUT::ByteSwap64(AliHLTUInt64_t src)
539 // see header file for class documentation
540 return ((src & 0xFFULL) << 56) |
541 ((src & 0xFF00ULL) << 40) |
542 ((src & 0xFF0000ULL) << 24) |
543 ((src & 0xFF000000ULL) << 8) |
544 ((src & 0xFF00000000ULL) >> 8) |
545 ((src & 0xFF0000000000ULL) >> 24) |
546 ((src & 0xFF000000000000ULL) >> 40) |
547 ((src & 0xFF00000000000000ULL) >> 56);
550 AliHLTUInt32_t AliHLTOUT::ByteSwap32(AliHLTUInt32_t src)
552 // see header file for class documentation
553 return ((src & 0xFFULL) << 24) |
554 ((src & 0xFF00ULL) << 8) |
555 ((src & 0xFF0000ULL) >> 8) |
556 ((src & 0xFF000000ULL) >> 24);
559 AliHLTOUT* AliHLTOUT::New(AliRawReader* pRawReader)
561 // see header file for class documentation
562 AliHLTOUT* instance=New("AliHLTOUTRawReader");
564 instance->SetParam(pRawReader);
569 AliHLTOUT* AliHLTOUT::New(TTree* pDigitTree, int event)
571 // see header file for class documentation
572 AliHLTOUT* instance=New("AliHLTOUTDigitReader");
574 instance->SetParam(pDigitTree, event);
579 AliHLTOUT* AliHLTOUT::New(const char* classname)
581 // see header file for class documentation
583 AliHLTOUT* instance=NULL;
586 ROOT::NewFunc_t pNewFunc=NULL;
588 pCl=TClass::GetClass(classname);
589 } while (!pCl && (iLibResult=gSystem->Load("libHLTrec.so"))==0);
591 if (pCl && (pNewFunc=pCl->GetNew())!=NULL) {
592 void* p=(*pNewFunc)(NULL);
594 instance=reinterpret_cast<AliHLTOUT*>(p);
596 log.Logging(kHLTLogError, "AliHLTOUT::New", "HLTOUT handling", "type cast to AliHLTOUT instance failed");
599 log.Logging(kHLTLogError, "AliHLTOUT::New", "HLTOUT handling", "can not create AliHLTOUT instance from class descriptor");
602 log.Logging(kHLTLogError, "AliHLTOUT::New", "HLTOUT handling", "can not find AliHLTOUT class descriptor");
605 log.Logging(kHLTLogError, "AliHLTOUT::New", "HLTOUT handling", "can not load libHLTrec library");
610 void AliHLTOUT::Delete(AliHLTOUT* pInstance)
612 // see header file for class documentation
613 if (!pInstance) return;
614 if (pInstance==fgGlobalInstance) return;
616 // check if the library is still there in order to have the
617 // destructor available
618 TClass* pCl1=TClass::GetClass("AliHLTOUTRawReader");
619 TClass* pCl2=TClass::GetClass("AliHLTOUTDigitReader");
620 if (!pCl1 && !pCl2) {
622 log.Logging(kHLTLogError, "AliHLTOUT::Delete", "HLTOUT handling", "potential memory leak: libHLTrec library not available, skipping destruction %p", pInstance);
629 void AliHLTOUT::SetParam(AliRawReader* /*pRawReader*/)
631 // see header file for class documentation
632 // default implementation, we should never get here
633 // this function can only be called from the class itsself and
634 // is intended to be used with the New functions. If we get into
635 // the default implementation there is a class mismatch.
637 fLog.LoggingVarargs(kHLTLogFatal, "AliHLTOUT", "SetParam" , __FILE__ , __LINE__ , "severe internal error: class mismatch");
640 void AliHLTOUT::SetParam(TTree* /*pDigitTree*/, int /*event*/)
642 // see header file for class documentation
643 // default implementation, we should never get here
644 // this function can only be called from the class itsself and
645 // is intended to be used with the New functions. If we get into
646 // the default implementation there is a class mismatch.
648 fLog.LoggingVarargs(kHLTLogFatal, "AliHLTOUT", "SetParam" , __FILE__ , __LINE__ , "severe internal error: class mismatch");
651 int AliHLTOUT::SelectDataBlock()
653 // see header file for class documentation
655 if (fCurrent>=fBlockDescList.size()) return 0;
656 fBlockDescList[fCurrent].Select(true);
657 EnableBlockSelection();
661 int AliHLTOUT::SelectDataBlocks(const AliHLTOUTHandlerListEntry* pHandlerEntry)
663 // see header file for class documentation
665 if (!pHandlerEntry) return 0;
667 AliHLTModuleAgent* pAgent=*pHandlerEntry;
669 log.Logging(kHLTLogDebug, "AliHLTOUT::SelectDataBlocks", "HLTOUT handling", "selecting blocks for handler %s", pAgent->GetModuleId());
670 AliHLTOUTBlockDescriptorVector::iterator element;
671 for (AliHLTOUTBlockDescriptorVector::iterator block=fBlockDescList.begin();
672 block!=fBlockDescList.end();
674 if (block->GetHandlerDesc()==*pHandlerEntry && pHandlerEntry->HasIndex(block->GetIndex())) {
676 log.Logging(kHLTLogDebug, "AliHLTOUT::SelectDataBlocks", "HLTOUT handling", " select block %s", AliHLTComponent::DataType2Text(*block).c_str());
678 log.Logging(kHLTLogDebug, "AliHLTOUT::SelectDataBlocks", "HLTOUT handling", " skip block %s", AliHLTComponent::DataType2Text(*block).c_str());
679 block->Select(false);
682 EnableBlockSelection();
684 // Matthias 2009-07-03 bugfix: the fCurrent position was not reset at that
685 // place. Also I think the data type and specification must be set in order
686 // to make SelectFirst/NextDataBlock working on the selected collection
688 AliHLTModuleAgent::AliHLTOUTHandlerDesc pHandlerDesc=*pHandlerEntry;
689 fSearchDataType=pHandlerDesc;
690 fSearchSpecification=kAliHLTVoidDataSpec;
691 fSearchHandlerType=pHandlerDesc;
697 int AliHLTOUT::EnableBlockSelection()
699 // see header file for class documentation
700 SetStatusFlag(kBlockSelection);
704 int AliHLTOUT::DisableBlockSelection()
706 // see header file for class documentation
707 ClearStatusFlag(kBlockSelection);
711 int AliHLTOUT::ResetBlockSelection()
713 // see header file for class documentation
714 for (AliHLTOUTBlockDescriptorVector::iterator block=fBlockDescList.begin();
715 block!=fBlockDescList.end();
717 block->Select(false);
722 int AliHLTOUT::MarkDataBlockProcessed()
724 // see header file for class documentation
726 if (fCurrent>=fBlockDescList.size()) return 0;
727 fBlockDescList[fCurrent].MarkProcessed();
731 int AliHLTOUT::MarkDataBlocksProcessed(const AliHLTOUTHandlerListEntry* pHandlerDesc)
733 // see header file for class documentation
735 if (!pHandlerDesc) return 0;
737 AliHLTOUTBlockDescriptorVector::iterator element;
738 for (AliHLTOUTBlockDescriptorVector::iterator block=fBlockDescList.begin();
739 block!=fBlockDescList.end();
741 if (block->GetHandlerDesc()==*pHandlerDesc && pHandlerDesc->HasIndex(block->GetIndex()))
742 block->MarkProcessed();
748 int AliHLTOUT::AddSubCollection(AliHLTOUT* pCollection)
750 // see header file for class documentation
752 if (!pCollection) return 0;
754 SetStatusFlag(kCollecting);
756 for (index=pCollection->SelectFirstDataBlock();
758 index=pCollection->SelectNextDataBlock()) {
759 AliHLTComponentDataType dt=kAliHLTVoidDataType;
760 AliHLTUInt32_t spec=kAliHLTVoidDataSpec;
761 pCollection->GetDataBlockDescription(dt, spec);
762 AliHLTOUTBlockDescriptor desc(dt, spec, index, pCollection);
763 AddBlockDescriptor(desc);
767 if (CheckStatusFlag(kIsSubCollection)) {
768 fLog.LoggingVarargs(kHLTLogWarning, "AliHLTOUT", "AddSubCollection" , __FILE__ , __LINE__ , "HLTOUT object %p has already been added as sub-collection", pCollection);
770 pCollection->SetStatusFlag(kIsSubCollection);
773 ClearStatusFlag(kCollecting);
778 int AliHLTOUT::ReleaseSubCollection(AliHLTOUT* pCollection)
780 // see header file for class documentation
782 if (!pCollection) return 0;
784 AliHLTOUTBlockDescriptorVector::iterator block=fBlockDescList.begin();
785 while (block!=fBlockDescList.end()) {
786 if ((*block)==pCollection) {
787 block=fBlockDescList.erase(block);
792 pCollection->ClearStatusFlag(kIsSubCollection);
797 int AliHLTOUT::Reset()
799 // see header file for class documentation
801 AliHLTOUTPVector subCollections;
802 AliHLTOUTBlockDescriptorVector::iterator block=fBlockDescList.begin();
803 while (block!=fBlockDescList.end()) {
804 if (!((*block)==this)) {
805 AliHLTOUTPVector::iterator collection=subCollections.begin();
806 for (; collection!=subCollections.end(); collection++)
807 if((*block)==*collection) break;
808 if (collection==subCollections.end())
809 subCollections.push_back(block->GetCollection());
811 block=fBlockDescList.erase(block);
814 for (AliHLTOUTPVector::iterator collection=subCollections.begin();
815 collection!=subCollections.end(); collection++) {
816 (*collection)->Reset();
817 (*collection)->ClearStatusFlag(kIsSubCollection);
821 fCurrentEventId=kAliHLTVoidEventID;
826 int AliHLTOUT::ResetInput()
828 // default implementation, nothing to do
832 const AliHLTOUT::AliHLTOUTHandlerListEntry& AliHLTOUT::AliHLTOUTBlockDescriptor::GetHandlerDesc()
834 // see header file for class documentation
836 AliHLTOUTHandlerListEntryVector::iterator element=fpCollection->fDataHandlers.begin();
837 while (element!=fpCollection->fDataHandlers.end()) {
838 if (element->HasIndex(GetIndex())) {
844 return const_cast<AliHLTOUT::AliHLTOUTHandlerListEntry&>(AliHLTOUT::AliHLTOUTHandlerListEntry::fgkVoidHandlerListEntry);
847 TObject* AliHLTOUT::GetDataObject()
849 // see header file for class documentation
851 fLog.LoggingVarargs(kHLTLogWarning, "AliHLTOUT", "GetDataObject" , __FILE__ , __LINE__ , "data object has not been released, potential memory leak");
852 ReleaseDataBuffer(fpObjectBuffer);
858 if (GetDataBuffer(fpObjectBuffer, fObjectBufferSize)>=0) {
859 fpDataObject=AliHLTMessage::Extract(fpObjectBuffer, fObjectBufferSize);
861 fLog.LoggingVarargs(kHLTLogError, "AliHLTOUT", "GetDataObject" , __FILE__ , __LINE__ , "can not fetch data buffer");
867 int AliHLTOUT::ReleaseDataObject(TObject* pObject)
869 // see header file for class documentation
870 if (!pObject) return -EINVAL;
871 if (pObject!=fpDataObject) {
872 fLog.LoggingVarargs(kHLTLogError, "AliHLTOUT", "GetDataObject" , __FILE__ , __LINE__ , "attempt to release wrong data object %p, expected %p", pObject, fpDataObject);
878 ReleaseDataBuffer(fpObjectBuffer);
885 void AliHLTOUT::SetEventId(AliHLTUInt64_t id)
887 // see header file for class documentation
888 if (fCurrentEventId!=kAliHLTVoidEventID && fCurrentEventId!=id) {
889 fLog.LoggingVarargs(kHLTLogWarning, "AliHLTOUT", "SetEventId" , __FILE__ , __LINE__ , "event id was already set to 0x%llx, setting now to 0x%llx", fCurrentEventId, id);