/home/andreas/src/svn/mapnik/include/mapnik/filter.hpp

Go to the documentation of this file.
00001 /*****************************************************************************
00002  * 
00003  * This file is part of Mapnik (c++ mapping toolkit)
00004  *
00005  * Copyright (C) 2006 Artem Pavlenko
00006  *
00007  * This library is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU Lesser General Public
00009  * License as published by the Free Software Foundation; either
00010  * version 2.1 of the License, or (at your option) any later version.
00011  *
00012  * This library is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015  * Lesser General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU Lesser General Public
00018  * License along with this library; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00020  *
00021  *****************************************************************************/
00022 
00023 //$Id$
00024 
00025 #ifndef FILTER_HPP
00026 #define FILTER_HPP
00027 
00028 #include <mapnik/config.hpp>
00029 #include <mapnik/feature.hpp>
00030 
00031 namespace mapnik
00032 {
00033     template <typename FeatureT> class filter_visitor;
00034     template <typename FeatureT>
00035     class MAPNIK_DECL filter
00036     {
00037         public:
00038                 virtual bool pass(const FeatureT& feature) const=0; 
00039                 virtual filter<FeatureT>* clone() const=0;
00040                 virtual void accept(filter_visitor<FeatureT>& v) = 0;
00041         virtual std::string to_string() const=0;
00042                 virtual ~filter() {}
00043     };
00044     
00045     typedef boost::shared_ptr<filter<Feature> > filter_ptr;
00046     
00047     template <typename FeatureT>
00048     class all_filter : public filter<FeatureT>
00049     {
00050         public:
00051                 bool pass (const FeatureT&) const
00052                 {
00053                         return true;
00054                 }
00055         
00056                 filter<FeatureT>* clone() const
00057                 {
00058                         return new all_filter<FeatureT>;
00059                 }
00060                 std::string to_string() const
00061                 {
00062                         return "true";
00063                 }  
00064         void accept(filter_visitor<FeatureT>&) {}
00065                 virtual ~all_filter() {}
00066     };
00067       
00068     template <typename FeatureT>
00069     class none_filter : public filter<FeatureT>
00070     {
00071         public:
00072                 bool pass (const FeatureT&) const
00073                 {
00074                         return false;
00075                 }
00076         
00077                 filter<FeatureT>* clone() const
00078                 {
00079                         return new none_filter<FeatureT>;
00080                 }
00081                 std::string to_string() const
00082                 {
00083                         return "false";
00084                 }  
00085             void accept(filter_visitor<FeatureT>&) {}
00086                 virtual ~none_filter() {}
00087         };
00088 }
00089 
00090 #endif //FILTER_HPP

Generated on Thu Jul 19 17:59:26 2007 for Mapnik by  doxygen 1.4.7