Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-17 08:53:38

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 celeritas/ext/RootJsonDumper.hh
0006 //---------------------------------------------------------------------------//
0007 #pragma once
0008 
0009 #include <iosfwd>
0010 
0011 #include "corecel/Config.hh"
0012 
0013 #include "corecel/Assert.hh"
0014 
0015 namespace celeritas
0016 {
0017 struct ImportData;
0018 
0019 //---------------------------------------------------------------------------//
0020 /*!
0021  * Write an \c ImportData object to JSON output.
0022  *
0023  * \code
0024  *  RootJsonDumper dump(&std::cout);
0025  *  dump(my_import_data);
0026  * \endcode
0027  */
0028 class RootJsonDumper
0029 {
0030   public:
0031     // Construct with an output stream
0032     explicit RootJsonDumper(std::ostream& os);
0033 
0034     // Save data to the JSON file
0035     void operator()(ImportData const& data);
0036 
0037   private:
0038     std::ostream* os_;
0039 };
0040 
0041 //---------------------------------------------------------------------------//
0042 #if !CELERITAS_USE_ROOT
0043 inline RootJsonDumper::RootJsonDumper(std::ostream&)
0044 {
0045     CELER_DISCARD(os_);
0046     CELER_NOT_CONFIGURED("ROOT");
0047 }
0048 
0049 inline void RootJsonDumper::operator()(ImportData const&)
0050 {
0051     CELER_ASSERT_UNREACHABLE();
0052 }
0053 #endif
0054 
0055 //---------------------------------------------------------------------------//
0056 }  // namespace celeritas