// $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>
fSearchDataType(kAliHLTVoidDataType),
fSearchSpecification(kAliHLTVoidDataSpec),
fSearchHandlerType(AliHLTModuleAgent::kUnknownOutput),
- fFlags(0),
+ fFlags(kSkipProcessed),
fBlockDescList(),
- fCurrent(fBlockDescList.begin()),
+ fCurrent(0),
fpBuffer(NULL),
fDataHandlers(),
fbVerbose(true)
AliHLTOUT::~AliHLTOUT()
{
// see header file for class documentation
+ if (CheckStatusFlag(kIsSubCollection)) {
+ HLTWarning("severe internal error: collection has not been released, potential crash due to invalid pointer");
+ }
}
int AliHLTOUT::Init()
}
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(fBlockDescList[fCurrent].GetIndex())==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;
}
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;
}
}
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;
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;
}
assert(0);
HLTFatal("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* 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 (pHandlerDesc->HasIndex(block->GetIndex()))
+ block->Select(true);
+ else
+ block->Select(false);
+ }
+ EnableBlockSelection();
+
+ 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 (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;
+
+ 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) {
+ pCollection->SetStatusFlag(kIsSubCollection);
+ }
+
+ return iResult;
+}
+
+int AliHLTOUT::ReleaseSubCollection(AliHLTOUT* pCollection)
+{
+ // see header file for class documentation
+ int iResult=0;
+ if (!pCollection) return 0;
+
+ AliHLTOUTBlockDescriptorVector::iterator element;
+ for (AliHLTOUTBlockDescriptorVector::iterator block=fBlockDescList.begin();
+ block!=fBlockDescList.end();
+ block++) {
+ if ((*block)==pCollection) {
+ element=fBlockDescList.erase(element);
+ }
+ }
+
+ return iResult;
+}
*/
class AliHLTOUTBlockDescriptor {
public:
- AliHLTOUTBlockDescriptor(AliHLTComponentDataType dt, AliHLTUInt32_t spec, AliHLTUInt32_t index)
- : fDataType(dt), fSpecification(spec), fIndex(index) {};
+ AliHLTOUTBlockDescriptor(AliHLTComponentDataType dt, AliHLTUInt32_t spec, AliHLTUInt32_t index, AliHLTOUT* pCollection)
+ : fDataType(dt), fSpecification(spec), fIndex(index), fSelected(false), fProcessed(false), fpCollection(pCollection) {};
+ AliHLTOUTBlockDescriptor(const AliHLTOUTBlockDescriptor& src)
+ : fDataType(src.fDataType), fSpecification(src.fSpecification), fIndex(src.fIndex), fSelected(false), fProcessed(false), fpCollection(src.fpCollection) {}
+ AliHLTOUTBlockDescriptor& operator=(const AliHLTOUTBlockDescriptor& src)
+ { fDataType=src.fDataType; fSpecification=src.fSpecification; fIndex=src.fIndex; fSelected=false; fProcessed=false; fpCollection=src.fpCollection; return *this; }
~AliHLTOUTBlockDescriptor() {}
operator AliHLTComponentDataType() const {return fDataType;}
operator AliHLTUInt32_t() const {return fSpecification;}
int operator==(AliHLTComponentDataType dt) const {return dt==fDataType;}
int operator==(AliHLTUInt32_t spec) const {return spec==fSpecification;}
+ int operator==(AliHLTOUT* collection) const {return collection==fpCollection;}
AliHLTUInt32_t GetIndex() const {return fIndex;}
- private:
+
+ bool IsSelected() const {return fSelected;}
+ void Select(bool selected=true) {fSelected=selected;}
+ bool IsProcessed() const {return fSelected;}
+ void MarkProcessed() {fProcessed=true;}
+
+ /**
+ * Get the data buffer
+ * @param pBuffer [out] buffer of the selected data block
+ * @param size [out] size of the selected data block
+ */
+ int GetDataBuffer(const AliHLTUInt8_t* &pBuffer, AliHLTUInt32_t& size) {
+ if (fpCollection) return fpCollection->GetDataBuffer(GetIndex(), pBuffer, size);
+ return -ENODEV;
+ }
+
+ private:
/** data type of the block */
AliHLTComponentDataType fDataType; //!transient
/** data specification of the block */
AliHLTUInt32_t fSpecification; //!transient
/** index in the data stream */
AliHLTUInt32_t fIndex; //!transient
+ /** selection flag */
+ bool fSelected; //!transient
+ /** processed flag */
+ bool fProcessed; //!transient
+ /** the collection */
+ AliHLTOUT* fpCollection; //!transient
};
class AliHLTOUTHandlerListEntry {
* Check if an index is served by this descriptor.
* @return true if the index is in the table
*/
- bool HasIndex(AliHLTUInt32_t index);
+ bool HasIndex(AliHLTUInt32_t index) const;
private:
/** standard constructor prohibited */
typedef vector<AliHLTOUTHandlerListEntry> AliHLTOUTHandlerListEntryVector;
typedef vector<AliHLTOUTBlockDescriptor> AliHLTOUTBlockDescriptorVector;
+ typedef vector<AliHLTOUT*> AliHLTOUTPVector;
+
+ /**
+ * Selection guard for the AliHLTOUT object.
+ * If the object is locked, the selection of data blocks can not be changed.
+ */
+ class AliHLTOUTSelectionGuard {
+ public:
+ /** constructor */
+ AliHLTOUTSelectionGuard(AliHLTOUT* pInstance) : fpInstance(pInstance)
+ {if (fpInstance) fpInstance->SelectDataBlock();}
+ /** constructor */
+ AliHLTOUTSelectionGuard(AliHLTOUT* pInstance, const AliHLTOUTHandlerListEntry* pHandlerDesc) : fpInstance(pInstance)
+ {if (fpInstance) fpInstance->SelectDataBlocks(pHandlerDesc);}
+ /** destructor */
+ ~AliHLTOUTSelectionGuard()
+ {if (fpInstance) fpInstance->DisableBlockSelection();}
+
+ private:
+ /** standard constructor prohibited */
+ AliHLTOUTSelectionGuard();
+ /** copy constructor prohibited */
+ AliHLTOUTSelectionGuard(const AliHLTOUTSelectionGuard&);
+ /** assignment operator prohibited */
+ AliHLTOUTSelectionGuard& operator=(const AliHLTOUTSelectionGuard&);
+
+ /** the AliHLTOUT instance the guard is locking */
+ AliHLTOUT* fpInstance; //!transient
+ };
/**
* Init for processing.
*/
int SelectFirstDataBlock(AliHLTComponentDataType dt=kAliHLTAnyDataType,
AliHLTUInt32_t spec=kAliHLTVoidDataSpec,
- AliHLTModuleAgent::AliHLTOUTHandlerType handlerType=AliHLTModuleAgent::kUnknownOutput);
+ AliHLTModuleAgent::AliHLTOUTHandlerType handlerType=AliHLTModuleAgent::kUnknownOutput,
+ bool skipProcessed=true);
/**
* Select the next data block of data type and specification of the previous
*/
int ReleaseDataBuffer(const AliHLTUInt8_t* pBuffer);
+ /**
+ * Add the current data block to the selection.
+ * Note: enables also the block selection
+ */
+ int SelectDataBlock();
+
+ /**
+ * Add the all data blocks of a certain handler to the selection.
+ * Note: enables also the block selection
+ */
+ int SelectDataBlocks(const AliHLTOUTHandlerListEntry* pHandlerDesc);
+
+ /**
+ * Enable the selection of data blocks.
+ */
+ int EnableBlockSelection();
+
+ /**
+ * Disable the selection of data blocks.
+ */
+ int DisableBlockSelection();
+
+ /**
+ * Reset the data block selection.
+ * Resets the selection list, none of the blocks is selected.
+ */
+ int ResetBlockSelection();
+
+ /**
+ * Mark the current block as processed.
+ */
+ int MarkDataBlockProcessed();
+
+ /**
+ * Mark all data blocks of a certain handler processed.
+ */
+ int MarkDataBlocksProcessed(const AliHLTOUTHandlerListEntry* pHandlerDesc);
+
+ /**
+ * Add a sub collection to the HLTOUT.
+ */
+ int AddSubCollection(AliHLTOUT* pCollection);
+
+ /**
+ * Release a previously added sub collection.
+ */
+ int ReleaseSubCollection(AliHLTOUT* pCollection);
+
/**
* Get module agent for the selected data block.
*/
* Internal status flags
*/
enum {
- /** the HLTOUT object is locked with the current data block */
+ /** the HLTOUT object is locked with the current data block selection */
kLocked = 0x1,
/** childs can add block descriptors */
kCollecting = 0x2,
/** user of the data block has checked the alignment */
kAlignmentChecked = 0x10,
/** warning on alignment missmatch has been printed */
- kAlignmentWarning = 0x20
+ kAlignmentWarning = 0x20,
+ /** enable block selection list */
+ kBlockSelection = 0x40,
+ /** skip processed data blocks */
+ kSkipProcessed = 0x80,
+ /** marked as sub collection */
+ kIsSubCollection = 0x100
};
/**
* Select the data block of data type and specification of the previous
* call to @ref SelectFirstDataBlock. Core function of @ref SelectFirstDataBlock
* and @ref SelectNextDataBlock, starts to find a block at the current list
- * position.
+ * position.
+ *
+ * The data block is searched from the conditions of fSearchDataType,
+ * fSearchSpecification, fSearchHandlerType and the selection list.
+ *
* @return identifier >=0 if success, neg. error code if failed <br>
* -ENOENT if no block found <br>
* -EPERM if access denied (object locked)
AliHLTOUTBlockDescriptorVector fBlockDescList; //!transient
/** current position in the list */
- AliHLTOUTBlockDescriptorVector::iterator fCurrent; //!transient
+ unsigned int fCurrent; //!transient
/** data buffer under processing */
const AliHLTUInt8_t* fpBuffer; //!transient
/** verbose or silent output */
bool fbVerbose; //!transient
- ClassDef(AliHLTOUT, 2)
+ ClassDef(AliHLTOUT, 3)
};
#endif
/**
* Process the data.
- * The data and it's properties can be retrieved by the following member
+ * The data blocks can be selected by AliHLTOUT::SelectFirstDataBlock() and
+ * AliHLTOUT::SelectNextDataBlock()
+ *
+ * Properties of the current data block can be retrieved by the following member
* functions of AliHLTOUT:
* - AliHLTOUT::GetDataBlockDescription(AliHLTComponentDataType& dt, AliHLTUInt32_t& spec)
* - AliHLTOUT::GetDataBlockIndex()
homer_uint32 spec=pReader->GetBlockDataSpec( i );
AliHLTComponentDataType dt;
AliHLTComponent::SetDataType(dt, ByteSwap64(id), ByteSwap32(origin));
- AliHLTOUTBlockDescriptor desc(dt, spec, offset|i);
+ AliHLTOUTBlockDescriptor desc(dt, spec, offset|i, this);
HLTDebug("adding block %d: %s %#x", i, AliHLTComponent::DataType2Text(dt).c_str(), spec);
iResult=AddBlockDescriptor(desc);
}
// see header file for class documentation
int iResult=0;
if (!pHLTOUT) return -EINVAL;
-
HLTDebug("processing %d HLT data blocks", pHLTOUT->GetNofDataBlocks());
+
+ //
+ // process all kChain handlers first
+ //
+ if ((iResult=ProcessHLTOUTkChain(pHLTOUT))<0) {
+ HLTWarning("Processing of kChain-type data blocks failed with error code %d", iResult);
+ iResult=0;
+ }
+
AliHLTOUT::AliHLTOUTHandlerListEntryVector esdHandlers;
// first come first serve: the ESD of the first handler is also filled into
pHLTOUT->GetDataBlockDescription(dt, spec);
AliHLTOUTHandler* pHandler=pHLTOUT->GetHandler();
AliHLTModuleAgent::AliHLTOUTHandlerType handlerType=pHLTOUT->GetDataBlockHandlerType();
+
+ // default handling for ESD data blocks does not require an explicite handler
if (!pHandler && (dt==kAliHLTDataTypeESDObject || dt==kAliHLTDataTypeESDTree)) {
handlerType=AliHLTModuleAgent::kEsd;
}
case AliHLTModuleAgent::kEsd:
{
if (pHandler) {
- // preprocess and write later
- AliHLTOUT::AliHLTOUTLockGuard g(pHLTOUT);
- pHandler->ProcessData(pHLTOUT);
+ // schedule for later processing
pHLTOUT->InsertHandler(esdHandlers, pHLTOUT->GetDataBlockHandlerDesc());
} else {
// write directly
}
pHLTOUT->ReleaseDataBuffer(pBuffer);
}
+ pHLTOUT->MarkDataBlockProcessed();
}
}
break;
AliHLTComponent::DataType2Text(dt).c_str(), spec);
break;
case AliHLTModuleAgent::kChain:
- HLTWarning("HLTOUT handler type 'kChain' not yet implemented: agent %s, data type %s, specification %#x",
+ HLTWarning("HLTOUT handler type 'kChain' has already been processed: agent %s, data type %s, specification %#x\n"
+ "New block of this type added by the chain? Skipping data block ...",
pMsg, pHLTOUT->GetAgent()?pHLTOUT->GetAgent()->GetModuleId():"invalid",
AliHLTComponent::DataType2Text(dt).c_str(), spec);
break;
AliHLTOUT::AliHLTOUTHandlerListEntryVector::iterator esdHandler;
// write all postponed esd data blocks
for (esdHandler=esdHandlers.begin(); esdHandler!=esdHandlers.end() && iResult>=0; esdHandler++) {
+ AliHLTOUT::AliHLTOUTSelectionGuard g(pHLTOUT, &(*esdHandler));
AliHLTOUTHandler* pHandler=*esdHandler;
const AliHLTUInt8_t* pBuffer=NULL;
AliHLTUInt32_t size=0;
+ pHandler->ProcessData(pHLTOUT);
if ((size=pHandler->GetProcessedData(pBuffer))>0) {
AliHLTModuleAgent::AliHLTOUTHandlerDesc desc=*esdHandler;
AliHLTComponentDataType dt=desc;
}
pHandler->ReleaseProcessedData(pBuffer, size);
}
+ pHLTOUT->MarkDataBlocksProcessed(&(*esdHandler));
+ }
+
+ return iResult;
+}
+
+int AliHLTSystem::ProcessHLTOUTkChain(AliHLTOUT* pHLTOUT)
+{
+ // see header file for class documentation
+ int iResult=0;
+ if (!pHLTOUT) return -EINVAL;
+
+ AliHLTOUT::AliHLTOUTHandlerListEntryVector chainHandlers;
+ for (iResult=pHLTOUT->SelectFirstDataBlock(kAliHLTAnyDataType, kAliHLTVoidDataSpec, AliHLTModuleAgent::kUnknownOutput);
+ iResult>=0;
+ iResult=pHLTOUT->SelectNextDataBlock()) {
+ AliHLTComponentDataType dt=kAliHLTVoidDataType;
+ AliHLTUInt32_t spec=kAliHLTVoidDataSpec;
+ pHLTOUT->GetDataBlockDescription(dt, spec);
+ AliHLTOUTHandler* pHandler=pHLTOUT->GetHandler();
+ AliHLTModuleAgent::AliHLTOUTHandlerType handlerType=pHLTOUT->GetDataBlockHandlerType();
+ if (handlerType==AliHLTModuleAgent::kChain) {
+ if (!pHandler) {
+ HLTWarning("missing HLTOUT handler for block of type kChain: agent %s, data type %s, specification %#x, ... skipping data block",
+ pHLTOUT->GetAgent()?pHLTOUT->GetAgent()->GetModuleId():"invalid",
+ AliHLTComponent::DataType2Text(dt).c_str(), spec);
+ } else {
+ pHLTOUT->InsertHandler(chainHandlers, pHLTOUT->GetDataBlockHandlerDesc());
+ }
+ }
+ }
+ // TODO: the return value of SelectFirst/NextDataBlock must be
+ // changed in order to avoid this check
+ if (iResult==-ENOENT) iResult=0;
+
+ // process all defined chain handlers
+ AliHLTOUT::AliHLTOUTHandlerListEntryVector::iterator chainHandler;
+ for (chainHandler=chainHandlers.begin(); chainHandler!=chainHandlers.end() && iResult>=0; chainHandler++) {
+ AliHLTOUT::AliHLTOUTSelectionGuard g(pHLTOUT, &(*chainHandler));
+ AliHLTOUTHandler* pHandler=*chainHandler;
+ const AliHLTUInt8_t* pBuffer=NULL;
+ AliHLTUInt32_t size=0;
+ pHandler->ProcessData(pHLTOUT);
+ if ((size=pHandler->GetProcessedData(pBuffer))>0) {
+ AliHLTModuleAgent::AliHLTOUTHandlerDesc desc=*chainHandler;
+ AliHLTComponentDataType dt=desc;
+
+ pHandler->ReleaseProcessedData(pBuffer, size);
+ }
+ pHLTOUT->MarkDataBlocksProcessed(&(*chainHandler));
}
return iResult;
*/
int ProcessHLTOUT(AliHLTOUT* pHLTOUT, AliESDEvent* esd);
+ /**
+ * Process all kChain-type data blocks of the HLTOUT data.
+ * The function is involed from ProcessHLTOUT as the first step in
+ * the processing.
+ */
+ int ProcessHLTOUTkChain(AliHLTOUT* pHLTOUT);
+
/**
* Load component libraries.
* @param libs string of blank separated library names
AliHLTOUTHandler* pHandler=fpHLTOUT->GetHandler();
if (pHandler) {
if (dynamic_cast<AliHLTOUTHandlerEquId*>(pHandler)!=NULL) {
- AliHLTOUT::AliHLTOUTLockGuard g(fpHLTOUT);
+ AliHLTOUT::AliHLTOUTSelectionGuard g(fpHLTOUT);
fEquipmentId=pHandler->ProcessData(fpHLTOUT);
fpData=NULL;
fDataSize=pHandler->GetProcessedData(fpData);