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) {
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();
310 element!=remnants.end() && block!=fBlockDescList.end();
312 for (int trials=0; trials<2; trials++) {
314 // we start searching the index from the current position in the block list
315 if ((*block).GetIndex()==*element) break;
316 } while ((++block)!=fBlockDescList.end());
317 if (block==fBlockDescList.end()) {
318 // rewind and try again
319 block=fBlockDescList.begin();
322 assert(block!=fBlockDescList.end());
328 int AliHLTOUT::InsertHandler(AliHLTOUTHandlerListEntryVector& list, const AliHLTOUTHandlerListEntry &entry)
330 // see header file for class documentation
332 AliHLTOUTHandlerListEntryVector::iterator element=list.begin();
333 for (; element!=list.end();
335 if (entry==(*element)) break;
337 if (element==list.end()) {
338 list.push_back(entry);
340 element->AddIndex(const_cast<AliHLTOUTHandlerListEntry&>(entry));
345 int AliHLTOUT::FillHandlerList(AliHLTOUTHandlerListEntryVector& list, AliHLTModuleAgent::AliHLTOUTHandlerType handlerType)
347 // see header file for class documentation
349 for (iResult=SelectFirstDataBlock(kAliHLTAnyDataType, kAliHLTVoidDataSpec, handlerType);
351 iResult=SelectNextDataBlock()) {
352 AliHLTComponentDataType dt=kAliHLTVoidDataType;
353 AliHLTUInt32_t spec=kAliHLTVoidDataSpec;
354 GetDataBlockDescription(dt, spec);
355 AliHLTOUTHandler* pHandler=GetHandler();
357 fLog.LoggingVarargs(kHLTLogWarning, "AliHLTOUT", "FillHandlerList" , __FILE__ , __LINE__ ,
358 "missing HLTOUT handler for block of type kChain: agent %s, data type %s, specification %#x, ... skipping data block",
359 GetAgent()?GetAgent()->GetModuleId():"invalid",
360 AliHLTComponent::DataType2Text(dt).c_str(), spec);
362 InsertHandler(list, GetDataBlockHandlerDesc());
365 // TODO: the return value of SelectFirst/NextDataBlock must be
366 // changed in order to avoid this check
367 if (iResult==-ENOENT) iResult=0;
372 int AliHLTOUT::RemoveEmptyDuplicateHandlers(AliHLTOUTHandlerListEntryVector& list)
374 // see header file for class documentation
376 AliHLTOUTHandlerListEntryVector::iterator element=list.begin();
377 while (element!=list.end()) {
378 if (element->IsEmpty()) {
379 AliHLTOUTHandler* pHandler=*element;
380 AliHLTModuleAgent* pAgent=*element;
381 AliHLTModuleAgent::AliHLTOUTHandlerDesc desc=*element;
382 if (FindHandler(list, desc)>=0) {
383 element=list.erase(element);
385 pAgent->DeleteOutputHandler(pHandler);
387 // we are already at the next element
396 int AliHLTOUT::FindHandler(AliHLTOUTHandlerListEntryVector& list, const AliHLTModuleAgent::AliHLTOUTHandlerDesc desc)
398 // see header file for class documentation
399 for (int i=0; i<(int)list.size(); i++) {
400 if (list[i]==desc) return i;
405 int AliHLTOUT::InvalidateBlocks(AliHLTOUTHandlerListEntryVector& list)
407 // see header file for class documentation
408 for (AliHLTOUTHandlerListEntryVector::iterator element=list.begin();
411 element->InvalidateBlocks();
416 const AliHLTOUT::AliHLTOUTHandlerListEntry& AliHLTOUT::FindHandlerDesc(AliHLTUInt32_t blockIndex)
418 // see header file for class documentation
419 if (blockIndex<fBlockDescList.size()) {
420 return fBlockDescList[blockIndex].GetHandlerDesc();
422 return const_cast<AliHLTOUT::AliHLTOUTHandlerListEntry&>(AliHLTOUT::AliHLTOUTHandlerListEntry::fgkVoidHandlerListEntry);
425 AliHLTOUT::AliHLTOUTHandlerListEntry::AliHLTOUTHandlerListEntry()
432 // see header file for class documentation
435 AliHLTOUT::AliHLTOUTHandlerListEntry::AliHLTOUTHandlerListEntry(AliHLTOUTHandler* pHandler,
436 AliHLTModuleAgent::AliHLTOUTHandlerDesc& handlerDesc,
437 AliHLTModuleAgent* pAgent,
438 AliHLTUInt32_t index)
441 fpHandlerDesc(new AliHLTModuleAgent::AliHLTOUTHandlerDesc),
445 // see header file for class documentation
446 *fpHandlerDesc=handlerDesc;
447 fBlocks.push_back(index);
450 AliHLTOUT::AliHLTOUTHandlerListEntry::AliHLTOUTHandlerListEntry(const AliHLTOUTHandlerListEntry& src)
452 fpHandler(src.fpHandler),
453 fpHandlerDesc(new AliHLTModuleAgent::AliHLTOUTHandlerDesc),
454 fpAgent(src.fpAgent),
457 // see header file for class documentation
458 *fpHandlerDesc=*src.fpHandlerDesc;
459 fBlocks.assign(src.fBlocks.begin(), src.fBlocks.end());
462 AliHLTOUT::AliHLTOUTHandlerListEntry::~AliHLTOUTHandlerListEntry()
464 // see header file for class documentation
465 if (fpHandlerDesc) delete fpHandlerDesc;
469 AliHLTOUT::AliHLTOUTHandlerListEntry& AliHLTOUT::AliHLTOUTHandlerListEntry::operator=(const AliHLTOUTHandlerListEntry& src)
471 // see header file for class documentation
472 fpHandler=src.fpHandler;
473 if (src.fpHandlerDesc)
474 *fpHandlerDesc=*src.fpHandlerDesc;
476 fBlocks.assign(src.fBlocks.begin(), src.fBlocks.end());
480 AliHLTUInt32_t AliHLTOUT::AliHLTOUTHandlerListEntry::operator[](int i) const
482 // see header file for class documentation
483 return (int)fBlocks.size()>i?fBlocks[i]:AliHLTOUTInvalidIndex;
486 bool AliHLTOUT::AliHLTOUTHandlerListEntry::operator==(const AliHLTOUTHandlerListEntry& entry) const
488 // see header file for class documentation
489 if (entry.fpHandler!=fpHandler || fpHandler==NULL) return false;
490 assert(entry.fpAgent==fpAgent);
491 if (entry.fpAgent!=fpAgent) return false;
495 bool AliHLTOUT::AliHLTOUTHandlerListEntry::operator==(const AliHLTModuleAgent::AliHLTOUTHandlerType handlerType) const
497 // see header file for class documentation
498 if (!fpHandlerDesc) return false;
499 return *fpHandlerDesc==handlerType;
502 bool AliHLTOUT::AliHLTOUTHandlerListEntry::operator==(const AliHLTModuleAgent::AliHLTOUTHandlerDesc desc) const
504 // see header file for class documentation
505 if (!fpHandlerDesc) return false;
506 return *fpHandlerDesc==desc;
509 void AliHLTOUT::AliHLTOUTHandlerListEntry::AddIndex(AliHLTOUT::AliHLTOUTHandlerListEntry &desc)
511 // see header file for class documentation
512 AliHLTOUTIndexList::iterator element;
513 for (element=desc.fBlocks.begin(); element!=desc.fBlocks.end(); element++) {
518 void AliHLTOUT::AliHLTOUTHandlerListEntry::AddIndex(AliHLTUInt32_t index)
520 // see header file for class documentation
521 fBlocks.push_back(index);
524 bool AliHLTOUT::AliHLTOUTHandlerListEntry::HasIndex(AliHLTUInt32_t index) const
526 // see header file for class documentation
527 AliHLTOUTIndexList::iterator element;
528 for (unsigned int i=0; i<fBlocks.size(); i++) {
529 if (fBlocks[i]==index) return true;
534 const AliHLTOUT::AliHLTOUTHandlerListEntry AliHLTOUT::AliHLTOUTHandlerListEntry::fgkVoidHandlerListEntry;
536 AliHLTUInt64_t AliHLTOUT::ByteSwap64(AliHLTUInt64_t src)
538 // see header file for class documentation
539 return ((src & 0xFFULL) << 56) |
540 ((src & 0xFF00ULL) << 40) |
541 ((src & 0xFF0000ULL) << 24) |
542 ((src & 0xFF000000ULL) << 8) |
543 ((src & 0xFF00000000ULL) >> 8) |
544 ((src & 0xFF0000000000ULL) >> 24) |
545 ((src & 0xFF000000000000ULL) >> 40) |
546 ((src & 0xFF00000000000000ULL) >> 56);
549 AliHLTUInt32_t AliHLTOUT::ByteSwap32(AliHLTUInt32_t src)
551 // see header file for class documentation
552 return ((src & 0xFFULL) << 24) |
553 ((src & 0xFF00ULL) << 8) |
554 ((src & 0xFF0000ULL) >> 8) |
555 ((src & 0xFF000000ULL) >> 24);
558 AliHLTOUT* AliHLTOUT::New(AliRawReader* pRawReader)
560 // see header file for class documentation
561 AliHLTOUT* instance=AliHLTMisc::LoadInstance((AliHLTOUT*)0, "AliHLTOUTRawReader", "libHLTrec.so");
563 instance->SetParam(pRawReader);
568 AliHLTOUT* AliHLTOUT::New(TTree* pDigitTree, int event)
570 // see header file for class documentation
571 AliHLTOUT* instance=AliHLTMisc::LoadInstance((AliHLTOUT*)0, "AliHLTOUTDigitReader", "libHLTrec.so");
573 instance->SetParam(pDigitTree, event);
578 AliHLTOUT* AliHLTOUT::New(const char* filename, int event)
580 // see header file for class documentation
581 AliHLTOUT* instance=AliHLTMisc::LoadInstance((AliHLTOUT*)0, "AliHLTOUTDigitReader", "libHLTrec.so");
583 instance->SetParam(filename, event);
588 void AliHLTOUT::Delete(AliHLTOUT* pInstance)
590 // see header file for class documentation
591 if (!pInstance) return;
592 if (pInstance==fgGlobalInstance) return;
594 // check if the library is still there in order to have the
595 // destructor available
596 TClass* pCl1=TClass::GetClass("AliHLTOUTRawReader");
597 TClass* pCl2=TClass::GetClass("AliHLTOUTDigitReader");
598 if (!pCl1 && !pCl2) {
600 log.Logging(kHLTLogError, "AliHLTOUT::Delete", "HLTOUT handling", "potential memory leak: libHLTrec library not available, skipping destruction %p", pInstance);
607 void AliHLTOUT::SetParam(AliRawReader* /*pRawReader*/)
609 // see header file for class documentation
610 // default implementation, we should never get here
611 // this function can only be called from the class itsself and
612 // is intended to be used with the New functions. If we get into
613 // the default implementation there is a class mismatch.
615 fLog.LoggingVarargs(kHLTLogFatal, "AliHLTOUT", "SetParam" , __FILE__ , __LINE__ , "severe internal error: class mismatch");
618 void AliHLTOUT::SetParam(TTree* /*pDigitTree*/, int /*event*/)
620 // see header file for class documentation
621 // default implementation, we should never get here
622 // this function can only be called from the class itsself and
623 // is intended to be used with the New functions. If we get into
624 // the default implementation there is a class mismatch.
626 fLog.LoggingVarargs(kHLTLogFatal, "AliHLTOUT", "SetParam" , __FILE__ , __LINE__ , "severe internal error: class mismatch");
629 void AliHLTOUT::SetParam(const char* /*filename*/, int /*event*/)
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 int AliHLTOUT::SelectDataBlock()
642 // see header file for class documentation
644 if (fCurrent>=fBlockDescList.size()) return 0;
645 fBlockDescList[fCurrent].Select(true);
646 EnableBlockSelection();
650 int AliHLTOUT::SelectDataBlocks(const AliHLTOUTHandlerListEntry* pHandlerEntry)
652 // see header file for class documentation
654 if (!pHandlerEntry) return 0;
656 AliHLTModuleAgent* pAgent=*pHandlerEntry;
658 log.Logging(kHLTLogDebug, "AliHLTOUT::SelectDataBlocks", "HLTOUT handling", "selecting blocks for handler %s", pAgent->GetModuleId());
659 AliHLTOUTBlockDescriptorVector::iterator element;
660 for (AliHLTOUTBlockDescriptorVector::iterator block=fBlockDescList.begin();
661 block!=fBlockDescList.end();
663 if (block->GetHandlerDesc()==*pHandlerEntry && pHandlerEntry->HasIndex(block->GetIndex())) {
665 log.Logging(kHLTLogDebug, "AliHLTOUT::SelectDataBlocks", "HLTOUT handling", " select block %s", AliHLTComponent::DataType2Text(*block).c_str());
667 log.Logging(kHLTLogDebug, "AliHLTOUT::SelectDataBlocks", "HLTOUT handling", " skip block %s", AliHLTComponent::DataType2Text(*block).c_str());
668 block->Select(false);
671 EnableBlockSelection();
673 // Matthias 2009-07-03 bugfix: the fCurrent position was not reset at that
674 // place. Also I think the data type and specification must be set in order
675 // to make SelectFirst/NextDataBlock working on the selected collection
677 AliHLTModuleAgent::AliHLTOUTHandlerDesc pHandlerDesc=*pHandlerEntry;
678 fSearchDataType=pHandlerDesc;
679 fSearchSpecification=kAliHLTVoidDataSpec;
680 fSearchHandlerType=pHandlerDesc;
686 int AliHLTOUT::EnableBlockSelection()
688 // see header file for class documentation
689 SetStatusFlag(kBlockSelection);
693 int AliHLTOUT::DisableBlockSelection()
695 // see header file for class documentation
696 ClearStatusFlag(kBlockSelection);
700 int AliHLTOUT::ResetBlockSelection()
702 // see header file for class documentation
703 for (AliHLTOUTBlockDescriptorVector::iterator block=fBlockDescList.begin();
704 block!=fBlockDescList.end();
706 block->Select(false);
711 int AliHLTOUT::MarkDataBlockProcessed()
713 // see header file for class documentation
715 if (fCurrent>=fBlockDescList.size()) return 0;
716 fBlockDescList[fCurrent].MarkProcessed();
720 int AliHLTOUT::MarkDataBlocksProcessed(const AliHLTOUTHandlerListEntry* pHandlerDesc)
722 // see header file for class documentation
724 if (!pHandlerDesc) return 0;
726 AliHLTOUTBlockDescriptorVector::iterator element;
727 for (AliHLTOUTBlockDescriptorVector::iterator block=fBlockDescList.begin();
728 block!=fBlockDescList.end();
730 if (block->GetHandlerDesc()==*pHandlerDesc && pHandlerDesc->HasIndex(block->GetIndex()))
731 block->MarkProcessed();
737 int AliHLTOUT::AddSubCollection(AliHLTOUT* pCollection)
739 // see header file for class documentation
741 if (!pCollection) return 0;
743 SetStatusFlag(kCollecting);
745 for (index=pCollection->SelectFirstDataBlock();
747 index=pCollection->SelectNextDataBlock()) {
748 AliHLTComponentDataType dt=kAliHLTVoidDataType;
749 AliHLTUInt32_t spec=kAliHLTVoidDataSpec;
750 pCollection->GetDataBlockDescription(dt, spec);
751 AliHLTOUTBlockDescriptor desc(dt, spec, index, pCollection);
752 AddBlockDescriptor(desc);
756 if (CheckStatusFlag(kIsSubCollection)) {
757 fLog.LoggingVarargs(kHLTLogWarning, "AliHLTOUT", "AddSubCollection" , __FILE__ , __LINE__ , "HLTOUT object %p has already been added as sub-collection", pCollection);
759 pCollection->SetStatusFlag(kIsSubCollection);
762 ClearStatusFlag(kCollecting);
767 int AliHLTOUT::ReleaseSubCollection(AliHLTOUT* pCollection)
769 // see header file for class documentation
771 if (!pCollection) return 0;
773 AliHLTOUTBlockDescriptorVector::iterator block=fBlockDescList.begin();
774 while (block!=fBlockDescList.end()) {
775 if ((*block)==pCollection) {
776 block=fBlockDescList.erase(block);
781 pCollection->ClearStatusFlag(kIsSubCollection);
786 int AliHLTOUT::Reset()
788 // see header file for class documentation
790 AliHLTOUTPVector subCollections;
791 AliHLTOUTBlockDescriptorVector::iterator block=fBlockDescList.begin();
792 while (block!=fBlockDescList.end()) {
793 if (!((*block)==this)) {
794 AliHLTOUTPVector::iterator collection=subCollections.begin();
795 for (; collection!=subCollections.end(); collection++)
796 if((*block)==*collection) break;
797 if (collection==subCollections.end())
798 subCollections.push_back(block->GetCollection());
800 block=fBlockDescList.erase(block);
803 for (AliHLTOUTPVector::iterator collection=subCollections.begin();
804 collection!=subCollections.end(); collection++) {
805 (*collection)->Reset();
806 (*collection)->ClearStatusFlag(kIsSubCollection);
810 fCurrentEventId=kAliHLTVoidEventID;
815 int AliHLTOUT::ResetInput()
817 // default implementation, nothing to do
821 const AliHLTOUT::AliHLTOUTHandlerListEntry& AliHLTOUT::AliHLTOUTBlockDescriptor::GetHandlerDesc()
823 // see header file for class documentation
825 AliHLTOUTHandlerListEntryVector::iterator element=fpCollection->fDataHandlers.begin();
826 while (element!=fpCollection->fDataHandlers.end()) {
827 if (element->HasIndex(GetIndex())) {
833 return const_cast<AliHLTOUT::AliHLTOUTHandlerListEntry&>(AliHLTOUT::AliHLTOUTHandlerListEntry::fgkVoidHandlerListEntry);
836 TObject* AliHLTOUT::GetDataObject()
838 // see header file for class documentation
840 fLog.LoggingVarargs(kHLTLogWarning, "AliHLTOUT", "GetDataObject" , __FILE__ , __LINE__ , "data object has not been released, potential memory leak");
841 ReleaseDataBuffer(fpObjectBuffer);
847 if (GetDataBuffer(fpObjectBuffer, fObjectBufferSize)>=0) {
848 fpDataObject=AliHLTMessage::Extract(fpObjectBuffer, fObjectBufferSize);
850 fLog.LoggingVarargs(kHLTLogError, "AliHLTOUT", "GetDataObject" , __FILE__ , __LINE__ , "can not fetch data buffer");
856 int AliHLTOUT::ReleaseDataObject(TObject* pObject)
858 // see header file for class documentation
859 if (!pObject) return -EINVAL;
860 if (pObject!=fpDataObject) {
861 fLog.LoggingVarargs(kHLTLogError, "AliHLTOUT", "GetDataObject" , __FILE__ , __LINE__ , "attempt to release wrong data object %p, expected %p", pObject, fpDataObject);
867 ReleaseDataBuffer(fpObjectBuffer);
874 void AliHLTOUT::SetEventId(AliHLTUInt64_t id)
876 // see header file for class documentation
877 if (fCurrentEventId!=kAliHLTVoidEventID && fCurrentEventId!=id) {
878 fLog.LoggingVarargs(kHLTLogWarning, "AliHLTOUT", "SetEventId" , __FILE__ , __LINE__ , "event id was already set to 0x%llx, setting now to 0x%llx", fCurrentEventId, id);