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: OStream.hpp,v 1.2 2006/05/20 15:27:41 delpinux Exp $ 00019 00020 #ifndef OSTREAM_HPP 00021 #define OSTREAM_HPP 00022 00023 #include <iostream> 00024 #include <Console.hpp> 00025 00026 class OStream 00027 { 00028 public: 00029 enum Type { 00030 standard, 00031 error, 00032 null, 00033 qt_standard, 00034 qt_error 00035 }; 00036 00037 private: 00038 Type __type; 00039 00040 template <typename T> 00041 void _writes(const T& t) 00042 { 00043 switch(__type) { 00044 case standard: { 00045 std::cout << t; 00046 break; 00047 } 00048 case error: { 00049 std::cerr << t; 00050 break; 00051 } 00052 case qt_standard: { 00053 Console::instance().writeStd(t); 00054 break; 00055 } 00056 case qt_error: { 00057 Console::instance().writeError(t); 00058 break; 00059 } 00060 case null: { 00061 break; 00062 } 00063 } 00064 } 00065 00066 public: 00067 void setType(const OStream::Type& type) 00068 { 00069 __type = type; 00070 } 00071 00072 template <typename T> 00073 OStream& operator<<(const T& t) 00074 { 00075 this->_writes(t); 00076 return *this; 00077 } 00078 00079 OStream(const OStream::Type& type) 00080 : __type(type) 00081 { 00082 ; 00083 } 00084 00085 virtual ~OStream() 00086 { 00087 ; 00088 } 00089 }; 00090 00091 #endif // OSTREAM_HPP
1.5.6