YPC  0.2.0
split.h
1 #pragma once
2 #include <hpda/extractor/raw_data.h>
3 #include <hpda/output/output_base.h>
4 //#include <hpda/processor/processor_base.h>
5 
6 namespace hpda {
7 namespace processor {
8 namespace internal {
9 
10 template <typename InputObjType>
11 class split_impl : public ::hpda::output::internal::output_base<InputObjType> {
12 public:
13  typedef ::hpda::output::internal::output_base<InputObjType> base;
14 
15  typedef ::hpda::extractor::internal::raw_data_impl<InputObjType> stream_type;
16  split_impl(
19  }
20 
22  m_streams.push_back(std::unique_ptr<stream_type>(new stream_type()));
23  auto ret = m_streams.back().get();
24  ret->set_engine(base::get_engine());
25  ret->add_predecessor(this);
26  return ret;
27  }
28 
29  virtual bool process() {
30  if (!base::has_input_value()) {
31  return false;
32  }
33  auto t = base::input_value();
34  for (auto &it : m_streams) {
35  it->add_data(t.make_copy());
36  }
37  base::consume_input_value();
38  return true;
39  }
40 
41 protected:
42  std::vector<std::unique_ptr<stream_type>> m_streams;
43 };
44 } // namespace internal
45 template <typename... ARGS>
46 using split = internal::split_impl<ntobject<ARGS...>>;
47 } // namespace processor
48 } // namespace hpda
hpda::processor::internal::split_impl
Definition: split.h:11
hpda::extractor::internal::raw_data_impl
Definition: raw_data.h:11
hpda::internal::processor_with_input
Definition: processor_with_input.h:10
hpda::output::internal::output_base
Definition: output_base.h:10
hpda::internal::processor_with_output< InputObjType >