diff --git a/include/mapnik/symbolizer_dispatch.hpp b/include/mapnik/symbolizer_dispatch.hpp new file mode 100644 index 000000000..a0320cc77 --- /dev/null +++ b/include/mapnik/symbolizer_dispatch.hpp @@ -0,0 +1,110 @@ +/***************************************************************************** + * + * This file is part of Mapnik (c++ mapping toolkit) + * + * Copyright (C) 2014 Artem Pavlenko + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + *****************************************************************************/ + +#ifndef MAPNIK_SYMBOLIZER_DISPATCH_HPP +#define MAPNIK_SYMBOLIZER_DISPATCH_HPP + +// mapnik +#include +#include +#include +#include + +namespace mapnik +{ + +template struct has_process; + +template +struct process_impl +{ + template + static void process(T0 & ren, T1 const& sym, T2 & f, T3 const& tr) + { + ren.process(sym,f,tr); + } +}; + +template <> // No-op specialization +struct process_impl +{ + template + static void process(T0 &, T1 const&, T2 &, T3 const&) + { +#ifdef MAPNIK_DEBUG + #ifdef _MSC_VER + #pragma NOTE(process function not implemented) + #else + #warning process function not implemented + #endif +#endif + } +}; + +/** Calls the renderer's process function, + * \param output Renderer + * \param f Feature to process + * \param prj_trans Projection + * \param sym Symbolizer object + */ +template +struct symbolizer_dispatch : public util::static_visitor<> +{ + symbolizer_dispatch(Processor & output, + mapnik::feature_impl & f, + proj_transform const& prj_trans) + : output_(output), + f_(f), + prj_trans_(prj_trans) {} + + template + void operator () (T const& sym) const + { + process_impl::value>::process(output_,sym,f_,prj_trans_); + } + + Processor & output_; + mapnik::feature_impl & f_; + proj_transform const& prj_trans_; +}; + +using no_tag = char (&)[1]; +using yes_tag = char (&)[2]; + +template +struct process_memfun_helper {}; + +template no_tag has_process_helper(...); +template yes_tag has_process_helper(process_memfun_helper* p); + +template +struct has_process +{ + using processor_impl_type = typename T0::processor_impl_type; + BOOST_STATIC_CONSTANT(bool + , value = sizeof(has_process_helper(0)) == sizeof(yes_tag) + ); +}; + +} + +#endif // MAPNIK_SYMBOLIZER_DISPATCH_HPP