#ifndef __JFUNCTIONALMAP__ #define __JFUNCTIONALMAP__ #include "JTools/JFunctional.hh" namespace JTOOLS { /** * Template definition of a functional map. */ template class JMap_t, class JResult_t> class JFunctionalMap; /** * Template specialisation of compilable functional map with same return type as function object. * This class implements the JFunction<>::compile() method. */ template class JMap_t> class JFunctionalMap : public virtual JFunction, public JMap_t { public: typedef typename JFunction_t::argument_type argument_type; typedef typename JFunction_t::result_type result_type; typedef JMap_t JCollection_t; typedef typename JCollection_t::key_type key_type; typedef typename JCollection_t::mapped_type mapped_type; typedef typename JCollection_t::value_type value_type; typedef typename JCollection_t::const_iterator const_iterator; typedef typename JCollection_t::const_reverse_iterator const_reverse_iterator; typedef typename JCollection_t::iterator iterator; typedef typename JCollection_t::reverse_iterator reverse_iterator; /** * Function compilation. */ void compile() { for (typename JCollection_t::iterator i = JCollection_t::begin(); i != JCollection_t::end(); ++i) i->second.compile(); } }; /** * Template specialisation of compilable functional map with recursively expanding return type. * This class implements the JFunction<>::compile() method. */ template class JMap_t, template class JResult_t> class JFunctionalMap > : public virtual JFunction >, public JMap_t { public: typedef typename JFunction_t::argument_type argument_type; typedef JResult_t result_type; typedef JMap_t JCollection_t; typedef typename JCollection_t::key_type key_type; typedef typename JCollection_t::mapped_type mapped_type; /** * Function compilation. */ void compile() { for (typename JCollection_t::iterator i = JCollection_t::begin(); i != JCollection_t::end(); ++i) i->second.compile(); } }; } #endif