|
||||
File indexing completed on 2025-01-18 09:58:42
0001 // ******************************************************************** 0002 // * License and Disclaimer * 0003 // * * 0004 // * The Geant4 software is copyright of the Copyright Holders of * 0005 // * the Geant4 Collaboration. It is provided under the terms and * 0006 // * conditions of the Geant4 Software License, included in the file * 0007 // * LICENSE and available at http://cern.ch/geant4/license . These * 0008 // * include a list of copyright holders. * 0009 // * * 0010 // * Neither the authors of this software system, nor their employing * 0011 // * institutes,nor the agencies providing financial support for this * 0012 // * work make any representation or warranty, express or implied, * 0013 // * regarding this software system or assume any liability for its * 0014 // * use. Please see the license in the file LICENSE and URL above * 0015 // * for the full disclaimer and the limitation of liability. * 0016 // * * 0017 // * This code implementation is the result of the scientific and * 0018 // * technical work of the GEANT4 collaboration. * 0019 // * By using, copying, modifying or distributing the software (or * 0020 // * any work based on the software) you agree to acknowledge its * 0021 // * use in resulting scientific publications, and indicate your * 0022 // * acceptance of all terms of the Geant4 Software license. * 0023 // ******************************************************************** 0024 // 0025 // G4MulticoutDestination 0026 // 0027 // Class description: 0028 // 0029 // Extends G4coutDestination and allows multiple G4coutDestination objects 0030 // to be chained in the same job. 0031 // Note that formatters can be attached to this destination that will apply 0032 // them before passing over the message to the child destination. 0033 // 0034 // Usage: 0035 // User should create and set-up G4coutDestination objects the usual way 0036 // these should then be added to an instance of this container class 0037 // this class should then be added to the streaming. E.g. 0038 // class MyCout1 : public G4coutDestination {}; 0039 // class MyCout2 : public G4coutDestination {}; 0040 // auto multi = new G4MulticoutDestination(); 0041 // multi->push_back( G4coutDestinationUPtr( new MyCout1 ) ); 0042 // multi->push_back( G4coutDestinationUPtr( new MyCout2 ) ); 0043 // G4iosSetDestination( multi ); // or G4cerrbuf 0044 0045 // ---------------- G4MulticoutDestination ---------------- 0046 // 0047 // Author: A.Dotti (SLAC), April 2017 0048 // -------------------------------------------------------------------- 0049 #ifndef G4MULTICOUTDESTINATION_HH 0050 #define G4MULTICOUTDESTINATION_HH 0051 0052 #include <memory> 0053 #include <vector> 0054 0055 #include "G4coutDestination.hh" 0056 0057 using G4coutDestinationUPtr = std::unique_ptr<G4coutDestination>; 0058 using G4coutDestinationVector = std::vector<G4coutDestinationUPtr>; 0059 0060 class G4MulticoutDestination 0061 : public G4coutDestination 0062 , public G4coutDestinationVector 0063 { 0064 public: 0065 G4MulticoutDestination() = default; 0066 ~G4MulticoutDestination() override = default; 0067 0068 // Forward call to contained destination. Note that the message may have 0069 // been modified by formatters attached to this 0070 G4int ReceiveG4debug(const G4String& msg) override 0071 { 0072 G4bool result = true; 0073 std::for_each(begin(), end(), [&](G4coutDestinationUPtr& e) { 0074 result &= (e->ReceiveG4debug_(msg) == 0); 0075 }); 0076 return (result ? 0 : -1); 0077 } 0078 0079 G4int ReceiveG4cout(const G4String& msg) override 0080 { 0081 G4bool result = true; 0082 std::for_each(begin(), end(), [&](G4coutDestinationUPtr& e) { 0083 result &= (e->ReceiveG4cout_(msg) == 0); 0084 }); 0085 return (result ? 0 : -1); 0086 } 0087 0088 G4int ReceiveG4cerr(const G4String& msg) override 0089 { 0090 G4bool result = true; 0091 std::for_each(begin(), end(), [&](G4coutDestinationUPtr& e) { 0092 result &= (e->ReceiveG4cerr_(msg) == 0); 0093 }); 0094 return (result ? 0 : -1); 0095 } 0096 }; 0097 0098 #endif
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |