]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
adding helper function to extract an object from a binary file containing the stream...
authorrichterm <richterm@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 15 Oct 2009 19:17:02 +0000 (19:17 +0000)
committerrichterm <richterm@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 15 Oct 2009 19:17:02 +0000 (19:17 +0000)
HLT/BASE/AliHLTMessage.cxx
HLT/BASE/AliHLTMessage.h

index 75cc551c02a9d38887bbea1f950474890479620b..e9598c1b7c595655126c0bff4435efafd8736ae8 100644 (file)
@@ -516,3 +516,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;
+}
index f75d172fedbca5d470145fbb60222ff229700933..cbb5f46cf00343c014a0bbe90d1b1cbff049365a 100644 (file)
@@ -159,6 +159,12 @@ public:
     */
    static TObject* Extract(const void* pBuffer, unsigned bufferSize, unsigned verbosity=0);
 
+   /**
+    * Helper function to extract an object from  a file containing the streamed object.
+    * The returned object must be cleaned by the caller
+    */
+   static TObject* Extract(const char* filename, unsigned verbosity=0);
+
 private:
    UInt_t   fWhat;        //!Message type
    TClass  *fClass;       //!If message is kMESS_OBJECT pointer to object's class