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"
29 #include "AliHLTMisc.h"
34 /** ROOT macro for the implementation of ROOT specific class methods */
37 AliHLTOUT::AliHLTOUT()
39 fSearchDataType(kAliHLTVoidDataType),
40 fSearchSpecification(kAliHLTVoidDataSpec),
41 fSearchHandlerType(AliHLTModuleAgent::kUnknownOutput),
42 fFlags(kSkipProcessed),
50 , fpObjectBuffer(NULL)
51 , fObjectBufferSize(0)
52 , fCurrentEventId(kAliHLTVoidEventID)
54 // see header file for class documentation
56 // refer to README to build package
58 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
61 AliHLTOUT::~AliHLTOUT()
63 // see header file for class documentation
64 if (CheckStatusFlag(kIsSubCollection)) {
65 fLog.LoggingVarargs(kHLTLogWarning, "AliHLTOUT", "~AliHLTOUT" , __FILE__ , __LINE__ , "severe internal error: collection has not been released, potential crash due to invalid pointer");
69 fLog.LoggingVarargs(kHLTLogWarning, "AliHLTOUT", "GetDataObject" , __FILE__ , __LINE__ , "data object has not been released, potential memory leak");
73 AliHLTOUT* AliHLTOUT::fgGlobalInstance=NULL;
77 // see header file for class documentation
80 // ignore if already initialized
81 if (fBlockDescList.size()>0) {
82 fLog.LoggingVarargs(kHLTLogWarning, "AliHLTOUT", "Init" , __FILE__ , __LINE__ , "instance %p already initialized, skipping ...", this);
86 SetStatusFlag(kCollecting);
87 if ((iResult=GenerateIndex())>=0) {
88 if ((iResult=InitHandlers())>=0) {
91 ClearStatusFlag(kCollecting);
95 int AliHLTOUT::GetNofDataBlocks()
97 // see header file for class documentation
98 return fBlockDescList.size();
101 int AliHLTOUT::SelectFirstDataBlock(AliHLTComponentDataType dt, AliHLTUInt32_t spec,
102 AliHLTModuleAgent::AliHLTOUTHandlerType handlerType,
105 // see header file for class documentation
108 fSearchSpecification=spec;
109 fSearchHandlerType=handlerType;
110 if (skipProcessed) SetStatusFlag(kSkipProcessed);
111 else ClearStatusFlag(kSkipProcessed);
112 return FindAndSelectDataBlock();
115 int AliHLTOUT::SelectNextDataBlock()
117 // see header file for class documentation
118 if (fCurrent>=fBlockDescList.size()) return -ENOENT;
120 return FindAndSelectDataBlock();
123 int AliHLTOUT::FindAndSelectDataBlock()
125 // see header file for class documentation
126 if (CheckStatusFlag(kLocked)) return -EPERM;
128 while (fCurrent<fBlockDescList.size() && iResult==-ENOENT) {
129 if (fBlockDescList[fCurrent]==fSearchDataType &&
130 (fSearchSpecification==kAliHLTVoidDataSpec || fBlockDescList[fCurrent]==fSearchSpecification) &&
131 (fSearchHandlerType==AliHLTModuleAgent::kUnknownOutput || FindHandlerDesc(fCurrent)==fSearchHandlerType) &&
132 (!CheckStatusFlag(kBlockSelection) || fBlockDescList[fCurrent].IsSelected()) &&
133 (!CheckStatusFlag(kSkipProcessed) || !fBlockDescList[fCurrent].IsProcessed())) {
134 iResult=fBlockDescList[fCurrent].GetIndex();
135 // TODO: check the byte order on the current system and the byte order of the
136 // data block, print warning when mismatch and user did not check
137 //AliHLTOUTByteOrder blockBO=CheckByteOrder();
140 if (blockBO!=fByteOrder) {
141 SetStatusFlag(kByteOrderWarning);
145 ClearStatusFlag(kByteOrderChecked);
147 // TODO: check the alignment on the current system and the alignment of the
148 // data block, print warning when mismatch and user did not check
149 ClearStatusFlag(kAlignmentChecked);
158 int AliHLTOUT::GetDataBlockDescription(AliHLTComponentDataType& dt, AliHLTUInt32_t& spec)
160 // see header file for class documentation
162 if (fCurrent<fBlockDescList.size()) {
164 dt=fBlockDescList[fCurrent];
165 spec=fBlockDescList[fCurrent];
170 const AliHLTOUT::AliHLTOUTHandlerListEntry& AliHLTOUT::GetDataBlockHandlerDesc()
172 // see header file for class documentation
173 return FindHandlerDesc(fCurrent);
176 AliHLTModuleAgent::AliHLTOUTHandlerType AliHLTOUT::GetDataBlockHandlerType()
178 // see header file for class documentation
179 AliHLTModuleAgent::AliHLTOUTHandlerDesc desc=FindHandlerDesc(fCurrent);
180 AliHLTModuleAgent::AliHLTOUTHandlerType type=desc;
184 AliHLTUInt32_t AliHLTOUT::GetDataBlockIndex()
186 // see header file for class documentation
187 if (fCurrent>=fBlockDescList.size()) return AliHLTOUTInvalidIndex;
188 return fBlockDescList[fCurrent].GetIndex();
191 int AliHLTOUT::GetDataBuffer(const AliHLTUInt8_t* &pBuffer, AliHLTUInt32_t& size)
193 // see header file for class documentation
197 if (fCurrent<fBlockDescList.size()) {
198 if ((iResult=fBlockDescList[fCurrent].GetDataBuffer(pBuffer, size))>=0) {
205 int AliHLTOUT::ReleaseDataBuffer(const AliHLTUInt8_t* pBuffer)
207 // see header file for class documentation
209 if (pBuffer==fpBuffer) {
212 fLog.LoggingVarargs(kHLTLogWarning, "AliHLTOUT", "ReleaseDataBuffer" , __FILE__ , __LINE__ , "buffer %p does not match the provided one %p", pBuffer, fpBuffer);
217 AliHLTModuleAgent* AliHLTOUT::GetAgent()
219 // see header file for class documentation
220 AliHLTModuleAgent* pAgent=NULL;
221 pAgent=FindHandlerDesc(fCurrent);
225 AliHLTOUTHandler* AliHLTOUT::GetHandler()
227 // see header file for class documentation
228 AliHLTOUTHandler* pHandler=NULL;
229 pHandler=FindHandlerDesc(fCurrent);
233 int AliHLTOUT::WriteESD(const AliHLTUInt8_t* /*pBuffer*/, AliHLTUInt32_t /*size*/, AliHLTComponentDataType /*dt*/, AliESDEvent* /*tgtesd*/) const
235 // see header file for class documentation
236 fLog.LoggingVarargs(kHLTLogWarning, "AliHLTOUT", "WriteESD" , __FILE__ , __LINE__ , "method not implemented in base class");
240 int AliHLTOUT::AddBlockDescriptor(const AliHLTOUTBlockDescriptor desc)
242 // see header file for class documentation
243 if (!CheckStatusFlag(kCollecting)) return -EPERM;
245 fBlockDescList.push_back(desc);
249 AliHLTOUT::AliHLTOUTByteOrder AliHLTOUT::CheckByteOrder()
251 // see header file for class documentation
252 if (fCurrent<fBlockDescList.size()) {
253 SetStatusFlag(kByteOrderChecked);
254 AliHLTOUT::AliHLTOUTByteOrder order=CheckBlockByteOrder(fBlockDescList[fCurrent].GetIndex());
257 return kInvalidByteOrder;
260 int AliHLTOUT::CheckAlignment(AliHLTOUT::AliHLTOUTDataType type)
262 // see header file for class documentation
263 if (fCurrent<fBlockDescList.size()) {
264 SetStatusFlag(kAlignmentChecked);
265 int alignment=CheckBlockAlignment(fBlockDescList[fCurrent].GetIndex(), type);
271 int AliHLTOUT::InitHandlers()
273 // see header file for class documentation
275 AliHLTOUTIndexList remnants;
277 for (int havedata=SelectFirstDataBlock(kAliHLTAnyDataType, kAliHLTVoidDataSpec); havedata>=0; havedata=SelectNextDataBlock()) {
279 remnants.push_back(GetDataBlockIndex());
280 AliHLTComponentDataType dt=kAliHLTVoidDataType;
281 AliHLTUInt32_t spec=kAliHLTVoidDataSpec;
282 if (GetDataBlockDescription(dt, spec)<0) break;
283 bool bHaveHandler=false;
284 for (AliHLTModuleAgent* pAgent=AliHLTModuleAgent::GetFirstAgent(); pAgent && iResult>=0; pAgent=AliHLTModuleAgent::GetNextAgent()) {
285 AliHLTModuleAgent::AliHLTOUTHandlerDesc handlerDesc;
286 if (pAgent->GetHandlerDescription(dt, spec, handlerDesc)>0) {
287 AliHLTOUTHandlerListEntry entry(pAgent->GetOutputHandler(dt, spec), handlerDesc, pAgent, GetDataBlockIndex());
288 InsertHandler(fDataHandlers, entry);
294 if (!bHaveHandler && (dt==kAliHLTDataTypeESDObject || dt==kAliHLTDataTypeESDTree)) {
295 // ESDs are handled by the framework
300 // warning if some of the data blocks are not selected by the kAliHLTAnyDataType
302 if (GetNofDataBlocks()>iCount) {
303 fLog.LoggingVarargs(kHLTLogWarning, "AliHLTOUT", "InitHandlers" , __FILE__ , __LINE__ , "incomplete data type in %d out of %d data block(s)", GetNofDataBlocks()-iCount, GetNofDataBlocks());
306 // warning if handler not found
307 if (remnants.size()>0) {
308 fLog.LoggingVarargs(kHLTLogWarning, "AliHLTOUT", "InitHandlers" , __FILE__ , __LINE__ , "no handlers found for %d data blocks out of %d", remnants.size(), iCount);
309 AliHLTOUTBlockDescriptorVector::iterator block=fBlockDescList.begin();
310 for (AliHLTOUTIndexList::iterator element=remnants.begin(); element!=remnants.end(); element++) {
311 for (int trials=0; trials<2; trials++) {
313 // we start searching the index from the current position in the block list
314 if ((*block).GetIndex()==*element) break;
315 } while ((++block)!=fBlockDescList.end());
316 if (block==fBlockDescList.end()) {
317 // rewind and try again
318 block=fBlockDescList.begin();
321 assert(block!=fBlockDescList.end());
322 if (block!=fBlockDescList.end()) {
323 //HLTDebug(" %s", AliHLTComponent::DataType2Text((AliHLTComponentDataType)*block).c_str());
330 int AliHLTOUT::InsertHandler(AliHLTOUTHandlerListEntryVector& list, const AliHLTOUTHandlerListEntry &entry)
332 // see header file for class documentation
334 AliHLTOUTHandlerListEntryVector::iterator element=list.begin();
335 for (; element!=list.end();
337 if (entry==(*element)) break;
339 if (element==list.end()) {
340 list.push_back(entry);
342 element->AddIndex(const_cast<AliHLTOUTHandlerListEntry&>(entry));
347 int AliHLTOUT::FillHandlerList(AliHLTOUTHandlerListEntryVector& list, AliHLTModuleAgent::AliHLTOUTHandlerType handlerType)
349 // see header file for class documentation
351 for (iResult=SelectFirstDataBlock(kAliHLTAnyDataType, kAliHLTVoidDataSpec, handlerType);
353 iResult=SelectNextDataBlock()) {
354 AliHLTComponentDataType dt=kAliHLTVoidDataType;
355 AliHLTUInt32_t spec=kAliHLTVoidDataSpec;
356 GetDataBlockDescription(dt, spec);
357 AliHLTOUTHandler* pHandler=GetHandler();
359 fLog.LoggingVarargs(kHLTLogWarning, "AliHLTOUT", "FillHandlerList" , __FILE__ , __LINE__ ,
360 "missing HLTOUT handler for block of type kChain: agent %s, data type %s, specification %#x, ... skipping data block",
361 GetAgent()?GetAgent()->GetModuleId():"invalid",
362 AliHLTComponent::DataType2Text(dt).c_str(), spec);
364 InsertHandler(list, GetDataBlockHandlerDesc());
367 // TODO: the return value of SelectFirst/NextDataBlock must be
368 // changed in order to avoid this check
369 if (iResult==-ENOENT) iResult=0;
374 int AliHLTOUT::RemoveEmptyDuplicateHandlers(AliHLTOUTHandlerListEntryVector& list)
376 // see header file for class documentation
378 AliHLTOUTHandlerListEntryVector::iterator element=list.begin();
379 while (element!=list.end()) {
380 if (element->IsEmpty()) {
381 AliHLTOUTHandler* pHandler=*element;
382 AliHLTModuleAgent* pAgent=*element;
383 AliHLTModuleAgent::AliHLTOUTHandlerDesc desc=*element;
384 if (FindHandler(list, desc)>=0) {
385 element=list.erase(element);
387 pAgent->DeleteOutputHandler(pHandler);
389 // we are already at the next element
398 int AliHLTOUT::FindHandler(AliHLTOUTHandlerListEntryVector& list, const AliHLTModuleAgent::AliHLTOUTHandlerDesc desc)
400 // see header file for class documentation
401 for (int i=0; i<(int)list.size(); i++) {
402 if (list[i]==desc) return i;
407 int AliHLTOUT::InvalidateBlocks(AliHLTOUTHandlerListEntryVector& list)
409 // see header file for class documentation
410 for (AliHLTOUTHandlerListEntryVector::iterator element=list.begin();
413 element->InvalidateBlocks();
418 const AliHLTOUT::AliHLTOUTHandlerListEntry& AliHLTOUT::FindHandlerDesc(AliHLTUInt32_t blockIndex)
420 // see header file for class documentation
421 if (blockIndex<fBlockDescList.size()) {
422 return fBlockDescList[blockIndex].GetHandlerDesc();
424 return const_cast<AliHLTOUT::AliHLTOUTHandlerListEntry&>(AliHLTOUT::AliHLTOUTHandlerListEntry::fgkVoidHandlerListEntry);
427 AliHLTOUT::AliHLTOUTHandlerListEntry::AliHLTOUTHandlerListEntry()
434 // see header file for class documentation
437 AliHLTOUT::AliHLTOUTHandlerListEntry::AliHLTOUTHandlerListEntry(AliHLTOUTHandler* pHandler,
438 AliHLTModuleAgent::AliHLTOUTHandlerDesc& handlerDesc,
439 AliHLTModuleAgent* pAgent,
440 AliHLTUInt32_t index)
443 fpHandlerDesc(new AliHLTModuleAgent::AliHLTOUTHandlerDesc),
447 // see header file for class documentation
448 *fpHandlerDesc=handlerDesc;
449 fBlocks.push_back(index);
452 AliHLTOUT::AliHLTOUTHandlerListEntry::AliHLTOUTHandlerListEntry(const AliHLTOUTHandlerListEntry& src)
454 fpHandler(src.fpHandler),
455 fpHandlerDesc(new AliHLTModuleAgent::AliHLTOUTHandlerDesc),
456 fpAgent(src.fpAgent),
459 // see header file for class documentation
460 *fpHandlerDesc=*src.fpHandlerDesc;
461 fBlocks.assign(src.fBlocks.begin(), src.fBlocks.end());
464 AliHLTOUT::AliHLTOUTHandlerListEntry::~AliHLTOUTHandlerListEntry()
466 // see header file for class documentation
467 if (fpHandlerDesc) delete fpHandlerDesc;
471 AliHLTOUT::AliHLTOUTHandlerListEntry& AliHLTOUT::AliHLTOUTHandlerListEntry::operator=(const AliHLTOUTHandlerListEntry& src)
473 // see header file for class documentation
474 fpHandler=src.fpHandler;
475 if (src.fpHandlerDesc)
476 *fpHandlerDesc=*src.fpHandlerDesc;
478 fBlocks.assign(src.fBlocks.begin(), src.fBlocks.end());
482 AliHLTUInt32_t AliHLTOUT::AliHLTOUTHandlerListEntry::operator[](int i) const
484 // see header file for class documentation
485 return (int)fBlocks.size()>i?fBlocks[i]:AliHLTOUTInvalidIndex;
488 bool AliHLTOUT::AliHLTOUTHandlerListEntry::operator==(const AliHLTOUTHandlerListEntry& entry) const
490 // see header file for class documentation
491 if (entry.fpHandler!=fpHandler || fpHandler==NULL) return false;
492 assert(entry.fpAgent==fpAgent);
493 if (entry.fpAgent!=fpAgent) return false;
497 bool AliHLTOUT::AliHLTOUTHandlerListEntry::operator==(const AliHLTModuleAgent::AliHLTOUTHandlerType handlerType) const
499 // see header file for class documentation
500 if (!fpHandlerDesc) return false;
501 return *fpHandlerDesc==handlerType;
504 bool AliHLTOUT::AliHLTOUTHandlerListEntry::operator==(const AliHLTModuleAgent::AliHLTOUTHandlerDesc desc) const
506 // see header file for class documentation
507 if (!fpHandlerDesc) return false;
508 return *fpHandlerDesc==desc;
511 void AliHLTOUT::AliHLTOUTHandlerListEntry::AddIndex(AliHLTOUT::AliHLTOUTHandlerListEntry &desc)
513 // see header file for class documentation
514 AliHLTOUTIndexList::iterator element;
515 for (element=desc.fBlocks.begin(); element!=desc.fBlocks.end(); element++) {
520 void AliHLTOUT::AliHLTOUTHandlerListEntry::AddIndex(AliHLTUInt32_t index)
522 // see header file for class documentation
523 fBlocks.push_back(index);
526 bool AliHLTOUT::AliHLTOUTHandlerListEntry::HasIndex(AliHLTUInt32_t index) const
528 // see header file for class documentation
529 AliHLTOUTIndexList::iterator element;
530 for (unsigned int i=0; i<fBlocks.size(); i++) {
531 if (fBlocks[i]==index) return true;
536 const AliHLTOUT::AliHLTOUTHandlerListEntry AliHLTOUT::AliHLTOUTHandlerListEntry::fgkVoidHandlerListEntry;
538 AliHLTUInt64_t AliHLTOUT::ByteSwap64(AliHLTUInt64_t src)
540 // see header file for class documentation
541 return ((src & 0xFFULL) << 56) |
542 ((src & 0xFF00ULL) << 40) |
543 ((src & 0xFF0000ULL) << 24) |
544 ((src & 0xFF000000ULL) << 8) |
545 ((src & 0xFF00000000ULL) >> 8) |
546 ((src & 0xFF0000000000ULL) >> 24) |
547 ((src & 0xFF000000000000ULL) >> 40) |
548 ((src & 0xFF00000000000000ULL) >> 56);
551 AliHLTUInt32_t AliHLTOUT::ByteSwap32(AliHLTUInt32_t src)
553 // see header file for class documentation
554 return ((src & 0xFFULL) << 24) |
555 ((src & 0xFF00ULL) << 8) |
556 ((src & 0xFF0000ULL) >> 8) |
557 ((src & 0xFF000000ULL) >> 24);
560 AliHLTOUT* AliHLTOUT::New(AliRawReader* pRawReader)
562 // see header file for class documentation
563 AliHLTOUT* instance=AliHLTMisc::LoadInstance((AliHLTOUT*)0, "AliHLTOUTRawReader", "libHLTrec.so");
565 instance->SetParam(pRawReader);
570 AliHLTOUT* AliHLTOUT::New(TTree* pDigitTree, int event)
572 // see header file for class documentation
573 AliHLTOUT* instance=AliHLTMisc::LoadInstance((AliHLTOUT*)0, "AliHLTOUTDigitReader", "libHLTrec.so");
575 instance->SetParam(pDigitTree, event);
580 AliHLTOUT* AliHLTOUT::New(const char* filename, int event)
582 // see header file for class documentation
583 AliHLTOUT* instance=AliHLTMisc::LoadInstance((AliHLTOUT*)0, "AliHLTOUTDigitReader", "libHLTrec.so");
585 instance->SetParam(filename, event);
590 void AliHLTOUT::Delete(AliHLTOUT* pInstance)
592 // see header file for class documentation
593 if (!pInstance) return;
594 if (pInstance==fgGlobalInstance) return;
596 // check if the library is still there in order to have the
597 // destructor available
598 TClass* pCl1=TClass::GetClass("AliHLTOUTRawReader");
599 TClass* pCl2=TClass::GetClass("AliHLTOUTDigitReader");
600 if (!pCl1 && !pCl2) {
602 log.Logging(kHLTLogError, "AliHLTOUT::Delete", "HLTOUT handling", "potential memory leak: libHLTrec library not available, skipping destruction %p", pInstance);
609 void AliHLTOUT::SetParam(AliRawReader* /*pRawReader*/)
611 // see header file for class documentation
612 // default implementation, we should never get here
613 // this function can only be called from the class itsself and
614 // is intended to be used with the New functions. If we get into
615 // the default implementation there is a class mismatch.
617 fLog.LoggingVarargs(kHLTLogFatal, "AliHLTOUT", "SetParam" , __FILE__ , __LINE__ , "severe internal error: class mismatch");
620 void AliHLTOUT::SetParam(TTree* /*pDigitTree*/, int /*event*/)
622 // see header file for class documentation
623 // default implementation, we should never get here
624 // this function can only be called from the class itsself and
625 // is intended to be used with the New functions. If we get into
626 // the default implementation there is a class mismatch.
628 fLog.LoggingVarargs(kHLTLogFatal, "AliHLTOUT", "SetParam" , __FILE__ , __LINE__ , "severe internal error: class mismatch");
631 void AliHLTOUT::SetParam(const char* /*filename*/, int /*event*/)
633 // see header file for class documentation
634 // default implementation, we should never get here
635 // this function can only be called from the class itsself and
636 // is intended to be used with the New functions. If we get into
637 // the default implementation there is a class mismatch.
639 fLog.LoggingVarargs(kHLTLogFatal, "AliHLTOUT", "SetParam" , __FILE__ , __LINE__ , "severe internal error: class mismatch");
642 int AliHLTOUT::SelectDataBlock()
644 // see header file for class documentation
646 if (fCurrent>=fBlockDescList.size()) return 0;
647 fBlockDescList[fCurrent].Select(true);
648 EnableBlockSelection();
652 int AliHLTOUT::SelectDataBlocks(const AliHLTOUTHandlerListEntry* pHandlerEntry)
654 // see header file for class documentation
656 if (!pHandlerEntry) return 0;
658 AliHLTModuleAgent* pAgent=*pHandlerEntry;
660 log.Logging(kHLTLogDebug, "AliHLTOUT::SelectDataBlocks", "HLTOUT handling", "selecting blocks for handler %s", pAgent->GetModuleId());
661 AliHLTOUTBlockDescriptorVector::iterator element;
662 for (AliHLTOUTBlockDescriptorVector::iterator block=fBlockDescList.begin();
663 block!=fBlockDescList.end();
665 if (block->GetHandlerDesc()==*pHandlerEntry && pHandlerEntry->HasIndex(block->GetIndex())) {
667 log.Logging(kHLTLogDebug, "AliHLTOUT::SelectDataBlocks", "HLTOUT handling", " select block %s", AliHLTComponent::DataType2Text(*block).c_str());
669 log.Logging(kHLTLogDebug, "AliHLTOUT::SelectDataBlocks", "HLTOUT handling", " skip block %s", AliHLTComponent::DataType2Text(*block).c_str());
670 block->Select(false);
673 EnableBlockSelection();
675 // Matthias 2009-07-03 bugfix: the fCurrent position was not reset at that
676 // place. Also I think the data type and specification must be set in order
677 // to make SelectFirst/NextDataBlock working on the selected collection
679 AliHLTModuleAgent::AliHLTOUTHandlerDesc pHandlerDesc=*pHandlerEntry;
680 fSearchDataType=pHandlerDesc;
681 fSearchSpecification=kAliHLTVoidDataSpec;
682 fSearchHandlerType=pHandlerDesc;
688 int AliHLTOUT::EnableBlockSelection()
690 // see header file for class documentation
691 SetStatusFlag(kBlockSelection);
695 int AliHLTOUT::DisableBlockSelection()
697 // see header file for class documentation
698 ClearStatusFlag(kBlockSelection);
702 int AliHLTOUT::ResetBlockSelection()
704 // see header file for class documentation
705 for (AliHLTOUTBlockDescriptorVector::iterator block=fBlockDescList.begin();
706 block!=fBlockDescList.end();
708 block->Select(false);
713 int AliHLTOUT::MarkDataBlockProcessed()
715 // see header file for class documentation
717 if (fCurrent>=fBlockDescList.size()) return 0;
718 fBlockDescList[fCurrent].MarkProcessed();
722 int AliHLTOUT::MarkDataBlocksProcessed(const AliHLTOUTHandlerListEntry* pHandlerDesc)
724 // see header file for class documentation
726 if (!pHandlerDesc) return 0;
728 AliHLTOUTBlockDescriptorVector::iterator element;
729 for (AliHLTOUTBlockDescriptorVector::iterator block=fBlockDescList.begin();
730 block!=fBlockDescList.end();
732 if (block->GetHandlerDesc()==*pHandlerDesc && pHandlerDesc->HasIndex(block->GetIndex()))
733 block->MarkProcessed();
739 int AliHLTOUT::AddSubCollection(AliHLTOUT* pCollection)
741 // see header file for class documentation
743 if (!pCollection) return 0;
745 SetStatusFlag(kCollecting);
747 for (index=pCollection->SelectFirstDataBlock();
749 index=pCollection->SelectNextDataBlock()) {
750 AliHLTComponentDataType dt=kAliHLTVoidDataType;
751 AliHLTUInt32_t spec=kAliHLTVoidDataSpec;
752 pCollection->GetDataBlockDescription(dt, spec);
753 AliHLTOUTBlockDescriptor desc(dt, spec, index, pCollection);
754 AddBlockDescriptor(desc);
758 if (CheckStatusFlag(kIsSubCollection)) {
759 fLog.LoggingVarargs(kHLTLogWarning, "AliHLTOUT", "AddSubCollection" , __FILE__ , __LINE__ , "HLTOUT object %p has already been added as sub-collection", pCollection);
761 pCollection->SetStatusFlag(kIsSubCollection);
764 ClearStatusFlag(kCollecting);
769 int AliHLTOUT::ReleaseSubCollection(AliHLTOUT* pCollection)
771 // see header file for class documentation
773 if (!pCollection) return 0;
775 AliHLTOUTBlockDescriptorVector::iterator block=fBlockDescList.begin();
776 while (block!=fBlockDescList.end()) {
777 if ((*block)==pCollection) {
778 block=fBlockDescList.erase(block);
783 pCollection->ClearStatusFlag(kIsSubCollection);
788 int AliHLTOUT::Reset()
790 // see header file for class documentation
792 AliHLTOUTPVector subCollections;
793 AliHLTOUTBlockDescriptorVector::iterator block=fBlockDescList.begin();
794 while (block!=fBlockDescList.end()) {
795 if (!((*block)==this)) {
796 AliHLTOUTPVector::iterator collection=subCollections.begin();
797 for (; collection!=subCollections.end(); collection++)
798 if((*block)==*collection) break;
799 if (collection==subCollections.end())
800 subCollections.push_back(block->GetCollection());
802 block=fBlockDescList.erase(block);
805 for (AliHLTOUTPVector::iterator collection=subCollections.begin();
806 collection!=subCollections.end(); collection++) {
807 (*collection)->Reset();
808 (*collection)->ClearStatusFlag(kIsSubCollection);
812 fCurrentEventId=kAliHLTVoidEventID;
817 int AliHLTOUT::ResetInput()
819 // default implementation, nothing to do
823 const AliHLTOUT::AliHLTOUTHandlerListEntry& AliHLTOUT::AliHLTOUTBlockDescriptor::GetHandlerDesc()
825 // see header file for class documentation
827 AliHLTOUTHandlerListEntryVector::iterator element=fpCollection->fDataHandlers.begin();
828 while (element!=fpCollection->fDataHandlers.end()) {
829 if (element->HasIndex(GetIndex())) {
835 return const_cast<AliHLTOUT::AliHLTOUTHandlerListEntry&>(AliHLTOUT::AliHLTOUTHandlerListEntry::fgkVoidHandlerListEntry);
838 TObject* AliHLTOUT::GetDataObject()
840 // see header file for class documentation
842 fLog.LoggingVarargs(kHLTLogWarning, "AliHLTOUT", "GetDataObject" , __FILE__ , __LINE__ , "data object has not been released, potential memory leak");
843 ReleaseDataBuffer(fpObjectBuffer);
849 if (GetDataBuffer(fpObjectBuffer, fObjectBufferSize)>=0) {
850 fpDataObject=AliHLTMessage::Extract(fpObjectBuffer, fObjectBufferSize);
852 fLog.LoggingVarargs(kHLTLogError, "AliHLTOUT", "GetDataObject" , __FILE__ , __LINE__ , "can not fetch data buffer");
858 int AliHLTOUT::ReleaseDataObject(TObject* pObject)
860 // see header file for class documentation
861 if (!pObject) return -EINVAL;
862 if (pObject!=fpDataObject) {
863 fLog.LoggingVarargs(kHLTLogError, "AliHLTOUT", "GetDataObject" , __FILE__ , __LINE__ , "attempt to release wrong data object %p, expected %p", pObject, fpDataObject);
869 ReleaseDataBuffer(fpObjectBuffer);
876 void AliHLTOUT::SetEventId(AliHLTUInt64_t id)
878 // see header file for class documentation
879 if (fCurrentEventId!=kAliHLTVoidEventID && fCurrentEventId!=id) {
880 fLog.LoggingVarargs(kHLTLogWarning, "AliHLTOUT", "SetEventId" , __FILE__ , __LINE__ , "event id was already set to 0x%llx, setting now to 0x%llx", fCurrentEventId, id);