Logo ROOT  
Reference Guide
TGRedirectOutputGuard Class Reference

This class provides output redirection to a TGTextView in guaranteed exception safe way.

Use like this:

{
TGRedirectOutputGuard guard(textview);
... // do something
guard.Update();
... // do something else
}
This class provides output redirection to a TGTextView in guaranteed exception safe way.

when guard goes out of scope, Update() is called to flush what left on the screed and the output is automatically redirected again to the standard units. The exception mechanism takes care of calling the dtors of local objects so it is exception safe. Optionally the output can also be saved into a file:

{
TGRedirectOutputGuard guard(textview, file, mode);
... // do something
}
Option_t Option_t TPoint TPoint const char mode
Definition: file.py:1

Definition at line 20 of file TGRedirectOutputGuard.h.

Public Member Functions

 TGRedirectOutputGuard (TGTextView *tv, const char *flog=nullptr, const char *mode="a")
 Create output redirection guard. More...
 
virtual ~TGRedirectOutputGuard ()
 Destructor. More...
 
virtual TClassIsA () const
 
virtual void Streamer (TBuffer &)
 
void StreamerNVirtual (TBuffer &ClassDef_StreamerNVirtual_b)
 
void Update ()
 Send to text frame the undisplayed content of the file. More...
 

Static Public Member Functions

static TClassClass ()
 
static const char * Class_Name ()
 
static constexpr Version_t Class_Version ()
 
static const char * DeclFileName ()
 

Private Member Functions

 TGRedirectOutputGuard (const TGRedirectOutputGuard &)=delete
 
TGRedirectOutputGuardoperator= (const TGRedirectOutputGuard &)=delete
 

Private Attributes

TString fLogFile
 
FILE * fLogFileRead
 
TGTextViewfTextView
 
Bool_t fTmpFile
 

#include <TGRedirectOutputGuard.h>

Constructor & Destructor Documentation

◆ TGRedirectOutputGuard() [1/2]

TGRedirectOutputGuard::TGRedirectOutputGuard ( const TGRedirectOutputGuard )
privatedelete

◆ TGRedirectOutputGuard() [2/2]

TGRedirectOutputGuard::TGRedirectOutputGuard ( TGTextView tv,
const char *  flog = nullptr,
const char *  mode = "a" 
)

Create output redirection guard.

The TGTextView instance should be initialized outside. Text is added to the existing text in the frame. If defined, 'flog' is interpreted as the path of a file where to save the output; in such a case 'mode' if the opening mode of the file (either "w" or "a"). By default a temporary file is used.

Definition at line 67 of file TGRedirectOutputGuard.cxx.

◆ ~TGRedirectOutputGuard()

TGRedirectOutputGuard::~TGRedirectOutputGuard ( )
virtual

Destructor.

Definition at line 121 of file TGRedirectOutputGuard.cxx.

Member Function Documentation

◆ Class()

static TClass * TGRedirectOutputGuard::Class ( )
static
Returns
TClass describing this class

◆ Class_Name()

static const char * TGRedirectOutputGuard::Class_Name ( )
static
Returns
Name of this class

◆ Class_Version()

static constexpr Version_t TGRedirectOutputGuard::Class_Version ( )
inlinestaticconstexpr
Returns
Version of this class

Definition at line 39 of file TGRedirectOutputGuard.h.

◆ DeclFileName()

static const char * TGRedirectOutputGuard::DeclFileName ( )
inlinestatic
Returns
Name of the file containing the class declaration

Definition at line 39 of file TGRedirectOutputGuard.h.

◆ IsA()

virtual TClass * TGRedirectOutputGuard::IsA ( ) const
inlinevirtual
Returns
TClass describing current object

Definition at line 39 of file TGRedirectOutputGuard.h.

◆ operator=()

TGRedirectOutputGuard & TGRedirectOutputGuard::operator= ( const TGRedirectOutputGuard )
privatedelete

◆ Streamer()

virtual void TGRedirectOutputGuard::Streamer ( TBuffer )
virtual

◆ StreamerNVirtual()

void TGRedirectOutputGuard::StreamerNVirtual ( TBuffer ClassDef_StreamerNVirtual_b)
inline

Definition at line 39 of file TGRedirectOutputGuard.h.

◆ Update()

void TGRedirectOutputGuard::Update ( )

Send to text frame the undisplayed content of the file.

Definition at line 141 of file TGRedirectOutputGuard.cxx.

Member Data Documentation

◆ fLogFile

TString TGRedirectOutputGuard::fLogFile
private

Definition at line 23 of file TGRedirectOutputGuard.h.

◆ fLogFileRead

FILE* TGRedirectOutputGuard::fLogFileRead
private

Definition at line 26 of file TGRedirectOutputGuard.h.

◆ fTextView

TGTextView* TGRedirectOutputGuard::fTextView
private

Definition at line 25 of file TGRedirectOutputGuard.h.

◆ fTmpFile

Bool_t TGRedirectOutputGuard::fTmpFile
private

Definition at line 24 of file TGRedirectOutputGuard.h.

Libraries for TGRedirectOutputGuard:
[legend]

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