reporter.cc

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 /*! \file
00029   \brief Message reporter.
00030 
00031   Definition of reporter class representing message reporter.
00032   \author pt
00033 */
00034 #include <lestes/common.hh>
00035 #include <lestes/std/source_location.hh>
00036 #include <lestes/std/ostream_wrapper.hh>
00037 #include <lestes/msg/message.hh>
00038 #include <lestes/msg/reporter.hh>
00039 #include <lestes/msg/report_end.hh>
00040 #include <iostream>
00041 
00042 package(lestes);
00043 package(msg);
00044 
00045 /*!
00046   Creates the only reporter.
00047 */
00048 reporter::reporter(void):
00049         filter(report_end::create())
00050 {
00051 }
00052 
00053 /*!
00054   Reports message at location. Calls process of the active filter.
00055   \pre a_message != NULL
00056   \pre a_location != NULL
00057   \pre filter != NULL
00058   \param a_message  The message to report.
00059   \param a_location  The associated location.
00060 */
00061 void reporter::report(const ptr<message> &a_message,
00062                         const ptr<source_location> &a_location)
00063 {
00064         lassert(a_message);
00065         lassert(a_location);
00066         
00067         filter->process(a_message,a_location);
00068 }
00069 
00070 /*! 
00071   Sets report filter to use for processing reports.
00072   \pre a_filter != NULL
00073   \param a_filter  The filter to set.
00074 */
00075 void reporter::filter_set(const ptr<report_filter> &a_filter)
00076 {
00077         lassert(a_filter);
00078         filter = a_filter;
00079 }
00080 
00081 /*! 
00082   Returns active filter.
00083   \return  The filter processing the reports.
00084 */
00085 ptr<report_filter> reporter::filter_get(void) const
00086 {
00087         return filter;
00088 }
00089 
00090 /*!
00091   Returns the only instance of the object.
00092   \return  The singleton reporter object.
00093 */
00094 ptr<reporter> reporter::instance(void)
00095 {
00096         if (!singleton) {
00097                 singleton = new reporter();
00098         }
00099         return singleton;
00100 }
00101 
00102 /*!
00103   The only instance of the class. Uses lazy instantiation.
00104 */
00105 ptr<reporter> reporter::singleton;
00106 
00107 end_package(msg);
00108 
00109 ptr< ::lestes::msg::reporter > report(::lestes::msg::reporter::instance());
00110 
00111 end_package(lestes);
00112 
00113 /* vim: set ft=lestes : */
00114 

Generated on Mon Feb 12 18:23:11 2007 for lestes by doxygen 1.5.1-20070107