// visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
#include <cerrno>
+#include <cassert>
#include "AliHLTOUT.h"
/** ROOT macro for the implementation of ROOT specific class methods */
fFlags(0),
fBlockDescList(),
fCurrent(fBlockDescList.begin()),
- fpBuffer(NULL)
+ fpBuffer(NULL),
+ fDataHandlers()
{
// see header file for class documentation
// or
// see header file for class documentation
}
+int AliHLTOUT::Init()
+{
+ // see header file for class documentation
+ int iResult=0;
+ SetStatusFlag(kCollecting);
+ if ((iResult=GenerateIndex())>=0) {
+ if ((iResult=InitHandlers())>=0) {
+ }
+ }
+ ClearStatusFlag(kCollecting);
+ return iResult;
+}
+
int AliHLTOUT::GetNofDataBlocks()
{
// see header file for class documentation
return fBlockDescList.size();
}
-int AliHLTOUT::SelectFirstDataBlock(AliHLTComponentDataType dt, AliHLTUInt32_t spec)
+int AliHLTOUT::SelectFirstDataBlock(AliHLTComponentDataType dt, AliHLTUInt32_t spec,
+ AliHLTModuleAgent::AliHLTOUTHandlerType handlerType)
{
// see header file for class documentation
if (CheckStatusFlag(kLocked)) return -EPERM;
fCurrent=fBlockDescList.begin();
fSearchDataType=dt;
fSearchSpecification=spec;
+ //fSearchHandlerType=handlerType;
return FindAndSelectDataBlock();
}
{
// see header file for class documentation
if (CheckStatusFlag(kLocked)) return -EPERM;
+ if (fCurrent==fBlockDescList.end()) return -ENOENT;
fCurrent++;
return FindAndSelectDataBlock();
}
if (CheckStatusFlag(kLocked)) return -EPERM;
int iResult=-ENOENT;
while (fCurrent!=fBlockDescList.end() && iResult==-ENOENT) {
- if ((fSearchDataType==kAliHLTAnyDataType || (*fCurrent)==fSearchDataType) &&
- fSearchSpecification==kAliHLTVoidDataSpec || (*fCurrent)==fSearchSpecification) {
- iResult=0;
+ if ((*fCurrent)==fSearchDataType &&
+ fSearchSpecification==kAliHLTVoidDataSpec || (*fCurrent)==fSearchSpecification &&
+ 1/*fSearchHandlerType==AliHLTModuleAgent::kUnknownOutput*/) {
+ iResult=fCurrent->GetIndex();
// TODO: check the byte order on the current system and the byte order of the
// data block, print warning when missmatch and user did not check
- AliHLTOUTByteOrder_t blockBO=CheckByteOrder();
+ //AliHLTOUTByteOrder_t blockBO=CheckByteOrder();
+ CheckByteOrder();
/*
if (blockBO!=fByteOrder) {
SetStatusFlag(kByteOrderWarning);
// TODO: check the alignment on the current system and the alignment of the
// data block, print warning when missmatch and user did not check
ClearStatusFlag(kAlignmentChecked);
+
+ break;
}
fCurrent++;
}
return iResult;
}
+AliHLTUInt32_t AliHLTOUT::GetDataBlockIndex()
+{
+ // see header file for class documentation
+ if (fCurrent==fBlockDescList.end()) return AliHLTOUTInvalidIndex;
+ return fCurrent->GetIndex();
+}
+
int AliHLTOUT::GetDataBuffer(const AliHLTUInt8_t* &pBuffer, AliHLTUInt32_t& size)
{
// see header file for class documentation
AliHLTOUT::AliHLTOUTByteOrder_t AliHLTOUT::CheckByteOrder()
{
+ // see header file for class documentation
if (fCurrent!=fBlockDescList.end()) {
SetStatusFlag(kByteOrderChecked);
AliHLTOUT::AliHLTOUTByteOrder_t order=CheckBlockByteOrder((*fCurrent).GetIndex());
int AliHLTOUT::CheckAlignment(AliHLTOUT::AliHLTOUTDataType_t type)
{
+ // see header file for class documentation
if (fCurrent!=fBlockDescList.end()) {
SetStatusFlag(kAlignmentChecked);
int alignment=CheckBlockAlignment((*fCurrent).GetIndex(), type);
}
return -ENOENT;
}
+
+int AliHLTOUT::InitHandlers()
+{
+ // see header file for class documentation
+ int iResult=0;
+ AliHLTOUTIndexList remnants;
+ for (iResult=SelectFirstDataBlock(kAliHLTAnyDataType, kAliHLTVoidDataSpec); iResult>=0; iResult=SelectNextDataBlock()) {
+ remnants.push_back(GetDataBlockIndex());
+ AliHLTComponentDataType dt=kAliHLTVoidDataType;
+ AliHLTUInt32_t spec=kAliHLTVoidDataSpec;
+ if ((iResult=GetDataBlockDescription(dt, spec))<0) break;
+ for (AliHLTModuleAgent* pAgent=AliHLTModuleAgent::GetFirstAgent(); pAgent && iResult>=0; pAgent=AliHLTModuleAgent::GetNextAgent()) {
+ AliHLTModuleAgent::AliHLTOUTHandlerDesc handlerDesc;
+ if (pAgent->GetHandlerDescription(dt, spec, &handlerDesc)>0) {
+ AliHLTOUTHandlerListEntry entry(pAgent->GetOutputHandler(dt, spec), handlerDesc, pAgent, GetDataBlockIndex());
+ iResult=InsertHandler(entry);
+ remnants.pop_back();
+ break;
+ }
+ }
+ }
+ if (remnants.size()>0) {
+ HLTWarning("no handlers found for %d data blocks out of %d", remnants.size(), GetNofDataBlocks());
+ vector<AliHLTOUTBlockDescriptor>::iterator block=fBlockDescList.begin();
+ for (AliHLTOUTIndexList::iterator element=remnants.begin(); element!=remnants.end(); element++) {
+ for (int trials=0; trials<2; trials++) {
+ do {
+ // we start searching the index from the current position in the block list
+ if ((*block).GetIndex()==*element) break;
+ } while ((++block)!=fBlockDescList.end());
+ if (block==fBlockDescList.end()) {
+ // rewind and try again
+ block=fBlockDescList.begin();
+ }
+ }
+ assert(block!=fBlockDescList.end());
+ if (block!=fBlockDescList.end()) {
+ HLTDebug(" %s", AliHLTComponent::DataType2Text((AliHLTComponentDataType)*block).c_str());
+ }
+ }
+ }
+ return iResult;
+}
+
+int AliHLTOUT::InsertHandler(const AliHLTOUTHandlerListEntry &entry)
+{
+ // see header file for class documentation
+ int iResult=0;
+ vector<AliHLTOUTHandlerListEntry>::iterator element=fDataHandlers.begin();
+ while (element!=fDataHandlers.end()) {
+ if (entry==(*element)) break;
+ element++;
+ }
+ if (element==fDataHandlers.end()) {
+ fDataHandlers.push_back(entry);
+ } else {
+
+ }
+ return iResult;
+}
+
+AliHLTOUT::AliHLTOUTHandlerListEntry::AliHLTOUTHandlerListEntry(AliHLTOUTHandler* pHandler,
+ AliHLTModuleAgent::AliHLTOUTHandlerDesc& handlerDesc,
+ AliHLTModuleAgent* pAgent,
+ AliHLTUInt32_t index)
+ :
+ fpHandler(pHandler),
+ fHandlerDesc(handlerDesc),
+ fpAgent(pAgent),
+ fBlocks()
+{
+ // see header file for class documentation
+ fBlocks.push_back(index);
+}
+
+AliHLTOUT::AliHLTOUTHandlerListEntry::AliHLTOUTHandlerListEntry(const AliHLTOUTHandlerListEntry& src)
+ :
+ fpHandler(src.fpHandler),
+ fHandlerDesc(src.fHandlerDesc),
+ fpAgent(src.fpAgent),
+ fBlocks()
+{
+ // see header file for class documentation
+ fBlocks.assign(src.fBlocks.begin(), src.fBlocks.end());
+}
+
+AliHLTOUT::AliHLTOUTHandlerListEntry::~AliHLTOUTHandlerListEntry()
+{
+ // see header file for class documentation
+}
+
+AliHLTOUT::AliHLTOUTHandlerListEntry& AliHLTOUT::AliHLTOUTHandlerListEntry::operator=(const AliHLTOUTHandlerListEntry& src)
+{
+ // see header file for class documentation
+ fpHandler=src.fpHandler;
+ fHandlerDesc=src.fHandlerDesc;
+ fpAgent=src.fpAgent;
+ fBlocks.assign(src.fBlocks.begin(), src.fBlocks.end());
+ return *this;
+}
+
+AliHLTUInt32_t AliHLTOUT::AliHLTOUTHandlerListEntry::operator[](int i) const
+{
+ // see header file for class documentation
+ return fBlocks.size()>i?fBlocks[i]:AliHLTOUTInvalidIndex;
+}
+
+bool AliHLTOUT::AliHLTOUTHandlerListEntry::operator==(const AliHLTOUTHandlerListEntry& entry) const
+{
+ // see header file for class documentation
+ assert(0); // not yet implemented
+ return false;
+}
+
+void AliHLTOUT::AliHLTOUTHandlerListEntry::AddIndex(AliHLTUInt32_t index)
+{
+ // see header file for class documentation
+ fBlocks.push_back(index);
+}