]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
using common function for merging of streamer info
authorrichterm <richterm@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 7 Sep 2012 07:07:01 +0000 (07:07 +0000)
committerrichterm <richterm@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 7 Sep 2012 07:07:01 +0000 (07:07 +0000)
HLT/BASE/util/AliHLTRootSchemaEvolutionComponent.cxx
HLT/BASE/util/AliHLTRootSchemaEvolutionComponent.h

index 72010fc4c5eee217077b5458e691c69f9e09ed5e..b9d83000e79c00b7aa44f921289e7c320c8b53a7 100644 (file)
@@ -24,6 +24,7 @@
 #include "AliHLTRootSchemaEvolutionComponent.h"
 #include "AliHLTMessage.h"
 #include "AliHLTReadoutList.h"
+#include "AliHLTMisc.h"
 #include "TObjArray.h"
 #include "TStreamerInfo.h"
 #include "TList.h"
@@ -438,7 +439,7 @@ int AliHLTRootSchemaEvolutionComponent::WriteToFile(const char* filename, const
   if (existingEntry && existingEntry->GetObject()) {
     TObject* cloneObj=existingEntry->GetObject()->Clone();
     if (cloneObj) clone=dynamic_cast<TObjArray*>(cloneObj);
-    if (MergeStreamerInfo(clone, infos)==0) {
+    if (AliHLTMisc::Instance().MergeStreamerInfo(clone, infos)==0) {
       // no change, store with identical version
       version=existingEntry->GetId().GetVersion();
     }
@@ -470,54 +471,6 @@ int AliHLTRootSchemaEvolutionComponent::WriteToFile(const char* filename, const
   return 0;
 }
 
-int AliHLTRootSchemaEvolutionComponent::MergeStreamerInfo(TObjArray* tgt, const TObjArray* src)
-{
-  /// merge streamer info entries from source array to target array
-  /// return 1 if target array has been changed
-
-  // add all existing infos if not existing in the current one, or having
-  // different class version
-  int iResult=0;
-  if (!tgt || !src) return -EINVAL;
-
-  {
-    // check if all infos from the existing entry are in the new entry and with
-    // identical class version
-    TIter next(src);
-    TObject* nextobj=NULL;
-    while ((nextobj=next())) {
-      TStreamerInfo* srcInfo=dynamic_cast<TStreamerInfo*>(nextobj);
-      if (!srcInfo) continue;
-      TString srcInfoName=srcInfo->GetName();
-
-      int i=0;
-      for (; i<tgt->GetEntriesFast(); i++) {
-       if (tgt->At(i)==NULL) continue;
-       if (srcInfoName.CompareTo(tgt->At(i)->GetName())!=0) continue;
-       // TODO: 2010-08-23 some more detailed investigation is needed.
-       // Structures used for data exchange, e.g. AliHLTComponentDataType
-       // or AliHLTEventDDLV1 do not have a class version, but need to be stored in the
-       // streamer info. Strictly speaking not, because those structures are not supposed
-       // to be changed at all, so they should be the same in all versions in the future.
-       // There has been a problem with detecting whether the streamer info is already in
-       // the target array if the srcInfo has class version -1. As it just concerns
-       // structures not going to be changed we can safely skip checking the class version,
-       // as long as the entry is already in the target streamer infos it does not need
-       // to be copied again.
-       if (srcInfo->GetClassVersion()<0) break;
-       TStreamerInfo* tgtInfo=dynamic_cast<TStreamerInfo*>(tgt->At(i));
-       if (tgtInfo && tgtInfo->GetClassVersion()==srcInfo->GetClassVersion()) break;
-      }
-      if (i<tgt->GetEntriesFast()) continue;
-
-      iResult=1;
-      tgt->Add(srcInfo);
-    }
-  }
-
-  return iResult;
-}
-
 AliHLTRootSchemaEvolutionComponent::AliHLTDataBlockItem*
 AliHLTRootSchemaEvolutionComponent::FindItem(AliHLTComponentDataType dt,
                                             AliHLTUInt32_t spec)
index 85da0d2b4812e59f399461bc3b0a266a5b5732bf..29060d1ce831592dec94636137d99c17a71f178a 100644 (file)
@@ -115,12 +115,6 @@ class AliHLTRootSchemaEvolutionComponent : public AliHLTCalibrationProcessor
   /// and adds if it is a new info. 
   int UpdateStreamerInfos(const TList* list, TObjArray* infos) const;
 
-  /// merge streamer info entries from source array to target array
-  /// add all existing infos if not existing in the current one, or having
-  /// different class version
-  /// return 1 if target array has been changed
-  static int MergeStreamerInfo(TObjArray* tgt, const TObjArray* src);
-
   class AliHLTDataBlockItem
   {
   public: