Skip to content

Commit

Permalink
Merge pull request #476 from rest-for-physics/lobis-merge-update
Browse files Browse the repository at this point in the history
Add Merge method to base metadata class
  • Loading branch information
lobis authored Sep 20, 2023
2 parents 2497cd4 + 49dee41 commit c947149
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
4 changes: 4 additions & 0 deletions source/framework/core/inc/TRestMetadata.h
Original file line number Diff line number Diff line change
Expand Up @@ -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&);

/// Making default settings.
virtual void Initialize() {}

Expand Down
11 changes: 11 additions & 0 deletions source/framework/core/src/TRestMetadata.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}

0 comments on commit c947149

Please sign in to comment.