AliHLTOUTTask::AliHLTOUTTask(const char* chains)
:
AliHLTOUT(),
- AliHLTTask(),
- fpDummyTask(NULL),
- fpDummyConfiguration(NULL),
- fBlockDescList()
+ AliHLTDumpTask(chains)
{
// see header file for class documentation
// or
// refer to README to build package
// or
// visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
- TString taskname=chains;
- taskname.ReplaceAll(" ", "_");
- taskname+="_hltouttask";
-
- // This is just a trick to use the existing Task handling, especially the
- // ProcessTask function.
- // 1. The 'BlockFilter' just forwards the data blocks of all specified chains
- // 2. A dummy task is added to the target list in order to set the data segments
- // after forwarding. In case of an empty target list the data is just discarded.
- // That's maybe not the most elegant solution but far less awkward as one would
- // expect.
- fpConfiguration=new AliHLTConfiguration(taskname.Data(), "BlockFilter", chains, NULL);
- TString dummyname=chains;
- dummyname.ReplaceAll(" ", "_");
- dummyname+="_never_used_dummy_";
- fpDummyConfiguration=new AliHLTConfiguration(dummyname.Data(), "BlockFilter", taskname.Data(), NULL);
- if (fpDummyConfiguration) {
- fpDummyTask=new AliHLTTask(fpDummyConfiguration);
- SetTarget(fpDummyTask);
- }
}
AliHLTOUTTask::~AliHLTOUTTask()
{
// see header file for class documentation
-
- // UnsetTarget called automatically
- if (fpDummyTask) delete fpDummyTask;
- fpDummyTask=NULL;
-
- if (fpDummyConfiguration) delete fpDummyConfiguration;
- fpDummyConfiguration=NULL;
-
- if (fpConfiguration) delete fpConfiguration;
- fpConfiguration=NULL;
-}
-
-int AliHLTOUTTask::CustomInit(AliHLTComponentHandler* pCH)
-{
- // see header file for class documentation
- if (!fpDummyTask) return -ENOENT;
- return fpDummyTask->Init(NULL, pCH);
-}
-
-int AliHLTOUTTask::CustomCleanup()
-{
- // see header file for class documentation
- if (!fpDummyTask) return -ENOENT;
- return fpDummyTask->Deinit();
}
int AliHLTOUTTask::GenerateIndex()
{
// see header file for class documentation
int iResult=0;
- if (fpDataBuffer) {
- if (!fpDataBuffer->FindConsumer(fpDummyTask->GetComponent())) {
- // in order to subscribe to the buffers the dummy consumer
- // needs to be set. The dummy task is not in the AliHLTSystem chain
- // and therefor not automatically set.
- fpDataBuffer->SetConsumer(fpDummyTask->GetComponent());
- }
- fBlockDescList.clear();
- if (fpDataBuffer->GetNofSegments()>0) {
- if ((iResult=fpDataBuffer->Subscribe(fpDummyTask->GetComponent(), fBlockDescList))>=0) {
- for (unsigned int i=0; i<fBlockDescList.size(); i++) {
- AliHLTOUTBlockDescriptor desc(fBlockDescList[i].fDataType, fBlockDescList[i].fSpecification, i, this);
- //HLTDebug("adding block %d: %s %#x", i, AliHLTComponent::DataType2Text(fBlockDescList[i].fDataType).c_str(), fBlockDescList[i].fSpecification);
- iResult=AddBlockDescriptor(desc);
- }
- } else {
- HLTError("failed to subscribe to data buffer");
- }
- }
- } else {
- HLTWarning("no data buffer available");
+ const AliHLTComponentBlockDataList& list=GetDataBlocks();
+ for (unsigned int i=0; i<list.size(); i++) {
+ AliHLTOUTBlockDescriptor desc(list[i].fDataType, list[i].fSpecification, i, this);
+ //HLTDebug("adding block %d: %s %#x", i, AliHLTComponent::DataType2Text(list[i].fDataType).c_str(), list[i].fSpecification);
+ iResult=AddBlockDescriptor(desc);
}
return iResult;
}
{
// see header file for class documentation
int iResult=0;
- if (index>=fBlockDescList.size()) return -ENOENT;
- pBuffer=reinterpret_cast<AliHLTUInt8_t*>(fBlockDescList[index].fPtr);
- size=fBlockDescList[index].fSize;
+ const AliHLTComponentBlockDataList& list=GetDataBlocks();
+ if (index>=list.size()) return -ENOENT;
+ pBuffer=reinterpret_cast<AliHLTUInt8_t*>(list[index].fPtr);
+ size=list[index].fSize;
return iResult;
}
int AliHLTOUTTask::ResetInput()
{
// see header file for class documentation
- int iResult=0;
- if (!fpDataBuffer) return 0;
-
- if (fBlockDescList.size()==0 && fpDataBuffer->GetNofPendingConsumers()>0) {
- // not yet subscribed
- fpDataBuffer->Subscribe(fpDummyTask->GetComponent(), fBlockDescList);
- }
-
- for (unsigned int i=0; i<fBlockDescList.size(); i++) {
- fpDataBuffer->Release(&(fBlockDescList[i]), fpDummyTask->GetComponent(), this);
- }
- fBlockDescList.clear();
- return iResult;
+ return ReleaseDataBlocks();
}