logger_formatters.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_formatters_hh___included
00029 #define lestes__msg___logger_formatters_hh___included
00030 
00031 /*! \file
00032  * Logger formatters.
00033  * \author Rudo
00034  * \author TMA
00035  */
00036 
00037 #include <lestes/common.hh>
00038 #include <lestes/std/map.hh>
00039 #include <lestes/std/objectize_macros.hh>
00040 #include <lestes/std/ostream_wrapper.hh>
00041 
00042 #include <iosfwd>
00043 
00044 package(lestes);
00045 package(msg);
00046 
00047 class logger_formatter;
00048 class logger;
00049 
00050 class logger_formatter : public ::lestes::std::object {
00051 public:
00052         virtual ::std::ostream & format( const ptr<logger> &, ::std::ostream & ) = 0;
00053         virtual void format_end( const ptr<logger> &, ::std::ostream & ) = 0;
00054 };
00055 
00056 class fullname_formatter : public logger_formatter {
00057 public:
00058         static ptr<fullname_formatter> instance();
00059         virtual ::std::ostream & format( const ptr<logger> &, ::std::ostream & );
00060         virtual void format_end( const ptr<logger> &, ::std::ostream & );
00061 protected:
00062         fullname_formatter();
00063 private:
00064         static ptr<fullname_formatter> the_instance;
00065 };
00066 
00067 class plain_formatter : public logger_formatter {
00068 public:
00069         static ptr<plain_formatter> instance();
00070         virtual ::std::ostream & format( const ptr<logger> &, ::std::ostream & );
00071         virtual void format_end( const ptr<logger> &, ::std::ostream & );
00072 protected:
00073         plain_formatter();
00074 private:
00075         static ptr<plain_formatter> the_instance;
00076 };
00077 
00078 class xml_formatter : public logger_formatter {
00079 public:
00080         static ptr<xml_formatter> instance();
00081         virtual ::std::ostream & format( const ptr<logger> &, ::std::ostream & );
00082         virtual void format_end( const ptr<logger> &, ::std::ostream & );
00083         lstring tag_name_get() const;
00084         void tag_name_set( const lstring & );
00085 protected:
00086         xml_formatter();
00087 private:
00088         static ptr<xml_formatter> the_instance;
00089         lstring tag_name;
00090 };
00091 
00092 /*!
00093   \brief Combines sequentially two formatters.
00094   \author TMA
00095  */
00096 class conjunct_formatter : public logger_formatter {
00097 public:
00098         static ptr < conjunct_formatter > create(const ptr < logger_formatter > &, const ptr < logger_formatter > &);
00099         virtual ::std::ostream & format(const ptr<logger> &, ::std::ostream &);
00100         virtual void format_end(const ptr<logger> &, ::std::ostream &);
00101 protected:
00102         conjunct_formatter(const ptr < logger_formatter > &, const ptr < logger_formatter > &);
00103         virtual void gc_mark();
00104 private:
00105         srp < logger_formatter > first;
00106         srp < logger_formatter > second;
00107 };
00108 
00109 /*!
00110   \brief Prints the logger output in color
00111   \author TMA
00112  */
00113 class color_formatter : public logger_formatter {
00114 public:
00115         static ptr < color_formatter > create(lstring color);
00116         virtual ::std::ostream & format(const ptr<logger> &, ::std::ostream &);
00117         virtual void format_end(const ptr<logger> &, ::std::ostream &);
00118 protected:
00119         color_formatter(lstring b);
00120 private:
00121         lstring begin;
00122         color_formatter(const color_formatter &);
00123 };
00124 
00125 class shortname_formatter : public logger_formatter {
00126 public:
00127         static ptr < shortname_formatter > instance();
00128         virtual ::std::ostream & format(const ptr<logger> &, ::std::ostream &);
00129         virtual void format_end(const ptr<logger> &, ::std::ostream &);
00130 protected:
00131         shortname_formatter();
00132 private:
00133         shortname_formatter(const color_formatter &);
00134         static ptr < shortname_formatter > the_instance;
00135 };
00136 
00137 end_package(msg);
00138 end_package(lestes);
00139 
00140 #endif  // lestes__msg___logger_formatters_hh___included

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