Illustrated C/C++ source sheets, symbol index, API relationship graph, compiler console and debug trace

LIVE AI / FLEXIBLE SENSING / FLIGHT CONTEXT

Sensoraia API

Live AI and sensing, connected to the flight.
See, listen, inspect and return supported results while airborne.

Loading...
Searching...
No Matches
TeeBuffer Class Reference

Stream one message to both the original console and the session log. More...

#include <application_runtime.h>

Inheritance diagram for TeeBuffer:
Collaboration diagram for TeeBuffer:

Public Member Functions

 TeeBuffer (std::streambuf *console, std::streambuf *file, std::mutex &mutex)
 Bind two destinations to a caller-owned synchronization lock.

Protected Member Functions

std::streamsize xsputn (const char *data, std::streamsize size) override
 Write a block to both outputs under the shared lock.
int overflow (int character) override
 Mirror a single character not handled by a put area.
int sync () override
 Synchronize the two outputs without interleaving other writes.

Private Attributes

std::streambuf * console_
std::streambuf * file_
std::mutex & mutex_

Detailed Description

Stream one message to both the original console and the session log.

Definition at line 41 of file application_runtime.h.

Constructor & Destructor Documentation

◆ TeeBuffer()

TeeBuffer::TeeBuffer ( std::streambuf * console,
std::streambuf * file,
std::mutex & mutex )
inline

Bind two destinations to a caller-owned synchronization lock.

Parameters
[in]consoleOriginal console stream buffer.
[in]fileSession-log stream buffer.
[in,out]mutexLock shared by the stdout and stderr tee buffers.

Definition at line 86 of file application_runtime.h.

Member Function Documentation

◆ overflow()

int TeeBuffer::overflow ( int character)
inlineoverrideprotected

Mirror a single character not handled by a put area.

Parameters
characterStreambuf integer character, or the EOF sentinel.
Returns
The written character, or EOF on either write failure.

Treat an EOF sentinel as a no-op, not as a byte to write.

Definition at line 62 of file application_runtime.h.

◆ sync()

int TeeBuffer::sync ( )
inlineoverrideprotected

Synchronize the two outputs without interleaving other writes.

Returns
Zero if both sync calls succeed, otherwise -1.

A console sync failure short-circuits the file sync.

Definition at line 75 of file application_runtime.h.

◆ xsputn()

std::streamsize TeeBuffer::xsputn ( const char * data,
std::streamsize size )
inlineoverrideprotected

Write a block to both outputs under the shared lock.

Parameters
dataBorrowed character block.
sizeCharacter count.
Returns
The shorter of the two writes, exposing failure of either output.

Keep the lock across both writes so competing diagnostics appear in the same order in the console and session log.

Definition at line 52 of file application_runtime.h.

Field Documentation

◆ console_

std::streambuf* TeeBuffer::console_
private

Definition at line 42 of file application_runtime.h.

◆ file_

std::streambuf* TeeBuffer::file_
private

Definition at line 43 of file application_runtime.h.

◆ mutex_

std::mutex& TeeBuffer::mutex_
private

Definition at line 44 of file application_runtime.h.


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