ROOT  6.06/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 #ifndef ROOT_TString
41 #include "TString.h"
42 #endif
43 
44 class TGTextView;
45 
47 
48 private:
52  FILE *fLogFileRead;
53 
54 private:
55  TGRedirectOutputGuard(const TGRedirectOutputGuard&); // Not implemented.
56  TGRedirectOutputGuard &operator=(const TGRedirectOutputGuard&); // Not implemented.
57 
58 public:
60  const char *flog = 0, const char *mode = "a");
61  virtual ~TGRedirectOutputGuard();
62 
63  void Update(); // Update window with file content
64 
65  ClassDef(TGRedirectOutputGuard,0) // Exception safe output redirection
66 };
67 
68 #endif
TGRedirectOutputGuard(const TGRedirectOutputGuard &)
Basic string class.
Definition: TString.h:137
bool Bool_t
Definition: RtypesCore.h:59
#define ClassDef(name, id)
Definition: Rtypes.h:254
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.