From abb64a6138df65dd349d61f8a38d6c1b67686504 Mon Sep 17 00:00:00 2001 From: richterm Date: Fri, 7 Sep 2012 07:05:22 +0000 Subject: [PATCH] moving merging of streamer info arrays from RootSchemaEvolution component to common toolbox --- HLT/rec/AliHLTMiscImplementation.cxx | 58 ++++++++++++++++++++++++++-- HLT/rec/AliHLTMiscImplementation.h | 10 +++-- 2 files changed, 62 insertions(+), 6 deletions(-) diff --git a/HLT/rec/AliHLTMiscImplementation.cxx b/HLT/rec/AliHLTMiscImplementation.cxx index b102f1e7008..592252e7df1 100644 --- a/HLT/rec/AliHLTMiscImplementation.cxx +++ b/HLT/rec/AliHLTMiscImplementation.cxx @@ -1,7 +1,7 @@ // $Id$ //************************************************************************** -//* This file is property of and copyright by the ALICE HLT Project * +//* This file is property of and copyright by the * //* ALICE Experiment at CERN, All rights reserved. * //* * //* Primary Authors: Matthias Richter * @@ -18,8 +18,9 @@ /// @file AliHLTMisc.cxx /// @author Matthias Richter -/// @date -/// @brief Miscellaneous methods for the HLT AliRoot integration +/// @date 2009-07-07 +/// @brief Implementation of various glue functions implemented in dynamically +/// loaded libraries #include "AliHLTMiscImplementation.h" #include "AliHLTLogging.h" @@ -406,6 +407,57 @@ int AliHLTMiscImplementation::InitStreamerInfos(TObjArray* pSchemas) const return 0; } +int AliHLTMiscImplementation::MergeStreamerInfo(TObjArray* tgt, const TObjArray* src, int iVerbosity) const +{ + /// 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(nextobj); + if (!srcInfo) continue; + TString srcInfoName=srcInfo->GetName(); + + int i=0; + for (; iGetEntriesFast(); 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(tgt->At(i)); + if (tgtInfo && tgtInfo->GetClassVersion()==srcInfo->GetClassVersion()) break; + } + if (iGetEntriesFast()) continue; + + iResult=1; + if (iVerbosity>0) { + AliInfo(Form("adding streamer info for class %s version %d", srcInfoName.Data(), srcInfo->GetClassVersion())); + } + tgt->Add(srcInfo); + } + } + + return iResult; +} + void AliHLTMiscImplementation::SetAliESDtrackOnlineModeFlag(bool mode) const { /// set the online mode flag of AliESDtrack diff --git a/HLT/rec/AliHLTMiscImplementation.h b/HLT/rec/AliHLTMiscImplementation.h index 2a89e5b3e05..bb00901b293 100644 --- a/HLT/rec/AliHLTMiscImplementation.h +++ b/HLT/rec/AliHLTMiscImplementation.h @@ -3,9 +3,9 @@ #ifndef ALIHLTMISCIMPLEMENTATION_H #define ALIHLTMISCIMPLEMENTATION_H -//* This file is property of and copyright by the ALICE HLT Project * +//* This file is property of and copyright by the * //* ALICE Experiment at CERN, All rights reserved. * -//* See cxx source for full Copyright notice */ +//* See cxx source for full Copyright notice * /// @file AliHLTMiscImplementation.h /// @author Matthias Richter @@ -14,7 +14,10 @@ /// loaded libraries #include "AliHLTMisc.h" - +/** + * @class AliHLTMiscImplementation + * Implementation of various glue functions provided by AliHLTMisc. + */ class AliHLTMiscImplementation : public AliHLTMisc { public: @@ -48,6 +51,7 @@ class AliHLTMiscImplementation : public AliHLTMisc int InitStreamerInfos(const char* ocdbEntry) const; int InitStreamerInfos(TObjArray* pSchemas) const; + int MergeStreamerInfo(TObjArray* tgt, const TObjArray* src, int iVerbosity=0) const; void SetAliESDtrackOnlineModeFlag(bool mode) const; bool GetAliESDtrackOnlineModeFlag() const; -- 2.39.3