![]() |
C++ API DOCUMENTATION |
00001 /***************************************************************************** 00002 * 00003 * This file is part of Mapnik (c++ mapping toolkit) 00004 * 00005 * Copyright (C) 2008 Tom Hughes 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 00024 //$Id$ 00025 00026 #ifndef BOOLEAN_FILTER_HPP 00027 #define BOOLEAN_FILTER_HPP 00028 // mapnik 00029 #include <mapnik/filter.hpp> 00030 #include <mapnik/expression.hpp> 00031 00032 namespace mapnik 00033 { 00034 template <typename FeatureT> 00035 struct boolean_filter : public filter<FeatureT> 00036 { 00037 00038 boolean_filter(expression<FeatureT> const& exp) 00039 : filter<FeatureT>(), 00040 exp_(exp.clone()) {} 00041 00042 boolean_filter(boolean_filter const& other) 00043 : filter<FeatureT>(), 00044 exp_(other.exp_->clone()) {} 00045 00046 bool pass(FeatureT const& feature) const 00047 { 00048 return exp_->get_value(feature).to_bool(); 00049 } 00050 00051 void accept(filter_visitor<FeatureT>& v) 00052 { 00053 exp_->accept(v); 00054 v.visit(*this); 00055 } 00056 00057 filter<FeatureT>* clone() const 00058 { 00059 return new boolean_filter(*this); 00060 } 00061 std::string to_string() const 00062 { 00063 return exp_->to_string(); 00064 } 00065 ~boolean_filter() 00066 { 00067 delete exp_; 00068 } 00069 00070 private: 00071 expression<FeatureT>* exp_; 00072 00073 }; 00074 } 00075 00076 00077 #endif //BOOLEAN_FILTER_HPP