Computer Assited Medical Intervention Tool Kit  version 5.0
camitk::ConsoleStream Class Reference

Provides a console windows, within the CamiTK application. More...

#include <ConsoleStream.h>

+ Inheritance diagram for camitk::ConsoleStream:
+ Collaboration diagram for camitk::ConsoleStream:

Public Member Functions

 ConsoleStream ()
 default constructor, init(..) have to be called later, before first use More...
 
 ConsoleStream (std::ostream *stream, QTextEdit *textEdit)
 constructor to use when you are sure about both paramaters More...
 
void free ()
 reset the state as it was before (stream use the old buffer again) More...
 
void init (std::ostream *stream, QTextEdit *textEdit)
 initialize ConsoleStream using both input stream and output text edit More...
 
void setStream (std::ostream *stream)
 set the value for the buffer to be replaced by the ConsoleStream More...
 
void setTextEdit (QTextEdit *text_edit)
 set the log QTextEdit More...
 
 ~ConsoleStream ()
 destructor: use free() to restore previous stream output buffer More...
 

Protected Member Functions

int_type overflow (int_type v)
 rewriting of the inherited method overflow More...
 
std::streamsize xsputn (const char *p, std::streamsize n)
 rewriting of the inherited method xsputn More...
 

Private Attributes

QTextEdit * logTextEdit
 
std::ostream * myStream
 
std::string myString
 
std::streambuf * previousBuffer
 

Detailed Description

Provides a console windows, within the CamiTK application.

The console widget.

Usage:

#include <ConsoleStream.h>
...
// create your application
QApplication app(argc, argv);
// these redirect both cout/cerr
ConsoleStream cout(std::cout);
ConsoleStream cerr(std::cerr);
// now start using cout and cerr normally
std::cerr << "Oops"; // this goes to your debugger output

Potential problem on windows (see thread)

  • std::string::clear() and std::string::push_back(...) don't exist, but myString.clear() can be substituted by myString.erase(myString.begin(), myString.end()) and myString.push_back(v) can be replaced by myString += v.
  • The usage of int_type seems to require a using std::ios::int_type statement.

Constructor & Destructor Documentation

◆ ConsoleStream() [1/2]

camitk::ConsoleStream::ConsoleStream ( std::ostream *  stream,
QTextEdit *  textEdit 
)
inline

constructor to use when you are sure about both paramaters

References logTextEdit, and myString.

◆ ConsoleStream() [2/2]

camitk::ConsoleStream::ConsoleStream ( )
inline

default constructor, init(..) have to be called later, before first use

◆ ~ConsoleStream()

camitk::ConsoleStream::~ConsoleStream ( )
inline

destructor: use free() to restore previous stream output buffer

Member Function Documentation

◆ free()

void camitk::ConsoleStream::free ( )
inline

reset the state as it was before (stream use the old buffer again)

◆ init()

void camitk::ConsoleStream::init ( std::ostream *  stream,
QTextEdit *  textEdit 
)
inline

initialize ConsoleStream using both input stream and output text edit

◆ overflow()

int_type camitk::ConsoleStream::overflow ( int_type  v)
inlineprotected

rewriting of the inherited method overflow

◆ setStream()

void camitk::ConsoleStream::setStream ( std::ostream *  stream)
inline

set the value for the buffer to be replaced by the ConsoleStream

◆ setTextEdit()

void camitk::ConsoleStream::setTextEdit ( QTextEdit *  text_edit)
inline

set the log QTextEdit

◆ xsputn()

std::streamsize camitk::ConsoleStream::xsputn ( const char *  p,
std::streamsize  n 
)
inlineprotected

rewriting of the inherited method xsputn

Member Data Documentation

◆ logTextEdit

QTextEdit* camitk::ConsoleStream::logTextEdit
private

Referenced by ConsoleStream().

◆ myStream

std::ostream* camitk::ConsoleStream::myStream
private

◆ myString

std::string camitk::ConsoleStream::myString
private

Referenced by ConsoleStream().

◆ previousBuffer

std::streambuf* camitk::ConsoleStream::previousBuffer
private

The documentation for this class was generated from the following file:
ConsoleStream.h
camitk::ConsoleStream::ConsoleStream
ConsoleStream()
default constructor, init(..) have to be called later, before first use
Definition: ConsoleStream.h:125