diff --git a/src/feature_style_processor.cpp b/src/feature_style_processor.cpp index 4b78ab0a3..40eb4ad96 100644 --- a/src/feature_style_processor.cpp +++ b/src/feature_style_processor.cpp @@ -35,7 +35,7 @@ // boost #include - +#include //stl #include @@ -56,6 +56,33 @@ namespace mapnik { +template struct has_process; + +template +struct process_impl +{ + template + static void process(T0 & ren, T1 const& sym, T2 const& f, T3 const& tr) + { + ren.process(sym,f,tr); + } +}; + +template <> // No-op specialization +struct process_impl +{ + template + static void process(T0 & ren, T1 const& sym, T2 const& f, T3 const& tr) + { + boost::ignore_unused_variable_warning(ren); + boost::ignore_unused_variable_warning(f); + boost::ignore_unused_variable_warning(tr); +#ifdef MAPNIK_DEBUG + std::clog << "NO-OP ...\n"; +#endif + } +}; + /** Calls the renderer's process function, * \param output Renderer * \param f Feature to process @@ -75,14 +102,32 @@ struct feature_style_processor::symbol_dispatch : public boost::stati template void operator () (T const& sym) const { - output_.process(sym,f_,prj_trans_); + process_impl::value>::process(output_,sym,f_,prj_trans_); } - + Processor & output_; mapnik::feature_ptr f_; proj_transform const& prj_trans_; }; +typedef char (&no_tag)[1]; +typedef char (&yes_tag)[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 +{ + BOOST_STATIC_CONSTANT(bool + , value = sizeof(has_process_helper(0)) == sizeof(yes_tag) + ); +}; + + template feature_style_processor::feature_style_processor(Map const& m, double scale_factor) : m_(m), scale_factor_(scale_factor)