#ifndef __JLANG__JCONVERSIONITERATOR__ #define __JLANG__JCONVERSIONITERATOR__ #include "JLang/JObjectIterator.hh" /** * \author mdejong */ namespace JLANG {} namespace JPP { using namespace JLANG; } namespace JLANG { /** * Interface for object iteration with type conversion. */ template class JConversionIterator : public JObjectIterator { public: typedef typename JObjectIterator::pointer_type pointer_type; /** * Constructor. * * \param input input iterator */ JConversionIterator(JObjectIterator& input) : in(input) {} /** * Check availability of next element. * * \return true if the iteration has more elements; else false */ virtual bool hasNext() override { return in.hasNext(); } /** * Get next element. * * \return pointer to element */ virtual const pointer_type& next() override { const JInput_t* p = in.next(); if (p != NULL) ps.reset(new JOutput_t(*p)); // type conversion else ps.reset(NULL); return ps; } protected: JObjectIterator& in; private: pointer_type ps; }; } #endif