Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-17 08:54:06

0001 //------------------------------- -*- C++ -*- -------------------------------//
0002 // Copyright Celeritas contributors: see top-level COPYRIGHT file for details
0003 // SPDX-License-Identifier: (Apache-2.0 OR MIT)
0004 //---------------------------------------------------------------------------//
0005 //! \file corecel/io/OutputRegistry.hh
0006 //---------------------------------------------------------------------------//
0007 #pragma once
0008 
0009 #include <iosfwd>
0010 #include <map>
0011 #include <memory>
0012 #include <string>
0013 
0014 #include "corecel/cont/EnumArray.hh"
0015 
0016 #include "OutputInterface.hh"
0017 
0018 namespace celeritas
0019 {
0020 //---------------------------------------------------------------------------//
0021 /*!
0022  * Store classes that can output data at the end of the run.
0023  *
0024  * Each output interface defines a category (e.g. input, result, system) and a
0025  * name. The output manager then writes the JSON output from that entry into a
0026  * nested database:
0027  * \verbatim
0028    {"category": {"label": "data"}}
0029  * \endverbatim
0030  */
0031 class OutputRegistry
0032 {
0033   public:
0034     //!@{
0035     //! \name Type aliases
0036     using SPConstInterface = std::shared_ptr<OutputInterface const>;
0037     //!@}
0038 
0039   public:
0040     // Add an interface for writing
0041     void insert(SPConstInterface);
0042 
0043     // Write output to the given JSON object
0044     void output(JsonPimpl*) const;
0045 
0046     // Dump all outputs as JSON to the given stream
0047     void output(std::ostream* os) const;
0048 
0049     // Whether no output has been registered
0050     bool empty() const;
0051 
0052   private:
0053     using Category = OutputInterface::Category;
0054 
0055     // Interfaces by category
0056     EnumArray<Category, std::map<std::string, SPConstInterface>> interfaces_;
0057 };
0058 
0059 //---------------------------------------------------------------------------//
0060 }  // namespace celeritas