From 51f948f50bfde1076ea8badd2265476d629eeae6 Mon Sep 17 00:00:00 2001 From: Remy Prechelt <prechelt@hawaii.edu> Date: Wed, 7 Apr 2021 22:12:19 -1000 Subject: [PATCH] Add a DummyOutputManager for use in tests. --- corsika/detail/output/DummyOutputManager.inl | 27 ++++++++ corsika/output/DummyOutputManager.hpp | 70 ++++++++++++++++++++ 2 files changed, 97 insertions(+) create mode 100644 corsika/detail/output/DummyOutputManager.inl create mode 100644 corsika/output/DummyOutputManager.hpp diff --git a/corsika/detail/output/DummyOutputManager.inl b/corsika/detail/output/DummyOutputManager.inl new file mode 100644 index 000000000..6a9d113e8 --- /dev/null +++ b/corsika/detail/output/DummyOutputManager.inl @@ -0,0 +1,27 @@ +/* + * (c) Copyright 2021 CORSIKA Project, corsika-project@lists.kit.edu + * + * This software is distributed under the terms of the GNU General Public + * Licence version 3 (GPL Version 3). See file LICENSE for a full version of + * the license. + */ +#pragma once + +namespace corsika { + + DummyOutputManager::DummyOutputManager() {} + + DummyOutputManager::~DummyOutputManager() {} + + template <typename TOutput> + void DummyOutputManager::add(std::string const& name, TOutput& output) {} + + void DummyOutputManager::startOfLibrary() {} + + void DummyOutputManager::startOfShower() {} + + void DummyOutputManager::endOfShower() {} + + void DummyOutputManager::endOfLibrary() {} + +} // namespace corsika diff --git a/corsika/output/DummyOutputManager.hpp b/corsika/output/DummyOutputManager.hpp new file mode 100644 index 000000000..fc5cf4647 --- /dev/null +++ b/corsika/output/DummyOutputManager.hpp @@ -0,0 +1,70 @@ +/* + * (c) Copyright 2021 CORSIKA Project, corsika-project@lists.kit.edu + * + * This software is distributed under the terms of the GNU General Public + * Licence version 3 (GPL Version 3). See file LICENSE for a full version of + * the license. + */ +#pragma once + +namespace corsika { + + /*! + * An output manager that does nothing. + */ + class DummyOutputManager final { + + public: + /** + * Construct an OutputManager instance with a name in a given directory. + * + * @param name The name of this output collection. + * @param dir The directory where the output directory will be stored. + */ + DummyOutputManager(); + + /** + * Handle graceful closure of the outputs upon destruction. + */ + ~DummyOutputManager(); + + /** + * Register an existing output to this manager. + * + * @param name The unique name of this output. + * @param args... These are perfect forwarded to the + * constructor of the output. + */ + template <typename TOutput> + void add(std::string const& name, TOutput& output); + + /** + * Called at the start of each library. + * + * This iteratively calls startOfLibrary on each registered output. + */ + void startOfLibrary(); + + /** + * Called at the start of each event/shower. + * This iteratively calls startOfEvent on each registered output. + */ + void startOfShower(); + + /** + * Called at the end of each event/shower. + * This iteratively calls endOfEvent on each registered output. + */ + void endOfShower(); + + /** + * Called at the end of each library. + * This iteratively calls endOfLibrary on each registered output. + */ + void endOfLibrary(); + + }; // class DummyOutputManager + +} // namespace corsika + +#include <corsika/detail/output/DummyOutputManager.inl> -- GitLab