]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/BASE/AliHLTOUTHandlerDetectorDDL.cxx
bugfix 88038: inconsistent handling of reference counters in library manager
[u/mrichter/AliRoot.git] / HLT / BASE / AliHLTOUTHandlerDetectorDDL.cxx
CommitLineData
7c4d1228 1// $Id$
2
3//**************************************************************************
4//* This file is property of and copyright by the ALICE HLT Project *
5//* ALICE Experiment at CERN, All rights reserved. *
6//* *
7//* Primary Authors: Matthias Richter <Matthias.Richter@ift.uib.no> *
8//* for The ALICE HLT Project. *
9//* *
10//* Permission to use, copy, modify and distribute this software and its *
11//* documentation strictly for non-commercial purposes is hereby granted *
12//* without fee, provided that the above copyright notice appears in all *
13//* copies and that both the copyright notice and this permission notice *
14//* appear in the supporting documentation. The authors make no claims *
15//* about the suitability of this software for any purpose. It is *
16//* provided "as is" without express or implied warranty. *
17//**************************************************************************
18
19/** @file AliHLTOUTHandlerDetectorDDL.cxx
20 @author Matthias Richter
21 @date 2008-09-09
22 @brief HLTOUT handler returning equipment id from data type and spec.
23*/
24
25#include "AliHLTOUTHandlerDetectorDDL.h"
26#include "AliHLTOUT.h"
27#include "AliHLTDAQ.h"
28
29/** ROOT macro for the implementation of ROOT specific class methods */
30ClassImp(AliHLTOUTHandlerDetectorDDL)
31
32AliHLTOUTHandlerDetectorDDL::AliHLTOUTHandlerDetectorDDL(const char* detector, AliHLTComponentDataType dt)
33 :
34 fDDLOffset(-1),
35 fNumberOfDDLs(-1),
36 fDt(dt)
37{
38 // see header file for class documentation
39 // or
40 // refer to README to build package
41 // or
42 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
43
44 fDDLOffset=AliHLTDAQ::DdlIDOffset(detector);
45 fNumberOfDDLs=AliHLTDAQ::NumberOfDdls(detector);
46}
47
48AliHLTOUTHandlerDetectorDDL::~AliHLTOUTHandlerDetectorDDL()
49{
50 // see header file for class documentation
51}
52
53int AliHLTOUTHandlerDetectorDDL::ProcessData(AliHLTOUT* pData)
54{
55 // see header file for class documentation
56 if (!pData) return -EINVAL;
57 if (fDDLOffset<0 || fNumberOfDDLs<0) return -ENODEV;
58
59 static int errorCount=0;
60 const int maxErrorCount=10;
61 AliHLTComponentDataType dt=kAliHLTVoidDataType;
62 AliHLTUInt32_t spec=kAliHLTVoidDataSpec;
63 int iResult=pData->GetDataBlockDescription(dt, spec);
64 if (iResult>=0 && dt!=kAliHLTVoidDataType && spec!=kAliHLTVoidDataSpec) {
65 if (dt==fDt) {
66 int ddlNo=0;
67 for (;ddlNo<32 && ddlNo<fNumberOfDDLs; ddlNo++) {
68 if (spec&(0x1<<ddlNo)) break;
69 }
70 if (ddlNo>=32 || ddlNo>=fNumberOfDDLs) {
71 HLTError("invalid specification 0x%08x: can not extract DDL id for data block %s", spec, AliHLTComponent::DataType2Text(dt).c_str());
72 iResult=-ENODEV;
73 } else if (spec^(0x1<<ddlNo)) {
74 iResult=-EEXIST;
75 HLTError("multiple links set in specification 0x%08x: can not extract DDL id for data block %s", spec, AliHLTComponent::DataType2Text(dt).c_str());
76 } else {
77 iResult=fDDLOffset+ddlNo;
78 }
79 } else {
80 if (errorCount++<10) {
81 HLTError("wrong data type: expecting %s, got %s%s",
82 AliHLTComponent::DataType2Text(fDt).c_str(),
83 AliHLTComponent::DataType2Text(dt).c_str(),
84 errorCount==maxErrorCount?"; suppressing further error messages":"");
85 }
86 iResult=-EBADF;
87 }
88 } else {
89 if (errorCount++<10) {
90 HLTError("can not get a valid data type and specification from HLTOUT: type %s, specification 0x%08x%s",
91 AliHLTComponent::DataType2Text(dt).c_str(), spec,
92 errorCount==maxErrorCount?"; suppressing further error messages":"");
93 }
94 iResult=-ENODATA;
95 }
96 return iResult;
97}