logger_util.hh

Go to the documentation of this file.
00001 /*
00002    The lestes compiler suite
00003    Copyright (C) 2002, 2003, 2004, 2005 Miroslav Tichy
00004    Copyright (C) 2002, 2003, 2004, 2005 Petr Zika
00005    Copyright (C) 2002, 2003, 2004, 2005 Vojtech Hala
00006    Copyright (C) 2002, 2003, 2004, 2005 Jiri Kosina
00007    Copyright (C) 2002, 2003, 2004, 2005 Pavel Sanda
00008    Copyright (C) 2002, 2003, 2004, 2005 Jan Zouhar
00009    Copyright (C) 2002, 2003, 2004, 2005 Rudolf Thomas
00010 
00011    This program is free software; you can redistribute it and/or modify
00012    it under the terms of the GNU General Public License as published by
00013    the Free Software Foundation; version 2 of the License.
00014 
00015    This program is distributed in the hope that it will be useful,
00016    but WITHOUT ANY WARRANTY; without even the implied warranty of
00017    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018    GNU General Public License for more details.
00019 
00020    See the full text of the GNU General Public License version 2, and
00021    the limitations in the file doc/LICENSE.
00022 
00023    By accepting the license the licensee waives any and all claims
00024    against the copyright holder(s) related in whole or in part to the
00025    work, its use, and/or the inability to use it.
00026  
00027  */
00028 #ifndef lestes__msg___logger_util_hh___included
00029 #define lestes__msg___logger_util_hh___included
00030 
00031 #include <lestes/common.hh>
00032 #include <lestes/msg/logger.hh>
00033 #include <iosfwd>
00034 
00035 /*! \file
00036   \author TMA
00037  */
00038 
00039 #ifdef _MSC_VER
00040 #define NAMESPACE_SCOPE_OPERATOR 1
00041 #endif
00042 
00043 package(lestes);
00044 package(msg);
00045 
00046 class logger_end_marker {};
00047 extern logger_end_marker eolog;
00048 ::std::ostream & operator << (::std::ostream &,const logger_end_marker &);
00049 
00050 class binded_logger {
00051 public:
00052         binded_logger(ptr < logger > l);
00053         ~binded_logger();
00054         void operator << (const logger_end_marker &) const;
00055 #if !NAMESPACE_SCOPE_OPERATOR
00056         template <typename T>
00057         inline const binded_logger & operator << (const T & x) const;
00058 #endif
00059         binded_logger(const binded_logger & l);
00060 private:
00061         ptr < logger > log;
00062 #if NAMESPACE_SCOPE_OPERATOR
00063 public:
00064 #endif
00065         ::std::ostream * stream;
00066 };
00067 
00068 #if NAMESPACE_SCOPE_OPERATOR
00069 template <typename T>
00070 const binded_logger & operator << (const binded_logger & bl, const T & x)
00071 {
00072         *bl.stream << x;
00073         return bl;
00074 }
00075 #else
00076 template <typename T>
00077 const binded_logger & binded_logger::operator << (const T & x) const
00078 {
00079         *stream << x;
00080         return *this;
00081 }
00082 #endif
00083 
00084 class formatter_factory : public object {
00085 public:
00086         static ptr < logger_formatter > create_formatter(lstring name, lstring parameter);
00087 private:
00088         formatter_factory(const formatter_factory &);
00089 };
00090 
00091 end_package(msg);
00092 package(std);
00093 
00094 template <typename T>
00095 inline ::lestes::msg::binded_logger operator <<(ptr < ::lestes::msg::logger > l, T x)
00096 {
00097         return ::lestes::msg::binded_logger(l) << x;
00098 }
00099 
00100 end_package(std);
00101 end_package(lestes);
00102 #endif /* lestes__msg___logger_util_hh___included */

Generated on Mon Feb 12 18:27:09 2007 for lestes by doxygen 1.5.1-20070107