From 0b0dfd3ae5617f28935546dfd3dfd99a1c43d66a Mon Sep 17 00:00:00 2001 From: Jakob Blomer <jblomer@cern.ch> Date: Fri, 3 May 2019 16:27:27 +0200 Subject: [PATCH] [forest] add possibility to print different types of information in RInputForest::GetInfo() --- tree/forest/v7/inc/ROOT/RForest.hxx | 10 +++++++++- tree/forest/v7/src/RForest.cxx | 21 +++++++++++++++------ 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/tree/forest/v7/inc/ROOT/RForest.hxx b/tree/forest/v7/inc/ROOT/RForest.hxx index a3fb56c8cd4..58fec71df14 100644 --- a/tree/forest/v7/inc/ROOT/RForest.hxx +++ b/tree/forest/v7/inc/ROOT/RForest.hxx @@ -71,6 +71,14 @@ public: } // namespace Detail +/** + * Listing of the different options that can be returned by RInputForest::GetInfo() + */ +enum class EForestInfo { + kSummary, // Forest name, description, number of entries +}; + + // clang-format off /** \class ROOT::Experimental::RInputForest @@ -120,7 +128,7 @@ public: ForestSize_t GetNEntries() { return fNEntries; } - std::string GetInfo(); + std::string GetInfo(const EForestInfo what = EForestInfo::kSummary); /// Analogous to Fill(), fills the default entry of the model. Returns false at the end of the forest. /// On I/O errors, raises an expection. diff --git a/tree/forest/v7/src/RForest.cxx b/tree/forest/v7/src/RForest.cxx index 405c9c4618b..88c1372ba7a 100644 --- a/tree/forest/v7/src/RForest.cxx +++ b/tree/forest/v7/src/RForest.cxx @@ -82,14 +82,23 @@ std::unique_ptr<ROOT::Experimental::RInputForest> ROOT::Experimental::RInputFore return std::make_unique<RInputForest>(std::make_unique<Detail::RPageSourceRoot>(forestName, storage)); } -std::string ROOT::Experimental::RInputForest::GetInfo() { +std::string ROOT::Experimental::RInputForest::GetInfo(const EForestInfo what) { std::ostringstream os; auto name = fSource->GetDescriptor().GetName(); - os << "****************************** FOREST ******************************" << std::endl - << "* Name: " << name << std::setw(57 - name.length()) << "*" << std::endl - << "* Entries: " << std::setw(10) << fNEntries << std::setw(47) << "*" << std::endl - << "********************************************************************" << std::endl; - return os.str(); + + switch (what) { + case EForestInfo::kSummary: + os << "****************************** FOREST ******************************" << std::endl + << "* Name: " << name << std::setw(57 - name.length()) << "*" << std::endl + << "* Entries: " << std::setw(10) << fNEntries << std::setw(47) << "*" << std::endl + << "********************************************************************" << std::endl; + return os.str(); + default: + // Unhandled case, internal error + assert(false); + } + // Never here + return ""; } //------------------------------------------------------------------------------ -- GitLab