Logo ROOT   6.10/09
Reference Guide
TGRedirectOutputGuard.h
Go to the documentation of this file.
1 // @(#)root/gui:$Id$
2 // Author: G. Ganis 10/10/2005
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2005, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 #ifndef ROOT_TGRedirectOutputGuard
13 #define ROOT_TGRedirectOutputGuard
14 
15 //////////////////////////////////////////////////////////////////////////
16 // //
17 // TGRedirectOutputGuard //
18 // //
19 // This class provides output redirection to a TGTextView in guaranteed //
20 // exception safe way. Use like this: //
21 // { //
22 // TGRedirectOutputGuard guard(textview); //
23 // ... // do something //
24 // guard.Update(); //
25 // ... // do something else //
26 // } //
27 // when guard goes out of scope, Update() is called to flush what left //
28 // on the screed and the output is automatically redirected again to //
29 // the standard units. //
30 // The exception mechanism takes care of calling the dtors //
31 // of local objects so it is exception safe. //
32 // Optionally the output can also be saved into a file: //
33 // { //
34 // TGRedirectOutputGuard guard(textview, file, mode); //
35 // ... // do something //
36 // } //
37 // //
38 //////////////////////////////////////////////////////////////////////////
39 
40 #include "TString.h"
41 
42 class TGTextView;
43 
45 
46 private:
50  FILE *fLogFileRead;
51 
52 private:
53  TGRedirectOutputGuard(const TGRedirectOutputGuard&); // Not implemented.
54  TGRedirectOutputGuard &operator=(const TGRedirectOutputGuard&); // Not implemented.
55 
56 public:
58  const char *flog = 0, const char *mode = "a");
59  virtual ~TGRedirectOutputGuard();
60 
61  void Update(); // Update window with file content
62 
63  ClassDef(TGRedirectOutputGuard,0) // Exception safe output redirection
64 };
65 
66 #endif
TGRedirectOutputGuard(const TGRedirectOutputGuard &)
Basic string class.
Definition: TString.h:129
bool Bool_t
Definition: RtypesCore.h:59
#define ClassDef(name, id)
Definition: Rtypes.h:297
TString flog
Definition: pq2main.cxx:37
TGRedirectOutputGuard & operator=(const TGRedirectOutputGuard &)
void Update()
Send to text frame the undisplayed content of the file.
virtual ~TGRedirectOutputGuard()
Destructor.