00001 // @(#)root/proof:$Id: redirguard.h 33259 2010-04-28 06:54:00Z ganis $ 00002 // Author: G. Ganis, Mar 2010 00003 00004 /************************************************************************* 00005 * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. * 00006 * All rights reserved. * 00007 * * 00008 * For the licensing terms see $ROOTSYS/LICENSE. * 00009 * For the list of contributors see $ROOTSYS/README/CREDITS. * 00010 *************************************************************************/ 00011 00012 #ifndef PQ2_redirguard 00013 #define PQ2_redirguard 00014 00015 ////////////////////////////////////////////////////////////////////////// 00016 // // 00017 // redirguard // 00018 // // 00019 // Auxilliary class used in PQ2 functions to redirect the logs // 00020 // // 00021 ////////////////////////////////////////////////////////////////////////// 00022 00023 #include "TSystem.h" 00024 00025 class redirguard { 00026 private: 00027 RedirectHandle_t fRH; 00028 Bool_t fDoIt; 00029 public: 00030 redirguard(const char *fn, const char *mode = "a", Int_t doit = 0) 00031 { fDoIt = (doit == 0) ? kTRUE : kFALSE; 00032 if (fDoIt) gSystem->RedirectOutput(fn, mode, &fRH); } 00033 ~redirguard() { if (fDoIt) gSystem->RedirectOutput(0, 0, &fRH); } 00034 }; 00035 #endif