GrPPI  0.3.1
Generic and Reusable Parallel Pattern Interface
iteration_nodes.h
Go to the documentation of this file.
1 
21 #ifndef GRPPI_FF_DETAIL_ITERATION_NODES_H
22 #define GRPPI_FF_DETAIL_ITERATION_NODES_H
23 
24 #include <vector>
25 
26 #include <ff/node.hpp>
27 
28 namespace grppi {
29 
30 namespace detail_ff {
31 
32 template<typename Item, typename Iteration>
33 class iteration_worker : public ff::ff_node_t<Item> {
34 public:
35  iteration_worker(Iteration && iteration) :
36  iteration_{std::move(iteration)}
37  {}
38 
39  Item * svc(Item * p_item) {
40  do {
41  *p_item = iteration_.transform(*p_item);
42  }
43  while (!iteration_.predicate(*p_item));
44  return p_item;
45  }
46 
47 private:
48  Iteration iteration_;
49 };
50 
51 } // namespace detail_ff
52 
53 } // namespace grppi
54 
55 #endif
Definition: callable_traits.h:26
Item * svc(Item *p_item)
Definition: iteration_nodes.h:39
Definition: iteration_nodes.h:33
iteration_worker(Iteration &&iteration)
Definition: iteration_nodes.h:35