// $Id$
-/**************************************************************************
- * This file is property of and copyright by the ALICE HLT Project *
- * ALICE Experiment at CERN, All rights reserved. *
- * *
- * Primary Authors: Matthias Richter <Matthias.Richter@ift.uib.no> *
- * for The ALICE HLT Project. *
- * *
- * Permission to use, copy, modify and distribute this software and its *
- * documentation strictly for non-commercial purposes is hereby granted *
- * without fee, provided that the above copyright notice appears in all *
- * copies and that both the copyright notice and this permission notice *
- * appear in the supporting documentation. The authors make no claims *
- * about the suitability of this software for any purpose. It is *
- * provided "as is" without express or implied warranty. *
- **************************************************************************/
+//**************************************************************************
+//* This file is property of and copyright by the ALICE HLT Project *
+//* ALICE Experiment at CERN, All rights reserved. *
+//* *
+//* Primary Authors: Matthias Richter <Matthias.Richter@ift.uib.no> *
+//* for The ALICE HLT Project. *
+//* *
+//* Permission to use, copy, modify and distribute this software and its *
+//* documentation strictly for non-commercial purposes is hereby granted *
+//* without fee, provided that the above copyright notice appears in all *
+//* copies and that both the copyright notice and this permission notice *
+//* appear in the supporting documentation. The authors make no claims *
+//* about the suitability of this software for any purpose. It is *
+//* provided "as is" without express or implied warranty. *
+//**************************************************************************
/** @file AliHLTOUT.cxx
@author Matthias Richter
@date
- @brief The control class for HLTOUT data. */
-
-// see header file for class documentation
-// or
-// refer to README to build package
-// or
-// visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
+ @brief The control class for HLTOUT data.
+*/
#include <cerrno>
#include <cassert>
#include "AliHLTOUT.h"
+#include "AliHLTMessage.h"
#include "TSystem.h"
#include "TClass.h"
#include "TROOT.h"
fSearchDataType(kAliHLTVoidDataType),
fSearchSpecification(kAliHLTVoidDataSpec),
fSearchHandlerType(AliHLTModuleAgent::kUnknownOutput),
- fFlags(0),
+ fFlags(kSkipProcessed),
fBlockDescList(),
- fCurrent(fBlockDescList.begin()),
+ fCurrent(0),
fpBuffer(NULL),
fDataHandlers(),
- fbVerbose(true)
+ fbVerbose(true),
+ fLog()
+ , fpDataObject(NULL)
+ , fpObjectBuffer(NULL)
+ , fObjectBufferSize(0)
+ , fCurrentEventId(kAliHLTVoidEventID)
{
// see header file for class documentation
// or
AliHLTOUT::~AliHLTOUT()
{
// see header file for class documentation
+ if (CheckStatusFlag(kIsSubCollection)) {
+ fLog.LoggingVarargs(kHLTLogWarning, "AliHLTOUT", "~AliHLTOUT" , __FILE__ , __LINE__ , "severe internal error: collection has not been released, potential crash due to invalid pointer");
+ }
+
+ if (fpDataObject) {
+ fLog.LoggingVarargs(kHLTLogWarning, "AliHLTOUT", "GetDataObject" , __FILE__ , __LINE__ , "data object has not been released, potential memory leak");
+ }
+ fpDataObject=NULL;
}
+AliHLTOUT* AliHLTOUT::fgGlobalInstance=NULL;
int AliHLTOUT::Init()
{
// see header file for class documentation
int iResult=0;
+
+ // ignore if already initialized
+ if (fBlockDescList.size()>0) {
+ fLog.LoggingVarargs(kHLTLogWarning, "AliHLTOUT", "Init" , __FILE__ , __LINE__ , "instance %p already initialized, skipping ...", this);
+ return 0;
+ }
+
SetStatusFlag(kCollecting);
if ((iResult=GenerateIndex())>=0) {
if ((iResult=InitHandlers())>=0) {
}
int AliHLTOUT::SelectFirstDataBlock(AliHLTComponentDataType dt, AliHLTUInt32_t spec,
- AliHLTModuleAgent::AliHLTOUTHandlerType handlerType)
+ AliHLTModuleAgent::AliHLTOUTHandlerType handlerType,
+ bool skipProcessed)
{
// see header file for class documentation
- if (CheckStatusFlag(kLocked)) return -EPERM;
- fCurrent=fBlockDescList.begin();
+ fCurrent=0;
fSearchDataType=dt;
fSearchSpecification=spec;
fSearchHandlerType=handlerType;
+ if (skipProcessed) SetStatusFlag(kSkipProcessed);
+ else ClearStatusFlag(kSkipProcessed);
return FindAndSelectDataBlock();
}
int AliHLTOUT::SelectNextDataBlock()
{
// see header file for class documentation
- if (CheckStatusFlag(kLocked)) return -EPERM;
- if (fCurrent==fBlockDescList.end()) return -ENOENT;
+ if (fCurrent>=fBlockDescList.size()) return -ENOENT;
fCurrent++;
return FindAndSelectDataBlock();
}
// see header file for class documentation
if (CheckStatusFlag(kLocked)) return -EPERM;
int iResult=-ENOENT;
- while (fCurrent!=fBlockDescList.end() && iResult==-ENOENT) {
- if ((*fCurrent)==fSearchDataType &&
- (fSearchSpecification==kAliHLTVoidDataSpec || (*fCurrent)==fSearchSpecification) &&
- (fSearchHandlerType==AliHLTModuleAgent::kUnknownOutput || FindHandlerDesc(fCurrent->GetIndex())==fSearchHandlerType)) {
- iResult=fCurrent->GetIndex();
+ while (fCurrent<fBlockDescList.size() && iResult==-ENOENT) {
+ if (fBlockDescList[fCurrent]==fSearchDataType &&
+ (fSearchSpecification==kAliHLTVoidDataSpec || fBlockDescList[fCurrent]==fSearchSpecification) &&
+ (fSearchHandlerType==AliHLTModuleAgent::kUnknownOutput || FindHandlerDesc(fCurrent)==fSearchHandlerType) &&
+ (!CheckStatusFlag(kBlockSelection) || fBlockDescList[fCurrent].IsSelected()) &&
+ (!CheckStatusFlag(kSkipProcessed) || !fBlockDescList[fCurrent].IsProcessed())) {
+ iResult=fBlockDescList[fCurrent].GetIndex();
// TODO: check the byte order on the current system and the byte order of the
// data block, print warning when mismatch and user did not check
//AliHLTOUTByteOrder blockBO=CheckByteOrder();
{
// see header file for class documentation
int iResult=-ENOENT;
- if (fCurrent!=fBlockDescList.end()) {
+ if (fCurrent<fBlockDescList.size()) {
iResult=0;
- dt=(*fCurrent);
- spec=(*fCurrent);
+ dt=fBlockDescList[fCurrent];
+ spec=fBlockDescList[fCurrent];
}
return iResult;
}
const AliHLTOUT::AliHLTOUTHandlerListEntry& AliHLTOUT::GetDataBlockHandlerDesc()
{
// see header file for class documentation
- return FindHandlerDesc(GetDataBlockIndex());
+ return FindHandlerDesc(fCurrent);
}
AliHLTModuleAgent::AliHLTOUTHandlerType AliHLTOUT::GetDataBlockHandlerType()
{
// see header file for class documentation
- AliHLTModuleAgent::AliHLTOUTHandlerDesc desc=FindHandlerDesc(GetDataBlockIndex());
+ AliHLTModuleAgent::AliHLTOUTHandlerDesc desc=FindHandlerDesc(fCurrent);
AliHLTModuleAgent::AliHLTOUTHandlerType type=desc;
return type;
}
AliHLTUInt32_t AliHLTOUT::GetDataBlockIndex()
{
// see header file for class documentation
- if (fCurrent==fBlockDescList.end()) return AliHLTOUTInvalidIndex;
- return fCurrent->GetIndex();
+ if (fCurrent>=fBlockDescList.size()) return AliHLTOUTInvalidIndex;
+ return fBlockDescList[fCurrent].GetIndex();
}
int AliHLTOUT::GetDataBuffer(const AliHLTUInt8_t* &pBuffer, AliHLTUInt32_t& size)
int iResult=-ENOENT;
pBuffer=NULL;
size=0;
- if (fCurrent!=fBlockDescList.end()) {
- if ((iResult=GetDataBuffer(fCurrent->GetIndex(), pBuffer, size))>=0) {
+ if (fCurrent<fBlockDescList.size()) {
+ if ((iResult=fBlockDescList[fCurrent].GetDataBuffer(pBuffer, size))>=0) {
fpBuffer=pBuffer;
}
}
if (pBuffer==fpBuffer) {
fpBuffer=NULL;
} else {
- HLTWarning("buffer %p does not match the provided one %p", pBuffer, fpBuffer);
+ fLog.LoggingVarargs(kHLTLogWarning, "AliHLTOUT", "ReleaseDataBuffer" , __FILE__ , __LINE__ , "buffer %p does not match the provided one %p", pBuffer, fpBuffer);
}
return iResult;
}
{
// see header file for class documentation
AliHLTModuleAgent* pAgent=NULL;
- pAgent=FindHandlerDesc(GetDataBlockIndex());
+ pAgent=FindHandlerDesc(fCurrent);
return pAgent;
}
{
// see header file for class documentation
AliHLTOUTHandler* pHandler=NULL;
- pHandler=FindHandlerDesc(GetDataBlockIndex());
+ pHandler=FindHandlerDesc(fCurrent);
return pHandler;
}
int AliHLTOUT::WriteESD(const AliHLTUInt8_t* /*pBuffer*/, AliHLTUInt32_t /*size*/, AliHLTComponentDataType /*dt*/, AliESDEvent* /*tgtesd*/) const
{
// see header file for class documentation
- HLTWarning("method not implemented in base class");
+ fLog.LoggingVarargs(kHLTLogWarning, "AliHLTOUT", "WriteESD" , __FILE__ , __LINE__ , "method not implemented in base class");
return -ENOSYS;
}
AliHLTOUT::AliHLTOUTByteOrder AliHLTOUT::CheckByteOrder()
{
// see header file for class documentation
- if (fCurrent!=fBlockDescList.end()) {
+ if (fCurrent<fBlockDescList.size()) {
SetStatusFlag(kByteOrderChecked);
- AliHLTOUT::AliHLTOUTByteOrder order=CheckBlockByteOrder((*fCurrent).GetIndex());
+ AliHLTOUT::AliHLTOUTByteOrder order=CheckBlockByteOrder(fBlockDescList[fCurrent].GetIndex());
return order;
}
return kInvalidByteOrder;
int AliHLTOUT::CheckAlignment(AliHLTOUT::AliHLTOUTDataType type)
{
// see header file for class documentation
- if (fCurrent!=fBlockDescList.end()) {
+ if (fCurrent<fBlockDescList.size()) {
SetStatusFlag(kAlignmentChecked);
- int alignment=CheckBlockAlignment((*fCurrent).GetIndex(), type);
+ int alignment=CheckBlockAlignment(fBlockDescList[fCurrent].GetIndex(), type);
return alignment;
}
return -ENOENT;
// warning if some of the data blocks are not selected by the kAliHLTAnyDataType
// criterion
if (GetNofDataBlocks()>iCount) {
- HLTWarning("incomplete data type in %d out of %d data block(s)", GetNofDataBlocks()-iCount, iCount);
+ fLog.LoggingVarargs(kHLTLogWarning, "AliHLTOUT", "InitHandlers" , __FILE__ , __LINE__ , "incomplete data type in %d out of %d data block(s)", GetNofDataBlocks()-iCount, GetNofDataBlocks());
}
// warning if handler not found
if (remnants.size()>0) {
- HLTWarning("no handlers found for %d data blocks out of %d", remnants.size(), iCount);
+ fLog.LoggingVarargs(kHLTLogWarning, "AliHLTOUT", "InitHandlers" , __FILE__ , __LINE__ , "no handlers found for %d data blocks out of %d", remnants.size(), iCount);
AliHLTOUTBlockDescriptorVector::iterator block=fBlockDescList.begin();
for (AliHLTOUTIndexList::iterator element=remnants.begin(); element!=remnants.end(); element++) {
for (int trials=0; trials<2; trials++) {
}
assert(block!=fBlockDescList.end());
if (block!=fBlockDescList.end()) {
- HLTDebug(" %s", AliHLTComponent::DataType2Text((AliHLTComponentDataType)*block).c_str());
+ //HLTDebug(" %s", AliHLTComponent::DataType2Text((AliHLTComponentDataType)*block).c_str());
}
}
}
// see header file for class documentation
int iResult=0;
AliHLTOUTHandlerListEntryVector::iterator element=list.begin();
- while (element!=list.end()) {
+ for (; element!=list.end();
+ element++) {
if (entry==(*element)) break;
- element++;
}
if (element==list.end()) {
list.push_back(entry);
return iResult;
}
-const AliHLTOUT::AliHLTOUTHandlerListEntry& AliHLTOUT::FindHandlerDesc(AliHLTUInt32_t blockIndex)
+int AliHLTOUT::FillHandlerList(AliHLTOUTHandlerListEntryVector& list, AliHLTModuleAgent::AliHLTOUTHandlerType handlerType)
{
// see header file for class documentation
- AliHLTOUTHandlerListEntryVector::iterator element=fDataHandlers.begin();
- while (element!=fDataHandlers.end()) {
- if (element->HasIndex(blockIndex)) {
- return *element;
+ int iResult=0;
+ for (iResult=SelectFirstDataBlock(kAliHLTAnyDataType, kAliHLTVoidDataSpec, handlerType);
+ iResult>=0;
+ iResult=SelectNextDataBlock()) {
+ AliHLTComponentDataType dt=kAliHLTVoidDataType;
+ AliHLTUInt32_t spec=kAliHLTVoidDataSpec;
+ GetDataBlockDescription(dt, spec);
+ AliHLTOUTHandler* pHandler=GetHandler();
+ if (!pHandler) {
+ fLog.LoggingVarargs(kHLTLogWarning, "AliHLTOUT", "FillHandlerList" , __FILE__ , __LINE__ ,
+ "missing HLTOUT handler for block of type kChain: agent %s, data type %s, specification %#x, ... skipping data block",
+ GetAgent()?GetAgent()->GetModuleId():"invalid",
+ AliHLTComponent::DataType2Text(dt).c_str(), spec);
+ } else {
+ InsertHandler(list, GetDataBlockHandlerDesc());
+ }
+ }
+ // TODO: the return value of SelectFirst/NextDataBlock must be
+ // changed in order to avoid this check
+ if (iResult==-ENOENT) iResult=0;
+
+ return iResult;
+}
+
+int AliHLTOUT::RemoveEmptyDuplicateHandlers(AliHLTOUTHandlerListEntryVector& list)
+{
+ // see header file for class documentation
+ int iResult=0;
+ AliHLTOUTHandlerListEntryVector::iterator element=list.begin();
+ while (element!=list.end()) {
+ if (element->IsEmpty()) {
+ AliHLTOUTHandler* pHandler=*element;
+ AliHLTModuleAgent* pAgent=*element;
+ AliHLTModuleAgent::AliHLTOUTHandlerDesc desc=*element;
+ if (FindHandler(list, desc)>=0) {
+ element=list.erase(element);
+ if (pAgent) {
+ pAgent->DeleteOutputHandler(pHandler);
+ }
+ // we are already at the next element
+ continue;
+ }
}
element++;
}
+ return iResult;
+}
+
+int AliHLTOUT::FindHandler(AliHLTOUTHandlerListEntryVector& list, const AliHLTModuleAgent::AliHLTOUTHandlerDesc desc)
+{
+ // see header file for class documentation
+ for (int i=0; i<(int)list.size(); i++) {
+ if (list[i]==desc) return i;
+ }
+ return -ENOENT;
+}
+
+int AliHLTOUT::InvalidateBlocks(AliHLTOUTHandlerListEntryVector& list)
+{
+ // see header file for class documentation
+ for (AliHLTOUTHandlerListEntryVector::iterator element=list.begin();
+ element!=list.end();
+ element++) {
+ element->InvalidateBlocks();
+ }
+ return 0;
+}
+
+const AliHLTOUT::AliHLTOUTHandlerListEntry& AliHLTOUT::FindHandlerDesc(AliHLTUInt32_t blockIndex)
+{
+ // see header file for class documentation
+ if (blockIndex<fBlockDescList.size()) {
+ return fBlockDescList[blockIndex].GetHandlerDesc();
+ }
return const_cast<AliHLTOUT::AliHLTOUTHandlerListEntry&>(AliHLTOUT::AliHLTOUTHandlerListEntry::fgkVoidHandlerListEntry);
}
return *fpHandlerDesc==handlerType;
}
+bool AliHLTOUT::AliHLTOUTHandlerListEntry::operator==(const AliHLTModuleAgent::AliHLTOUTHandlerDesc desc) const
+{
+ // see header file for class documentation
+ if (!fpHandlerDesc) return false;
+ return *fpHandlerDesc==desc;
+}
+
void AliHLTOUT::AliHLTOUTHandlerListEntry::AddIndex(AliHLTOUT::AliHLTOUTHandlerListEntry &desc)
{
// see header file for class documentation
fBlocks.push_back(index);
}
-bool AliHLTOUT::AliHLTOUTHandlerListEntry::HasIndex(AliHLTUInt32_t index)
+bool AliHLTOUT::AliHLTOUTHandlerListEntry::HasIndex(AliHLTUInt32_t index) const
{
// see header file for class documentation
AliHLTOUTIndexList::iterator element;
- for (element=fBlocks.begin(); element!=fBlocks.end(); element++) {
- if (*element==index) return true;
+ for (unsigned int i=0; i<fBlocks.size(); i++) {
+ if (fBlocks[i]==index) return true;
}
return false;
}
ROOT::NewFunc_t pNewFunc=NULL;
do {
pCl=TClass::GetClass(classname);
- } while (!pCl && (iLibResult=gSystem->Load("libHLTRec.so"))==0);
+ } while (!pCl && (iLibResult=gSystem->Load("libHLTrec.so"))==0);
if (iLibResult>=0) {
if (pCl && (pNewFunc=pCl->GetNew())!=NULL) {
void* p=(*pNewFunc)(NULL);
{
// see header file for class documentation
if (!pInstance) return;
+ if (pInstance==fgGlobalInstance) return;
// check if the library is still there in order to have the
// destructor available
// is intended to be used with the New functions. If we get into
// the default implementation there is a class mismatch.
assert(0);
- HLTFatal("severe internal error: class mismatch");
+ fLog.LoggingVarargs(kHLTLogFatal, "AliHLTOUT", "SetParam" , __FILE__ , __LINE__ , "severe internal error: class mismatch");
}
void AliHLTOUT::SetParam(TTree* /*pDigitTree*/, int /*event*/)
// is intended to be used with the New functions. If we get into
// the default implementation there is a class mismatch.
assert(0);
- HLTFatal("severe internal error: class mismatch");
+ fLog.LoggingVarargs(kHLTLogFatal, "AliHLTOUT", "SetParam" , __FILE__ , __LINE__ , "severe internal error: class mismatch");
+}
+
+int AliHLTOUT::SelectDataBlock()
+{
+ // see header file for class documentation
+ int iResult=0;
+ if (fCurrent>=fBlockDescList.size()) return 0;
+ fBlockDescList[fCurrent].Select(true);
+ EnableBlockSelection();
+ return iResult;
+}
+
+int AliHLTOUT::SelectDataBlocks(const AliHLTOUTHandlerListEntry* pHandlerEntry)
+{
+ // see header file for class documentation
+ int iResult=0;
+ if (!pHandlerEntry) return 0;
+
+ AliHLTModuleAgent* pAgent=*pHandlerEntry;
+ AliHLTLogging log;
+ log.Logging(kHLTLogDebug, "AliHLTOUT::SelectDataBlocks", "HLTOUT handling", "selecting blocks for handler %s", pAgent->GetModuleId());
+ AliHLTOUTBlockDescriptorVector::iterator element;
+ for (AliHLTOUTBlockDescriptorVector::iterator block=fBlockDescList.begin();
+ block!=fBlockDescList.end();
+ block++) {
+ if (block->GetHandlerDesc()==*pHandlerEntry && pHandlerEntry->HasIndex(block->GetIndex())) {
+ block->Select(true);
+ log.Logging(kHLTLogDebug, "AliHLTOUT::SelectDataBlocks", "HLTOUT handling", " select block %s", AliHLTComponent::DataType2Text(*block).c_str());
+ } else {
+ log.Logging(kHLTLogDebug, "AliHLTOUT::SelectDataBlocks", "HLTOUT handling", " skip block %s", AliHLTComponent::DataType2Text(*block).c_str());
+ block->Select(false);
+ }
+ }
+ EnableBlockSelection();
+
+ // Matthias 2009-07-03 bugfix: the fCurrent position was not reset at that
+ // place. Also I think the data type and specification must be set in order
+ // to make SelectFirst/NextDataBlock working on the selected collection
+ // of data blocks
+ AliHLTModuleAgent::AliHLTOUTHandlerDesc pHandlerDesc=*pHandlerEntry;
+ fSearchDataType=pHandlerDesc;
+ fSearchSpecification=kAliHLTVoidDataSpec;
+ fSearchHandlerType=pHandlerDesc;
+ fCurrent=0;
+
+ return iResult;
+}
+
+int AliHLTOUT::EnableBlockSelection()
+{
+ // see header file for class documentation
+ SetStatusFlag(kBlockSelection);
+ return 0;
+}
+
+int AliHLTOUT::DisableBlockSelection()
+{
+ // see header file for class documentation
+ ClearStatusFlag(kBlockSelection);
+ return 0;
+}
+
+int AliHLTOUT::ResetBlockSelection()
+{
+ // see header file for class documentation
+ for (AliHLTOUTBlockDescriptorVector::iterator block=fBlockDescList.begin();
+ block!=fBlockDescList.end();
+ block++) {
+ block->Select(false);
+ }
+ return 0;
+}
+
+int AliHLTOUT::MarkDataBlockProcessed()
+{
+ // see header file for class documentation
+ int iResult=0;
+ if (fCurrent>=fBlockDescList.size()) return 0;
+ fBlockDescList[fCurrent].MarkProcessed();
+ return iResult;
+}
+
+int AliHLTOUT::MarkDataBlocksProcessed(const AliHLTOUTHandlerListEntry* pHandlerDesc)
+{
+ // see header file for class documentation
+ int iResult=0;
+ if (!pHandlerDesc) return 0;
+
+ AliHLTOUTBlockDescriptorVector::iterator element;
+ for (AliHLTOUTBlockDescriptorVector::iterator block=fBlockDescList.begin();
+ block!=fBlockDescList.end();
+ block++) {
+ if (block->GetHandlerDesc()==*pHandlerDesc && pHandlerDesc->HasIndex(block->GetIndex()))
+ block->MarkProcessed();
+ }
+
+ return iResult;
+}
+
+int AliHLTOUT::AddSubCollection(AliHLTOUT* pCollection)
+{
+ // see header file for class documentation
+ int iResult=0;
+ if (!pCollection) return 0;
+
+ SetStatusFlag(kCollecting);
+ int index=-1;
+ for (index=pCollection->SelectFirstDataBlock();
+ index>=0;
+ index=pCollection->SelectNextDataBlock()) {
+ AliHLTComponentDataType dt=kAliHLTVoidDataType;
+ AliHLTUInt32_t spec=kAliHLTVoidDataSpec;
+ pCollection->GetDataBlockDescription(dt, spec);
+ AliHLTOUTBlockDescriptor desc(dt, spec, index, pCollection);
+ AddBlockDescriptor(desc);
+ iResult++;
+ }
+ if (iResult>0) {
+ if (CheckStatusFlag(kIsSubCollection)) {
+ fLog.LoggingVarargs(kHLTLogWarning, "AliHLTOUT", "AddSubCollection" , __FILE__ , __LINE__ , "HLTOUT object %p has already been added as sub-collection", pCollection);
+ } else {
+ pCollection->SetStatusFlag(kIsSubCollection);
+ }
+ }
+ ClearStatusFlag(kCollecting);
+
+ return iResult;
+}
+
+int AliHLTOUT::ReleaseSubCollection(AliHLTOUT* pCollection)
+{
+ // see header file for class documentation
+ int iResult=0;
+ if (!pCollection) return 0;
+
+ AliHLTOUTBlockDescriptorVector::iterator block=fBlockDescList.begin();
+ while (block!=fBlockDescList.end()) {
+ if ((*block)==pCollection) {
+ block=fBlockDescList.erase(block);
+ continue;
+ }
+ block++;
+ }
+ pCollection->ClearStatusFlag(kIsSubCollection);
+
+ return iResult;
+}
+
+int AliHLTOUT::Reset()
+{
+ // see header file for class documentation
+ int iResult=0;
+ AliHLTOUTPVector subCollections;
+ AliHLTOUTBlockDescriptorVector::iterator block=fBlockDescList.begin();
+ while (block!=fBlockDescList.end()) {
+ if (!((*block)==this)) {
+ AliHLTOUTPVector::iterator collection=subCollections.begin();
+ for (; collection!=subCollections.end(); collection++)
+ if((*block)==*collection) break;
+ if (collection==subCollections.end())
+ subCollections.push_back(block->GetCollection());
+ }
+ block=fBlockDescList.erase(block);
+ }
+
+ for (AliHLTOUTPVector::iterator collection=subCollections.begin();
+ collection!=subCollections.end(); collection++) {
+ (*collection)->Reset();
+ (*collection)->ClearStatusFlag(kIsSubCollection);
+ }
+
+ ResetInput();
+ fCurrentEventId=kAliHLTVoidEventID;
+
+ return iResult;
+}
+
+int AliHLTOUT::ResetInput()
+{
+ // default implementation, nothing to do
+ return 0;
+}
+
+const AliHLTOUT::AliHLTOUTHandlerListEntry& AliHLTOUT::AliHLTOUTBlockDescriptor::GetHandlerDesc()
+{
+ // see header file for class documentation
+ if (fpCollection) {
+ AliHLTOUTHandlerListEntryVector::iterator element=fpCollection->fDataHandlers.begin();
+ while (element!=fpCollection->fDataHandlers.end()) {
+ if (element->HasIndex(GetIndex())) {
+ return *element;
+ }
+ element++;
+ }
+ }
+ return const_cast<AliHLTOUT::AliHLTOUTHandlerListEntry&>(AliHLTOUT::AliHLTOUTHandlerListEntry::fgkVoidHandlerListEntry);
+}
+
+TObject* AliHLTOUT::GetDataObject()
+{
+ // see header file for class documentation
+ if (fpDataObject) {
+ fLog.LoggingVarargs(kHLTLogWarning, "AliHLTOUT", "GetDataObject" , __FILE__ , __LINE__ , "data object has not been released, potential memory leak");
+ ReleaseDataBuffer(fpObjectBuffer);
+ }
+ fpObjectBuffer=NULL;
+ fObjectBufferSize=0;
+ fpDataObject=NULL;
+
+ if (GetDataBuffer(fpObjectBuffer, fObjectBufferSize)>=0) {
+ fpDataObject=AliHLTMessage::Extract(fpObjectBuffer, fObjectBufferSize);
+ } else {
+ fLog.LoggingVarargs(kHLTLogError, "AliHLTOUT", "GetDataObject" , __FILE__ , __LINE__ , "can not fetch data buffer");
+ }
+
+ return fpDataObject;
+}
+
+int AliHLTOUT::ReleaseDataObject(TObject* pObject)
+{
+ // see header file for class documentation
+ if (!pObject) return -EINVAL;
+ if (pObject!=fpDataObject) {
+ fLog.LoggingVarargs(kHLTLogError, "AliHLTOUT", "GetDataObject" , __FILE__ , __LINE__ , "attempt to release wrong data object %p, expected %p", pObject, fpDataObject);
+ return -EINVAL;
+ }
+
+ delete fpDataObject;
+ fpDataObject=NULL;
+ ReleaseDataBuffer(fpObjectBuffer);
+ fpObjectBuffer=NULL;
+ fObjectBufferSize=0;
+
+ return 0;
+}
+
+void AliHLTOUT::SetEventId(AliHLTUInt64_t id)
+{
+ // see header file for class documentation
+ if (fCurrentEventId!=kAliHLTVoidEventID && fCurrentEventId!=id) {
+ fLog.LoggingVarargs(kHLTLogWarning, "AliHLTOUT", "SetEventId" , __FILE__ , __LINE__ , "event id was already set to 0x%llx, setting now to 0x%llx", fCurrentEventId, id);
+ }
+ fCurrentEventId=id;
}