// visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
}
+AliAltroDecoder* AliHLTTPCDigitReaderDecoder::fgpFreeInstance=NULL;
+AliAltroDecoder* AliHLTTPCDigitReaderDecoder::fgpIssuedInstance=NULL;
+
AliHLTTPCDigitReaderDecoder::~AliHLTTPCDigitReaderDecoder()
{
// see header file for class documentation
if(fAltroDecoder){
- delete fAltroDecoder;
+ ReleaseDecoderInstance(fAltroDecoder);
}
if(fAltroBunch){
delete fAltroBunch;
if(!fMapping){
fMapping = new AliHLTTPCMapping(patch);
}
+ fAltroDecoder=GetDecoderInstance();
if(!fAltroDecoder){
- fAltroDecoder = new AliAltroDecoder();
+ return -ENODEV;
}
if(!fAltroBunch){
fAltroBunch = new AliAltroBunch();
return 0;
}
+int AliHLTTPCDigitReaderDecoder::Reset()
+{
+ // see header file for class documentation
+ fAltroData.Reset();
+ fAltroData.SetIsComplete(false);
+ if (fAltroBunch) {
+ fAltroBunch->SetBunchSize(0);
+ fAltroBunch->SetData(NULL);
+ }
+ if (fAltroDecoder) ReleaseDecoderInstance(fAltroDecoder);
+ fAltroDecoder=NULL;
+ return 0;
+}
+
void AliHLTTPCDigitReaderDecoder::SetUnsorted(bool unsorted)
{
// see header file for class documentation
bool AliHLTTPCDigitReaderDecoder::NextChannel()
{
// see header file for class documentation
+ if (!fAltroDecoder) return false;
Bool_t result=fAltroDecoder->NextChannel(&fAltroData);
if(result && !fMapping->IsValidHWAddress(fAltroData.GetHadd())){
result = fAltroDecoder->NextChannel(&fAltroData);
return 0;
}
}
+
+int AliHLTTPCDigitReaderDecoder::GetRCUTrailerSize()
+{
+ // see header file for class documentation
+ if(fAltroDecoder){
+ return fAltroDecoder->GetRCUTrailerSize();
+ }
+ return 0;
+}
+
+bool AliHLTTPCDigitReaderDecoder::GetRCUTrailerData(UChar_t*& trData)
+{
+ // see header file for class documentation
+ if(fAltroDecoder){
+ return fAltroDecoder->GetRCUTrailerData(trData);
+ }
+ return false;
+}
+
+AliAltroDecoder* AliHLTTPCDigitReaderDecoder::GetDecoderInstance()
+{
+ // see header file for class documentation
+
+ // for the moment only a singleton of the decoder is foreseen
+ // could be extended but very unlikly to be worth the effort
+ // because AliAltroDecoder sooner or later will be deprecated.
+
+ // This is just a poor man's solution, no synchronization for the
+ // moment
+ if (fgpIssuedInstance) {
+ AliHLTLogging log;
+ log.LoggingVarargs(kHLTLogError, "AliHLTTPCDigitReaderDecoder", "GetDecoderInstance" , __FILE__ , __LINE__ ,
+ "instance of AltroDecoder has not been released or multiple instances requested. Only available as global singleton for DigitReaderDecoder");
+ return NULL;
+ }
+
+ if (!fgpFreeInstance) fgpFreeInstance=new AliAltroDecoder;
+ fgpIssuedInstance=fgpFreeInstance;
+ fgpFreeInstance=NULL;
+ return fgpIssuedInstance;
+}
+
+void AliHLTTPCDigitReaderDecoder::ReleaseDecoderInstance(AliAltroDecoder* pInstance)
+{
+ // see header file for class documentation
+ if (!pInstance) return;
+ if (pInstance!=fgpIssuedInstance) {
+ AliHLTLogging log;
+ log.LoggingVarargs(kHLTLogError, "AliHLTTPCDigitReaderDecoder", "ReleaseDecoderInstance" , __FILE__ , __LINE__ ,
+ "wrong instance %p, expecting %p", pInstance, fgpIssuedInstance);
+ return;
+ }
+ fgpFreeInstance=fgpIssuedInstance;
+ fgpIssuedInstance=NULL;
+}