41 using FlushFn_t = std::function<void(
const std::string&)>;
44 explicit BufferImpl(std::size_t maxSize) : m_maxSize(maxSize) {}
63 m_currentSize += msg.size();
66 if (m_maxSize > 0 && m_currentSize > m_maxSize) {
75 m_flushFn(m_buffer.str());
81 std::size_t m_maxSize = 0;
82 std::ostringstream m_buffer;
83 std::size_t m_currentSize = 0;
84 FlushFn_t m_flushFn = [](
auto& s) { std::cout << s << std::flush; };
92 m_buffer_err(
std::make_unique<
BufferImpl>(max, [](auto& s) { std::cerr << s << std::flush; }))
std::function< void(const std::string &)> FlushFn_t
void SetMaxSize(std::size_t n)
G4int Receive(const G4String &msg)
BufferImpl(std::size_t maxSize)
BufferImpl(std::size_t maxSize, FlushFn_t &&f)
std::unique_ptr< BufferImpl > m_buffer_err
void SetMaxSize(std::size_t max)
std::unique_ptr< BufferImpl > m_buffer_out
virtual G4int FlushG4cerr()
std::unique_ptr< BufferImpl > m_buffer_dbg
G4int ReceiveG4debug(const G4String &msg) override
G4BuffercoutDestination(std::size_t maxSize=0)
virtual G4int FlushG4cout()
G4int ReceiveG4cerr(const G4String &msg) override
virtual G4int FlushG4debug()
~G4BuffercoutDestination() override
G4int ReceiveG4cout(const G4String &msg) override