![]() |
|
|||
File indexing completed on 2025-09-18 09:09:40
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/ScopedTimeAndRedirect.hh 0006 //---------------------------------------------------------------------------// 0007 #pragma once 0008 0009 #include <memory> 0010 #include <string> 0011 0012 #include "corecel/Macros.hh" 0013 0014 #include "ScopedStreamRedirect.hh" 0015 #include "ScopedTimeLog.hh" 0016 0017 namespace celeritas 0018 { 0019 //---------------------------------------------------------------------------// 0020 /*! 0021 * At end of scope, print elapsed time and captured cout/cerr. 0022 * 0023 * This is designed to prevent other libraries (Geant4,VecGeom) from polluting 0024 * stdout and breaking JSON reading ability. 0025 * 0026 * \code 0027 { 0028 ScopedTimeAndRedirect temp_{"VecGeom"}; 0029 vecgeom::DoNoisyAndLongStuff(); 0030 } 0031 \endcode 0032 */ 0033 class ScopedTimeAndRedirect 0034 { 0035 public: 0036 explicit ScopedTimeAndRedirect(std::string label); 0037 ~ScopedTimeAndRedirect(); 0038 0039 //!@{ 0040 //! Prevent copying and moving for RAII class 0041 CELER_DELETE_COPY_MOVE(ScopedTimeAndRedirect); 0042 //!@} 0043 0044 private: 0045 std::unique_ptr<ScopedStreamRedirect> stdout_; 0046 std::unique_ptr<ScopedStreamRedirect> stderr_; 0047 std::string label_; 0048 ScopedTimeLog scoped_time_; 0049 }; 0050 0051 //---------------------------------------------------------------------------// 0052 } // 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 |
![]() ![]() |