Jpp  17.3.0-rc.2
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JConversionIterator.hh
Go to the documentation of this file.
1 #ifndef __JLANG__JCONVERSIONITERATOR__
2 #define __JLANG__JCONVERSIONITERATOR__
3 
5 
6 
7 /**
8  * \author mdejong
9  */
10 
11 namespace JLANG {}
12 namespace JPP { using namespace JLANG; }
13 
14 namespace JLANG {
15 
16  /**
17  * Interface for object iteration with type conversion.
18  */
19  template<class JInput_t, class JOutput_t>
21  public JObjectIterator<JOutput_t>
22  {
23  public:
24 
26 
27 
28  /**
29  * Constructor.
30  *
31  * \param input input iterator
32  */
34  in(input)
35  {}
36 
37 
38  /**
39  * Check availability of next element.
40  *
41  * \return true if the iteration has more elements; else false
42  */
43  virtual bool hasNext() override
44  {
45  return in.hasNext();
46  }
47 
48 
49  /**
50  * Get next element.
51  *
52  * \return pointer to element
53  */
54  virtual const pointer_type& next() override
55  {
56  const JInput_t* p = in.next();
57 
58  if (p != NULL)
59  ps.reset(new JOutput_t(*p)); // type conversion
60  else
61  ps.reset(NULL);
62 
63  return ps;
64  }
65 
66  protected:
68  private:
70  };
71 }
72 
73 #endif
JConversionIterator(JObjectIterator< JInput_t > &input)
Constructor.
Interface of object iteration for a single data type.
virtual const pointer_type & next() override
Get next element.
JObjectIterator< JOutput_t >::pointer_type pointer_type
virtual const pointer_type & next()=0
Get next element.
JObjectIterator< JInput_t > & in
Interface for object iteration with type conversion.
virtual bool hasNext()=0
Check availability of next element.
virtual bool hasNext() override
Check availability of next element.