CatapultServer  v0.5.0.1 (Elephant)
BasicProducer.h
Go to the documentation of this file.
1 
21 #pragma once
22 
23 namespace catapult { namespace handlers {
24 
26  template<typename TContainer>
27  class BasicProducer {
28  public:
30  explicit BasicProducer(const TContainer& container)
31  : m_container(container)
32  , m_iter(m_container.cbegin())
33  {}
34 
35  protected:
37  template<typename TConverter>
38  auto next(TConverter convert) {
39  return m_container.cend() == m_iter ? nullptr : convert(*m_iter++);
40  }
41 
42  private:
43  const TContainer& m_container;
44  decltype(TContainer().cbegin()) m_iter;
45  };
46 }}
catapult::handlers::BasicProducer::m_container
const TContainer & m_container
Definition: BasicProducer.h:43
catapult
Definition: AddressExtractionExtension.cpp:28
catapult::handlers::BasicProducer::next
auto next(TConverter convert)
Produces the next entity and calls convert for any required adaptation.
Definition: BasicProducer.h:38
catapult::handlers::BasicProducer::m_iter
decltype(TContainer().cbegin()) m_iter
Definition: BasicProducer.h:44
catapult::handlers::BasicProducer
A base class for producers.
Definition: BasicProducer.h:27
catapult::handlers::BasicProducer::BasicProducer
BasicProducer(const TContainer &container)
Creates a producer around container.
Definition: BasicProducer.h:30