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

#include <G4BuffercoutDestination.hh>

+ Inheritance diagram for G4BuffercoutDestination:

Public Member Functions

 G4BuffercoutDestination (std::size_t maxSize=0)
 
 ~G4BuffercoutDestination () override
 
G4int ReceiveG4cout (const G4String &msg) override
 
G4int ReceiveG4cerr (const G4String &msg) override
 
virtual G4int FlushG4cout ()
 
virtual G4int FlushG4cerr ()
 
virtual void Finalize ()
 
void SetMaxSize (std::size_t max)
 
std::size_t GetMaxSize () const
 
std::size_t GetCurrentSizeOut () const
 
std::size_t GetCurrentSizeErr () const
 
- Public Member Functions inherited from G4coutDestination
 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 Member Functions

void ResetCout ()
 
void ResetCerr ()
 

Protected Attributes

std::ostringstream m_buffer_out
 
std::ostringstream m_buffer_err
 
std::size_t m_currentSize_out = 0
 
std::size_t m_currentSize_err = 0
 
std::size_t m_maxSize = 0
 
- Protected Attributes inherited from G4coutDestination
std::vector< TransformertransformersCout
 
std::vector< TransformertransformersCerr
 

Additional Inherited Members

- Public Types inherited from G4coutDestination
using Transformer = std::function< G4bool(G4String &)>
 
- Static Protected Attributes inherited from G4coutDestination
static G4MTGLOB_DLL G4coutDestinationmasterG4coutDestination = nullptr
 

Detailed Description

Definition at line 45 of file G4BuffercoutDestination.hh.

Constructor & Destructor Documentation

◆ G4BuffercoutDestination()

G4BuffercoutDestination::G4BuffercoutDestination ( std::size_t  maxSize = 0)
explicit

Definition at line 37 of file G4BuffercoutDestination.cc.

38 : m_buffer_out("")
39 , m_buffer_err("")
40 , m_maxSize(max)
41{}

◆ ~G4BuffercoutDestination()

G4BuffercoutDestination::~G4BuffercoutDestination ( )
override

Definition at line 44 of file G4BuffercoutDestination.cc.

44{ Finalize(); }

Member Function Documentation

◆ Finalize()

void G4BuffercoutDestination::Finalize ( )
virtual

Definition at line 47 of file G4BuffercoutDestination.cc.

48{
51}

Referenced by ~G4BuffercoutDestination().

◆ FlushG4cerr()

G4int G4BuffercoutDestination::FlushG4cerr ( )
virtual

Definition at line 96 of file G4BuffercoutDestination.cc.

97{
98 std::cerr << m_buffer_err.str() << std::flush;
99 ResetCerr();
100 return 0;
101}

Referenced by Finalize(), and ReceiveG4cerr().

◆ FlushG4cout()

G4int G4BuffercoutDestination::FlushG4cout ( )
virtual

Definition at line 80 of file G4BuffercoutDestination.cc.

81{
82 std::cout << m_buffer_out.str() << std::flush;
83 ResetCout();
84 return 0;
85}

Referenced by Finalize(), and ReceiveG4cout().

◆ GetCurrentSizeErr()

std::size_t G4BuffercoutDestination::GetCurrentSizeErr ( ) const
inline

Definition at line 66 of file G4BuffercoutDestination.hh.

◆ GetCurrentSizeOut()

std::size_t G4BuffercoutDestination::GetCurrentSizeOut ( ) const
inline

Definition at line 65 of file G4BuffercoutDestination.hh.

◆ GetMaxSize()

std::size_t G4BuffercoutDestination::GetMaxSize ( ) const
inline

Definition at line 64 of file G4BuffercoutDestination.hh.

64{ return m_maxSize; }

◆ ReceiveG4cerr()

G4int G4BuffercoutDestination::ReceiveG4cerr ( const G4String msg)
overridevirtual

Reimplemented from G4coutDestination.

Definition at line 67 of file G4BuffercoutDestination.cc.

68{
69 m_currentSize_err += msg.size();
70 m_buffer_err << msg;
71 // If there is a max size and it has been reached, flush
73 {
75 }
76 return 0;
77}

◆ ReceiveG4cout()

G4int G4BuffercoutDestination::ReceiveG4cout ( const G4String msg)
overridevirtual

Reimplemented from G4coutDestination.

Definition at line 54 of file G4BuffercoutDestination.cc.

55{
56 m_currentSize_out += msg.size();
57 m_buffer_out << msg;
58 // If there is a max size and it has been reached, flush
60 {
62 }
63 return 0;
64}

◆ ResetCerr()

void G4BuffercoutDestination::ResetCerr ( )
protected

Definition at line 104 of file G4BuffercoutDestination.cc.

105{
106 m_buffer_err.str("");
107 m_buffer_err.clear();
109}

Referenced by FlushG4cerr().

◆ ResetCout()

void G4BuffercoutDestination::ResetCout ( )
protected

Definition at line 88 of file G4BuffercoutDestination.cc.

89{
90 m_buffer_out.str("");
91 m_buffer_out.clear();
93}

Referenced by FlushG4cout().

◆ SetMaxSize()

void G4BuffercoutDestination::SetMaxSize ( std::size_t  max)
inline

Definition at line 63 of file G4BuffercoutDestination.hh.

63{ m_maxSize = max; }
T max(const T t1, const T t2)
brief Return the largest of the two arguments

Member Data Documentation

◆ m_buffer_err

std::ostringstream G4BuffercoutDestination::m_buffer_err
protected

Definition at line 73 of file G4BuffercoutDestination.hh.

Referenced by FlushG4cerr(), ReceiveG4cerr(), and ResetCerr().

◆ m_buffer_out

std::ostringstream G4BuffercoutDestination::m_buffer_out
protected

Definition at line 72 of file G4BuffercoutDestination.hh.

Referenced by FlushG4cout(), ReceiveG4cout(), and ResetCout().

◆ m_currentSize_err

std::size_t G4BuffercoutDestination::m_currentSize_err = 0
protected

Definition at line 75 of file G4BuffercoutDestination.hh.

Referenced by GetCurrentSizeErr(), ReceiveG4cerr(), and ResetCerr().

◆ m_currentSize_out

std::size_t G4BuffercoutDestination::m_currentSize_out = 0
protected

Definition at line 74 of file G4BuffercoutDestination.hh.

Referenced by GetCurrentSizeOut(), ReceiveG4cout(), and ResetCout().

◆ m_maxSize

std::size_t G4BuffercoutDestination::m_maxSize = 0
protected

Definition at line 76 of file G4BuffercoutDestination.hh.

Referenced by GetMaxSize(), ReceiveG4cerr(), ReceiveG4cout(), and SetMaxSize().


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