00001 // This file is part of ff3d - http://www.freefem.org/ff3d 00002 // Copyright (C) 2001, 2002, 2003 Stéphane Del Pino 00003 00004 // This program is free software; you can redistribute it and/or modify 00005 // it under the terms of the GNU General Public License as published by 00006 // the Free Software Foundation; either version 2, or (at your option) 00007 // any later version. 00008 00009 // This program is distributed in the hope that it will be useful, 00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 // GNU General Public License for more details. 00013 00014 // You should have received a copy of the GNU General Public License 00015 // along with this program; if not, write to the Free Software Foundation, 00016 // Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00017 00018 // $Id: StreamCenter.hpp,v 1.5 2007/06/09 10:37:06 delpinux Exp $ 00019 00020 #ifndef STREAMCENTER_HPP 00021 #define STREAMCENTER_HPP 00022 00023 #include <sstream> 00024 #include <iostream> 00025 00026 #include <OStream.hpp> 00027 #include <StaticBase.hpp> 00028 00029 #include <config.h> 00030 00031 #ifdef HAVE_GUI_LIBS 00032 class QTextEdit; 00033 #endif // HAVE_GUI_LIBS 00034 00035 class StreamCenter 00036 : public ThreadStaticBase<StreamCenter> 00037 { 00038 private: 00039 friend class StaticCenter; 00040 00041 int __debugLevel; 00042 00044 OStream __nullStream; 00045 00047 OStream __log; 00048 00050 OStream __out; 00051 00053 OStream __err; 00054 00056 StreamCenter(const StreamCenter& SC); 00057 00058 public: 00059 00060 #ifdef HAVE_GUI_LIBS 00061 00066 void setConsole(QTextEdit* console); 00067 #endif // HAVE_GUI_LIBS 00068 00069 inline OStream& log(int i) 00070 { 00071 if (i<=__debugLevel) 00072 return __log; 00073 else 00074 return __nullStream; 00075 } 00076 00077 inline OStream& out(int i) 00078 { 00079 if (i<=__debugLevel) 00080 return __out; 00081 else 00082 return __nullStream; 00083 } 00084 00085 inline OStream& err(int i) 00086 { 00087 if (i<=__debugLevel) 00088 return __err; 00089 else 00090 return __nullStream; 00091 } 00092 00093 int getDebugLevel() const 00094 { 00095 return __debugLevel; 00096 } 00097 00098 void setDebugLevel(int i) 00099 { 00100 __debugLevel = i; 00101 } 00102 00103 StreamCenter(); 00104 00105 ~StreamCenter() 00106 { 00107 ; 00108 } 00109 }; 00110 00112 inline OStream& fflog(int i) 00113 { 00114 return StreamCenter::instance().log(i); 00115 } 00116 00117 inline OStream& ffout(int i) 00118 { 00119 return StreamCenter::instance().out(i); 00120 } 00121 00122 inline OStream& fferr(int i) 00123 { 00124 return StreamCenter::instance().err(i); 00125 } 00126 00127 #endif //STREAMCENTER_HPP
1.5.6