report_kind_filter.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 Report kind filter.
00030 
00031   Definition of report_kind_filter class representing report kind filter.
00032   \author pt
00033 */
00034 #include <lestes/common.hh>
00035 #include <lestes/std/source_location.hh>
00036 #include <lestes/msg/message.hh>
00037 #include <lestes/msg/message_stencil.hh>
00038 #include <lestes/msg/report_kind_filter.hh>
00039 
00040 package(lestes);
00041 package(msg);
00042 
00043 /*! 
00044   Creates the report kind filter.
00045   \param a_output  The output of the filter.
00046   \param a_stencils  The stencil list.
00047 */
00048 report_kind_filter::report_kind_filter(const ptr<report_filter> &a_output, 
00049                 const ptr<stencils_type> &a_stencils):
00050         report_filter(checked(a_output)),
00051         disabled(disabled_type::create())
00052 {
00053         lassert(a_stencils);
00054         
00055         for (stencils_type::iterator it = a_stencils->begin(), end = a_stencils->end();
00056                         it != end; ++it) {
00057                 disabled->insert((*it)->kind_get());
00058         }
00059 }
00060         
00061 /*!
00062   Discards all reports of specified kinds, other reports are passed to output.
00063   \pre a_message != NULL
00064   \pre a_location != NULL
00065   \param a_message  The message to process.
00066   \param a_location  The location to process.
00067 */
00068 void report_kind_filter::process(const ptr<message> &a_message,
00069                 const ptr<source_location> &a_location)
00070 {
00071         lassert(a_message);
00072         lassert(a_location);
00073   
00074         // check if the kind is not disabled
00075         if (disabled->find(a_message->kind_get()) != disabled->end()) {
00076                 process_output(a_message,a_location);
00077         }
00078 }
00079 
00080 /*! 
00081   Returns new report kind filter, initializes with output and list of stencils of disabled messages.
00082   \pre a_output != NULL
00083   \pre a_stencils != NULL
00084   \param a_output  The output of the filter.
00085   \param a_stencils  The stencils whose messages will be disabled.
00086   \return New report kind filter.
00087 */
00088 ptr<report_kind_filter> report_kind_filter::create(const ptr<report_filter> &a_output, 
00089                 const ptr<stencils_type> &a_stencils)
00090 {
00091         return new report_kind_filter(a_output,a_stencils);
00092 }
00093 
00094 end_package(msg);
00095 end_package(lestes);
00096 /* vim: set ft=lestes : */

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