]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - HLT/BASE/AliHLTMessage.cxx
Installation of additional header
[u/mrichter/AliRoot.git] / HLT / BASE / AliHLTMessage.cxx
index 75cc551c02a9d38887bbea1f950474890479620b..1dab948e227605ab6b3c5e0865aa64fddf61ed35 100644 (file)
@@ -169,7 +169,9 @@ void AliHLTMessage::ForceWriteInfo(TVirtualStreamerInfo *info, Bool_t /* force *
 
    if (fgEvolution || fEvolution) {
       if (!fInfos) fInfos = new TList();
-      fInfos->Add(info);
+      if (fInfos->FindObject(info->GetName())==NULL) {
+       fInfos->Add(info);
+      }
    }
 }
 
@@ -197,9 +199,15 @@ void AliHLTMessage::IncrementLevel(TVirtualStreamerInfo *info)
 
    TBufferFile::IncrementLevel(info);
 
+   if (!info) return;
    if (fgEvolution || fEvolution) {
       if (!fInfos) fInfos = new TList();
-      fInfos->Add(info);
+
+      // add the streamer info, but only once
+      // this assumes that there is only one version
+      if (fInfos->FindObject(info->GetName())==NULL) {
+       fInfos->Add(info);
+      }
    }
 }
 
@@ -371,8 +379,9 @@ Int_t AliHLTMessage::Uncompress()
 
    Int_t buflen;
    Int_t hdrlen = 2*sizeof(UInt_t);
-   UChar_t *bufcur = (UChar_t*)fBufComp + hdrlen;
-   frombuf((char *&)bufcur, &buflen);
+   char *bufcur1 = fBufComp + hdrlen;
+   frombuf(bufcur1, &buflen);
+   UChar_t *bufcur = (UChar_t*)bufcur1;
    fBuffer  = new char[buflen];
    fBufUncompressed = fBuffer;
    fBufSize = buflen;
@@ -516,3 +525,30 @@ TObject* AliHLTMessage::Extract(const void* pBuffer, unsigned bufferSize, unsign
   }
   return NULL;
 }
+
+TObject* AliHLTMessage::Extract(const char* filename, unsigned verbosity)
+{
+   /// Helper function to extract an object from a file containing the streamed object.
+   /// The returned object must be cleaned by the caller
+  if (!filename) return NULL;
+  
+  AliHLTLogging log;
+  TString input=filename;
+  input+="?filetype=raw";
+  TFile* pFile=new TFile(input);
+  if (!pFile) return NULL;
+  TObject* pObject=NULL;
+  if (!pFile->IsZombie()) {
+    pFile->Seek(0);
+    TArrayC buffer;
+    buffer.Set(pFile->GetSize());
+    if (pFile->ReadBuffer(buffer.GetArray(), buffer.GetSize())==0) {
+      pObject=Extract(buffer.GetArray(), buffer.GetSize(), verbosity);
+    } else {
+      log.LoggingVarargs(kHLTLogError, "AliHLTMessage", "Extract" , __FILE__ , __LINE__ , "failed reading %d byte(s) from file %s", pFile->GetSize(), filename);
+    }
+  }
+
+  delete pFile;
+  return pObject;
+}