Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Merge method to base metadata class #476

Merged
merged 4 commits into from
Sep 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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();
}
}