CORSIKA  @c8_version@
The framework to simulate particle cascades for astroparticle physics
BaseOutput.hpp
1 /*
2  * (c) Copyright 2021 CORSIKA Project, corsika-project@lists.kit.edu
3  *
4  * This software is distributed under the terms of the GNU General Public
5  * Licence version 3 (GPL Version 3). See file LICENSE for a full version of
6  * the license.
7  */
8 #pragma once
9 
11 #include <corsika/output/Configurable.hpp>
12 #include <boost/filesystem.hpp>
13 #include <yaml-cpp/yaml.h>
14 
15 namespace corsika {
16 
21  class BaseOutput : public Configurable {
22 
23  protected:
24  BaseOutput() = default;
25  virtual ~BaseOutput() = default;
26 
27  public:
31  virtual void startOfLibrary(boost::filesystem::path const& directory) = 0;
32 
38  virtual void startOfShower(unsigned int const /*showerId*/) {}
39 
45  virtual void endOfShower(unsigned int const showerId) = 0; // LCOV_EXCL_LINE
46 
50  virtual void endOfLibrary() = 0; // LCOV_EXCL_LINE
51 
55  bool isInit() const { return is_init_; }
56 
60  static auto getLogger() { return logger_; }
61 
65  virtual YAML::Node getSummary() const { return YAML::Node(); }
66 
67  protected:
71  void setInit(bool const v) { is_init_ = v; }
72 
73  private:
74  bool is_init_{false};
75  inline static auto logger_{get_logger("output")};
76  };
77 
78 } // namespace corsika
virtual void startOfShower(unsigned int const)
Called at the start of each event/shower.
Definition: BaseOutput.hpp:38
virtual void startOfLibrary(boost::filesystem::path const &directory)=0
Called at the start of each run.
void setInit(bool const v)
Set init flag.
Definition: BaseOutput.hpp:71
This is the base class for all classes that have YAML representations of their configurations.
std::shared_ptr< spdlog::logger > get_logger(std::string const &name, bool const defaultlog=false)
Get a smart pointer to an existing logger.
bool isInit() const
Flag to indicate readiness.
Definition: BaseOutput.hpp:55
CORSIKA8 logging utilities.
virtual YAML::Node getSummary() const
Provide YAML Summary for this BaseOutput.
Definition: BaseOutput.hpp:65
virtual void endOfShower(unsigned int const showerId)=0
Called at the end of each event/shower.
static auto getLogger()
The output logger.
Definition: BaseOutput.hpp:60
`, since they are used everywhere as integral part of the framework.
virtual void endOfLibrary()=0
Called at the end of each run.
This is the base class for all outputs so that they can be stored in homogeneous containers.
Definition: BaseOutput.hpp:21