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

Public Types

using FlushFn_t = std::function<void(const std::string&)>
 

Public Member Functions

 BufferImpl (std::size_t maxSize)
 
 BufferImpl (std::size_t maxSize, FlushFn_t &&f)
 
 ~BufferImpl ()=default
 
void SetMaxSize (std::size_t n)
 
void Reset ()
 
G4int Receive (const G4String &msg)
 
G4int Flush ()
 

Detailed Description

Definition at line 38 of file G4BuffercoutDestination.cc.

Member Typedef Documentation

◆ FlushFn_t

using G4BuffercoutDestination::BufferImpl::FlushFn_t = std::function<void(const std::string&)>

Definition at line 41 of file G4BuffercoutDestination.cc.

Constructor & Destructor Documentation

◆ BufferImpl() [1/2]

G4BuffercoutDestination::BufferImpl::BufferImpl ( std::size_t maxSize)
inlineexplicit

Definition at line 44 of file G4BuffercoutDestination.cc.

44: m_maxSize(maxSize) {}

◆ BufferImpl() [2/2]

G4BuffercoutDestination::BufferImpl::BufferImpl ( std::size_t maxSize,
FlushFn_t && f )
inlineexplicit

Definition at line 45 of file G4BuffercoutDestination.cc.

45: m_maxSize(maxSize), m_flushFn(f) {}

◆ ~BufferImpl()

G4BuffercoutDestination::BufferImpl::~BufferImpl ( )
default

Member Function Documentation

◆ Flush()

G4int G4BuffercoutDestination::BufferImpl::Flush ( )
inline

Definition at line 73 of file G4BuffercoutDestination.cc.

74 {
75 m_flushFn(m_buffer.str());
76 Reset();
77 return 0;
78 }

Referenced by Receive().

◆ Receive()

G4int G4BuffercoutDestination::BufferImpl::Receive ( const G4String & msg)
inline

Definition at line 61 of file G4BuffercoutDestination.cc.

62 {
63 m_currentSize += msg.size();
64 m_buffer << msg;
65
66 if (m_maxSize > 0 && m_currentSize > m_maxSize) {
67 return Flush();
68 }
69 return 0;
70 }

◆ Reset()

void G4BuffercoutDestination::BufferImpl::Reset ( )
inline

Definition at line 54 of file G4BuffercoutDestination.cc.

55 {
56 m_buffer.str("");
57 m_buffer.clear();
58 m_currentSize = 0;
59 }

Referenced by Flush().

◆ SetMaxSize()

void G4BuffercoutDestination::BufferImpl::SetMaxSize ( std::size_t n)
inline

Definition at line 51 of file G4BuffercoutDestination.cc.

51{ m_maxSize = n; }

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