![]() |
|
|||
File indexing completed on 2025-09-15 08:55:05
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/OutputInterface.hh 0006 //---------------------------------------------------------------------------// 0007 #pragma once 0008 0009 #include <iosfwd> // IWYU pragma: export 0010 #include <string> // IWYU pragma: export 0011 #include <string_view> // IWYU pragma: export 0012 0013 namespace celeritas 0014 { 0015 //---------------------------------------------------------------------------// 0016 struct JsonPimpl; 0017 0018 //---------------------------------------------------------------------------// 0019 /*! 0020 * Pure abstract interface for writing metadata output to JSON. 0021 * 0022 * At the end of the program/run, the OutputRegistry will call the "output" 0023 * method on all interfaces. 0024 * 0025 * \todo Perhaps another output method for saving a schema? 0026 */ 0027 class OutputInterface 0028 { 0029 public: 0030 //! Output category (TODO: could replace with string/cstring?) 0031 enum class Category 0032 { 0033 input, 0034 result, 0035 system, 0036 internal, 0037 size_ 0038 }; 0039 0040 public: 0041 //! Category of data to write 0042 virtual Category category() const = 0; 0043 0044 //! Key for the entry inside the category. 0045 virtual std::string_view label() const = 0; 0046 0047 // Write output to the given JSON object 0048 virtual void output(JsonPimpl*) const = 0; 0049 0050 protected: 0051 // Protected destructor prevents direct deletion of pointer-to-interface 0052 ~OutputInterface() = default; 0053 }; 0054 0055 //---------------------------------------------------------------------------// 0056 // FREE FUNCTIONS 0057 //---------------------------------------------------------------------------// 0058 0059 // Get a string representation of the category 0060 char const* to_cstring(OutputInterface::Category value); 0061 0062 // Get the JSON representation of a single output (mostly for testing) 0063 std::string to_string(OutputInterface const& output); 0064 0065 // Stream the JSON representation of a single output 0066 std::ostream& operator<<(std::ostream&, OutputInterface const& output); 0067 0068 //---------------------------------------------------------------------------// 0069 } // namespace celeritas
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |