Geant4 11.1.1
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4coutDestination Class Reference

#include <G4coutDestination.hh>

+ Inheritance diagram for G4coutDestination:

Public Types

using Transformer = std::function< G4bool(G4String &)>
 

Public Member Functions

 G4coutDestination ()=default
 
virtual ~G4coutDestination ()=default
 
void AddCoutTransformer (const Transformer &t)
 
void AddCoutTransformer (Transformer &&t)
 
void AddCerrTransformer (const Transformer &t)
 
void AddCerrTransformer (Transformer &&t)
 
virtual void ResetTransformers ()
 
virtual G4int ReceiveG4cout (const G4String &msg)
 
virtual G4int ReceiveG4cerr (const G4String &msg)
 
G4int ReceiveG4cout_ (const G4String &msg)
 
G4int ReceiveG4cerr_ (const G4String &msg)
 

Protected Attributes

std::vector< TransformertransformersCout
 
std::vector< TransformertransformersCerr
 

Static Protected Attributes

static G4MTGLOB_DLL G4coutDestinationmasterG4coutDestination = nullptr
 

Detailed Description

Definition at line 44 of file G4coutDestination.hh.

Member Typedef Documentation

◆ Transformer

Definition at line 60 of file G4coutDestination.hh.

Constructor & Destructor Documentation

◆ G4coutDestination()

G4coutDestination::G4coutDestination ( )
default

◆ ~G4coutDestination()

virtual G4coutDestination::~G4coutDestination ( )
virtualdefault

Member Function Documentation

◆ AddCerrTransformer() [1/2]

void G4coutDestination::AddCerrTransformer ( const Transformer t)
inline

Definition at line 66 of file G4coutDestination.hh.

67 {
68 transformersCerr.push_back(t);
69 }
std::vector< Transformer > transformersCerr

Referenced by G4MTcoutDestination::HandleFileCerr().

◆ AddCerrTransformer() [2/2]

void G4coutDestination::AddCerrTransformer ( Transformer &&  t)
inline

Definition at line 70 of file G4coutDestination.hh.

70{ transformersCerr.push_back(t); }

◆ AddCoutTransformer() [1/2]

void G4coutDestination::AddCoutTransformer ( const Transformer t)
inline

◆ AddCoutTransformer() [2/2]

void G4coutDestination::AddCoutTransformer ( Transformer &&  t)
inline

Definition at line 65 of file G4coutDestination.hh.

65{ transformersCout.push_back(t); }

◆ ReceiveG4cerr()

G4int G4coutDestination::ReceiveG4cerr ( const G4String msg)
virtual

◆ ReceiveG4cerr_()

G4int G4coutDestination::ReceiveG4cerr_ ( const G4String msg)

Definition at line 81 of file G4coutDestination.cc.

82{
83 if(!transformersCout.empty())
84 {
85 G4String m = msg;
86 std::for_each(transformersCerr.begin(), transformersCerr.end(),
87 [&m](const Transformer& t) { t(m); }
88 // Call transforming function on message
89 );
90 return ReceiveG4cerr(m);
91 }
92
93 return ReceiveG4cerr(msg);
94}
virtual G4int ReceiveG4cerr(const G4String &msg)
std::function< G4bool(G4String &)> Transformer

Referenced by G4MasterForwardcoutDestination::ReceiveG4cerr().

◆ ReceiveG4cout()

G4int G4coutDestination::ReceiveG4cout ( const G4String msg)
virtual

◆ ReceiveG4cout_()

G4int G4coutDestination::ReceiveG4cout_ ( const G4String msg)

Definition at line 59 of file G4coutDestination.cc.

60{
61 // Avoid copy of string if not necessary
62 if(!transformersCout.empty())
63 {
64 G4String m = msg;
65 G4bool result = true;
66 for(const auto& el : transformersCout)
67 {
68 result &= el(m);
69 if(!result)
70 {
71 break;
72 }
73 }
74 return (result ? ReceiveG4cout(m) : 0);
75 }
76
77 return ReceiveG4cout(msg);
78}
bool G4bool
Definition: G4Types.hh:86
virtual G4int ReceiveG4cout(const G4String &msg)

Referenced by G4MasterForwardcoutDestination::ReceiveG4cout().

◆ ResetTransformers()

void G4coutDestination::ResetTransformers ( )
virtual

Definition at line 38 of file G4coutDestination.cc.

39{
40 transformersCout.clear();
41 transformersCerr.clear();
42}

Member Data Documentation

◆ masterG4coutDestination

G4coutDestination * G4coutDestination::masterG4coutDestination = nullptr
staticprotected

◆ transformersCerr

std::vector<Transformer> G4coutDestination::transformersCerr
protected

Definition at line 93 of file G4coutDestination.hh.

Referenced by AddCerrTransformer(), ReceiveG4cerr_(), and ResetTransformers().

◆ transformersCout

std::vector<Transformer> G4coutDestination::transformersCout
protected

The documentation for this class was generated from the following files: