From cedacf87707a7933fe80baefb4909372531cea31 Mon Sep 17 00:00:00 2001 From: Remy Prechelt <prechelt@hawaii.edu> Date: Sat, 6 Feb 2021 23:51:10 -1000 Subject: [PATCH] Support writing summary files for each output. --- corsika/detail/modules/ObservationPlane.inl | 13 ------------- corsika/detail/output/OutputManager.inl | 16 ++++++++++++---- corsika/output/BaseOutput.hpp | 4 ++-- 3 files changed, 14 insertions(+), 19 deletions(-) diff --git a/corsika/detail/modules/ObservationPlane.inl b/corsika/detail/modules/ObservationPlane.inl index 3b04a16db..3f11726d5 100644 --- a/corsika/detail/modules/ObservationPlane.inl +++ b/corsika/detail/modules/ObservationPlane.inl @@ -151,19 +151,6 @@ namespace corsika { energy_ground_ / 1_GeV, count_ground_); } - // template <typename TOutput> - // YAML::Node ObservationPlane<TOutput>::getFinalResults() const { - - // // construct the top-level node - // YAML::Node node; - - // node["energy_at_ground"] = energy_ground_ / 1 GeV; - // node["count_at_ground"] = count_ground_; - - // return node; - - // } - template <typename TOutput> YAML::Node ObservationPlane<TOutput>::getConfig() const { using namespace units::si; diff --git a/corsika/detail/output/OutputManager.inl b/corsika/detail/output/OutputManager.inl index e839c1daf..ead11a08f 100644 --- a/corsika/detail/output/OutputManager.inl +++ b/corsika/detail/output/OutputManager.inl @@ -20,7 +20,6 @@ namespace corsika { - void OutputManager::writeNode(YAML::Node const& node, std::filesystem::path const& path) const { @@ -61,7 +60,6 @@ namespace corsika { // create a quick lambda function to convert a time-instance to a string auto timeToString = [&](auto const time) -> std::string { - // the format for our date string auto format{"%d/%m/%Y %H:%M:%S %Z"}; @@ -220,8 +218,18 @@ namespace corsika { throw std::runtime_error("endOfLibrary() called in invalid state."); } - // forward the endOfLibrary() call to all the registered outputs - for (auto& [name, output] : outputs_) { output.get().endOfLibrary(); } + // write the summary for each output and forward the endOfLibrary call() + for (auto& [name, output] : outputs_) { + + // we get the summary for each output as a YAML node + auto summary{outputs_.at(name).get().getSummary()}; + + // write the summary for this output to the file + writeNode(summary, root_ / name / "summary.yaml"); + + // and forward the end of library call + output.get().endOfLibrary(); + } // and the library has finished state_ = OutputState::LibraryFinished; diff --git a/corsika/output/BaseOutput.hpp b/corsika/output/BaseOutput.hpp index c79965381..a5ebc483a 100644 --- a/corsika/output/BaseOutput.hpp +++ b/corsika/output/BaseOutput.hpp @@ -52,9 +52,9 @@ namespace corsika { virtual YAML::Node getConfig() const = 0; /** - * Get final text outputs for the config file. + * Get any summary information for the entire library. */ - virtual YAML::Node getFinalOutput() { return YAML::Node(); }; + virtual YAML::Node getSummary() { return YAML::Node(); }; }; } // namespace corsika -- GitLab