Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
G4MulticoutDestination.hh
이 파일의 문서화 페이지로 가기
1 // ********************************************************************
2 // * License and Disclaimer *
3 // * *
4 // * The Geant4 software is copyright of the Copyright Holders of *
5 // * the Geant4 Collaboration. It is provided under the terms and *
6 // * conditions of the Geant4 Software License, included in the file *
7 // * LICENSE and available at http://cern.ch/geant4/license . These *
8 // * include a list of copyright holders. *
9 // * *
10 // * Neither the authors of this software system, nor their employing *
11 // * institutes,nor the agencies providing financial support for this *
12 // * work make any representation or warranty, express or implied, *
13 // * regarding this software system or assume any liability for its *
14 // * use. Please see the license in the file LICENSE and URL above *
15 // * for the full disclaimer and the limitation of liability. *
16 // * *
17 // * This code implementation is the result of the scientific and *
18 // * technical work of the GEANT4 collaboration. *
19 // * By using, copying, modifying or distributing the software (or *
20 // * any work based on the software) you agree to acknowledge its *
21 // * use in resulting scientific publications, and indicate your *
22 // * acceptance of all terms of the Geant4 Software license. *
23 // ********************************************************************
24 //
25 //
26 // $Id: G4MulticoutDestination.hh 103582 2017-04-18 17:24:45Z adotti $
27 //
28 //
29 // --------------------------------------------------------------------
30 // GEANT 4 class header file
31 //
32 // G4MulticoutDestination.hh
33 //
34 // Class description:
35 //
36 // Extends G4coutDestination and allows multiple G4coutDestination objects
37 // to be chained in the same job.
38 // Note that formatters can be attached to this destination that will apply
39 // them before passing over the message to the child destination.
40 //
41 // Usage:
42 // User should create and set-up G4coutDestination objects the usual way
43 // these should then be added to an instance of this container class
44 // this class should then be added to the streaming. E.g.
45 // class MyCout1 : public G4coutDestination {};
46 // class MyCout2 : public G4coutDestination {};
47 // auto multi = new G4MulticoutDestination();
48 // multi->push_back( G4coutDestinationUPtr( new MyCout1 ) );
49 // multi->push_back( G4coutDestinationUPtr( new MyCout2 ) );
50 // G4coutbuf.SetDestination( multi ); // or G4cerrbuf
51 
52 // ---------------- G4MulticoutDestination ----------------
53 //
54 // Author: A.Dotti (SLAC), April 2017
55 // --------------------------------------------------------------------
56 #ifndef G4MULTICOUTDESTINATION_HH_
57 #define G4MULTICOUTDESTINATION_HH_
58 
59 #include <memory>
60 #include <vector>
61 
62 #include "G4coutDestination.hh"
63 
64 using G4coutDestinationUPtr = std::unique_ptr<G4coutDestination>;
65 using G4coutDestinationVector = std::vector<G4coutDestinationUPtr>;
66 
69 {
70  public:
71 
72  G4MulticoutDestination() = default;
74 
75  // Forward call to contained destination. Note that the message may have
76  // been modified by formatters attached to this
77  virtual G4int ReceiveG4cout(const G4String& msg) override
78  {
79  G4bool result = true;
80  std::for_each( begin(), end(),
81  [&](G4coutDestinationUPtr& e) { result &= (e->ReceiveG4cout_(msg)==0); }
82  );
83  return ( result ? 0 : -1);
84  }
85 
86  virtual G4int ReceiveG4cerr(const G4String& msg) override
87  {
88  G4bool result = true;
89  std::for_each( begin(), end(),
90  [&](G4coutDestinationUPtr& e) { result &= (e->ReceiveG4cerr_(msg)==0); }
91  );
92  return ( result ? 0 : -1);
93  }
94 };
95 
96 #endif /* G4MULTICOUTDESTINATION_HH_ */
virtual G4int ReceiveG4cerr(const G4String &msg) override
std::unique_ptr< G4coutDestination > G4coutDestinationUPtr
std::vector< G4coutDestinationUPtr > G4coutDestinationVector
virtual G4int ReceiveG4cout(const G4String &msg) override
bool G4bool
Definition: G4Types.hh:79
G4MulticoutDestination()=default
G4double G4ParticleHPJENDLHEData::G4double result
int G4int
Definition: G4Types.hh:78