#include <cerrno>
#include <cassert>
#include "AliHLTOUT.h"
+#include "AliHLTMessage.h"
#include "TSystem.h"
#include "TClass.h"
#include "TROOT.h"
fDataHandlers(),
fbVerbose(true),
fLog()
+ , fpDataObject(NULL)
+ , fpObjectBuffer(NULL)
+ , fObjectBufferSize(0)
+ , fCurrentEventId(kAliHLTVoidEventID)
{
// see header file for class documentation
// or
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;
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);
return iResult;
}
-int AliHLTOUT::SelectDataBlocks(const AliHLTOUTHandlerListEntry* pHandlerDesc)
+int AliHLTOUT::SelectDataBlocks(const AliHLTOUTHandlerListEntry* pHandlerEntry)
{
// see header file for class documentation
int iResult=0;
- if (!pHandlerDesc) return 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()==*pHandlerDesc && pHandlerDesc->HasIndex(block->GetIndex()))
+ if (block->GetHandlerDesc()==*pHandlerEntry && pHandlerEntry->HasIndex(block->GetIndex())) {
block->Select(true);
- else
+ 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;
}
}
ResetInput();
+ fCurrentEventId=kAliHLTVoidEventID;
return iResult;
}
}
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;
+}