From dd2cea08c4ade332d21366e7c2a5b68cd18a9822 Mon Sep 17 00:00:00 2001 From: Luis Antonio Obis Aparicio Date: Tue, 19 Sep 2023 14:26:43 +0200 Subject: [PATCH 1/3] add Merge to base metadata class --- source/framework/core/inc/TRestMetadata.h | 4 ++++ source/framework/core/src/TRestMetadata.cxx | 11 +++++++++++ 2 files changed, 15 insertions(+) diff --git a/source/framework/core/inc/TRestMetadata.h b/source/framework/core/inc/TRestMetadata.h index e1e1910ef..53f284d59 100644 --- a/source/framework/core/inc/TRestMetadata.h +++ b/source/framework/core/inc/TRestMetadata.h @@ -239,6 +239,10 @@ class TRestMetadata : public TNamed { TRestMetadata* InstantiateChildMetadata(int index, std::string pattern = ""); TRestMetadata* InstantiateChildMetadata(std::string pattern = "", std::string name = ""); + /// Merge the metadata information from another metadata object. + /// Needs to be implemented in the derived class. + virtual void Merge(const TRestMetadata& metadata); + /// Making default settings. virtual void Initialize() {} diff --git a/source/framework/core/src/TRestMetadata.cxx b/source/framework/core/src/TRestMetadata.cxx index 4fcccc1fe..3186c64d5 100644 --- a/source/framework/core/src/TRestMetadata.cxx +++ b/source/framework/core/src/TRestMetadata.cxx @@ -2661,3 +2661,14 @@ TString TRestMetadata::GetWarningMessage() { else return "No warning!"; } + +void TRestMetadata::Merge(const TRestMetadata& metadata) { + if (!metadata.InheritsFrom(ClassName())) { + RESTError << "TRestMetadata::Merge. Metadata is not of type " << ClassName() << RESTendl; + exit(1); + } + + if (fName.IsNull()) { + fName = metadata.GetName(); + } +} \ No newline at end of file From af17077e6532283e77f011726ca8dc7a288a8cb5 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 19 Sep 2023 12:43:42 +0000 Subject: [PATCH 2/3] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- source/framework/core/src/TRestMetadata.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/framework/core/src/TRestMetadata.cxx b/source/framework/core/src/TRestMetadata.cxx index 3186c64d5..82f31fa72 100644 --- a/source/framework/core/src/TRestMetadata.cxx +++ b/source/framework/core/src/TRestMetadata.cxx @@ -2671,4 +2671,4 @@ void TRestMetadata::Merge(const TRestMetadata& metadata) { if (fName.IsNull()) { fName = metadata.GetName(); } -} \ No newline at end of file +} From d1d38da240fde8da868a750613a906f3cbbfc895 Mon Sep 17 00:00:00 2001 From: Luis Antonio Obis Aparicio Date: Tue, 19 Sep 2023 16:21:51 +0200 Subject: [PATCH 3/3] clean definition --- source/framework/core/inc/TRestMetadata.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/framework/core/inc/TRestMetadata.h b/source/framework/core/inc/TRestMetadata.h index 53f284d59..cea8ac1c7 100644 --- a/source/framework/core/inc/TRestMetadata.h +++ b/source/framework/core/inc/TRestMetadata.h @@ -241,7 +241,7 @@ class TRestMetadata : public TNamed { /// Merge the metadata information from another metadata object. /// Needs to be implemented in the derived class. - virtual void Merge(const TRestMetadata& metadata); + virtual void Merge(const TRestMetadata&); /// Making default settings. virtual void Initialize() {}