Geant4 11.2.2
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 AddDebugTransformer (const Transformer &t)
 
void AddDebugTransformer (Transformer &&t)
 
void AddCoutTransformer (const Transformer &t)
 
void AddCoutTransformer (Transformer &&t)
 
void AddCerrTransformer (const Transformer &t)
 
void AddCerrTransformer (Transformer &&t)
 
virtual void ResetTransformers ()
 
virtual G4int ReceiveG4debug (const G4String &msg)
 
virtual G4int ReceiveG4cout (const G4String &msg)
 
virtual G4int ReceiveG4cerr (const G4String &msg)
 
G4int ReceiveG4debug_ (const G4String &msg)
 
G4int ReceiveG4cout_ (const G4String &msg)
 
G4int ReceiveG4cerr_ (const G4String &msg)
 

Protected Attributes

std::vector< TransformertransformersDebug
 
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 74 of file G4coutDestination.hh.

75 {
76 transformersCerr.push_back(t);
77 }
std::vector< Transformer > transformersCerr

Referenced by G4MTcoutDestination::HandleFileCerr().

◆ AddCerrTransformer() [2/2]

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

Definition at line 78 of file G4coutDestination.hh.

78{ transformersCerr.push_back(t); }

◆ AddCoutTransformer() [1/2]

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

Definition at line 68 of file G4coutDestination.hh.

69 {
70 transformersCout.push_back(t);
71 }
std::vector< Transformer > transformersCout

Referenced by G4MTcoutDestination::HandleFileCout().

◆ AddCoutTransformer() [2/2]

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

Definition at line 72 of file G4coutDestination.hh.

72{ transformersCout.push_back(t); }

◆ AddDebugTransformer() [1/2]

void G4coutDestination::AddDebugTransformer ( const Transformer & t)
inline

Definition at line 62 of file G4coutDestination.hh.

63 {
64 transformersDebug.push_back(t);
65 }
std::vector< Transformer > transformersDebug

Referenced by G4MTcoutDestination::AddMasterOutput(), and G4MTcoutDestination::SetDefaultOutput().

◆ AddDebugTransformer() [2/2]

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

Definition at line 66 of file G4coutDestination.hh.

66{ transformersDebug.push_back(t); }

◆ ReceiveG4cerr()

G4int G4coutDestination::ReceiveG4cerr ( const G4String & msg)
virtual

◆ ReceiveG4cerr_()

G4int G4coutDestination::ReceiveG4cerr_ ( const G4String & msg)

Definition at line 111 of file G4coutDestination.cc.

112{
113 if(!transformersCout.empty())
114 {
115 G4String m = msg;
116 std::for_each(transformersCerr.begin(), transformersCerr.end(),
117 [&m](const Transformer& t) { t(m); }
118 // Call transforming function on message
119 );
120 return ReceiveG4cerr(m);
121 }
122
123 return ReceiveG4cerr(msg);
124}
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 89 of file G4coutDestination.cc.

90{
91 // Avoid copy of string if not necessary
92 if(!transformersCout.empty())
93 {
94 G4String m = msg;
95 G4bool result = true;
96 for(const auto& el : transformersCout)
97 {
98 result &= el(m);
99 if(!result)
100 {
101 break;
102 }
103 }
104 return (result ? ReceiveG4cout(m) : 0);
105 }
106
107 return ReceiveG4cout(msg);
108}
bool G4bool
Definition G4Types.hh:86
virtual G4int ReceiveG4cout(const G4String &msg)

Referenced by G4MasterForwardcoutDestination::ReceiveG4cout().

◆ ReceiveG4debug()

G4int G4coutDestination::ReceiveG4debug ( const G4String & msg)
virtual

◆ ReceiveG4debug_()

G4int G4coutDestination::ReceiveG4debug_ ( const G4String & msg)

Definition at line 67 of file G4coutDestination.cc.

68{
69 // Avoid copy of string if not necessary
70 if(!transformersDebug.empty())
71 {
72 G4String m = msg;
73 G4bool result = true;
74 for(const auto& el : transformersDebug)
75 {
76 result &= el(m);
77 if(!result)
78 {
79 break;
80 }
81 }
82 return (result ? ReceiveG4debug(m) : 0);
83 }
84
85 return ReceiveG4debug(msg);
86}
virtual G4int ReceiveG4debug(const G4String &msg)

Referenced by G4MasterForwardcoutDestination::ReceiveG4debug().

◆ ResetTransformers()

void G4coutDestination::ResetTransformers ( )
virtual

Definition at line 38 of file G4coutDestination.cc.

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

Member Data Documentation

◆ masterG4coutDestination

◆ transformersCerr

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

◆ transformersCout

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

◆ transformersDebug

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

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