tbb_mock.h
Go to the documentation of this file.
1 #ifndef WIRECELLTBB_TBB_MOCK
2 #define WIRECELLTBB_TBB_MOCK
3 
8 #include "WireCellUtil/Units.h"
9 
10 #include <iostream>
11 
12 
13 namespace WireCellTbb {
14 
16  int m_count;
17  const int m_maxdepos;
18  public:
19  MockDepoSource(int maxdepos = 10000) : m_count(0), m_maxdepos(maxdepos) {}
20  virtual ~MockDepoSource() {}
21 
22  virtual bool operator()(output_pointer& out) {
23  if (m_count > m_maxdepos) {
24  return false;
25  }
26  ++m_count;
27  double dist = m_count*WireCell::units::millimeter;
28  double time = m_count*WireCell::units::microsecond;
29  WireCell::Point pos(dist,dist,dist);
31  std::cerr << "Source: " << out->time()/WireCell::units::millimeter << std::endl;
32  return true;
33  }
34  };
35 
37  std::deque<input_pointer> m_depos;
38  public:
39  virtual ~MockDrifter() {}
40 
41  virtual bool operator()(const input_pointer& in, output_queue& outq) {
42  m_depos.push_back(in);
43 
44  // simulate some buffering condition
45  size_t n_to_keep = 2;
46  if (!in) { n_to_keep = 0; }
47 
48  while (m_depos.size() > n_to_keep) {
49  auto depo = m_depos.front();
50  m_depos.pop_front();
51  outq.push_back(depo);
52  std::cerr << "Drift: " << depo->time()/WireCell::units::millimeter << std::endl;
53  }
54 
55  return true;
56  }
57  };
58 
60  public:
61  virtual ~MockDepoSink() {}
62  virtual bool operator()(const input_pointer& depo) {
63  std::cerr << "Sink: " << depo->time()/WireCell::units::millimeter << std::endl;
64  return true;
65  }
66  };
67 
68 }
69 #endif
std::shared_ptr< const IDepo > pointer
Definition: IData.h:19
virtual bool operator()(output_pointer &out)
The calling signature:
Definition: tbb_mock.h:22
static const double microsecond
Definition: Units.h:94
virtual ~MockDrifter()
Definition: tbb_mock.h:39
MockDepoSource(int maxdepos=10000)
Definition: tbb_mock.h:19
std::shared_ptr< const IDepo > output_pointer
Definition: ISourceNode.h:38
std::deque< output_pointer > output_queue
virtual bool operator()(const input_pointer &depo)
The calling signature:
Definition: tbb_mock.h:62
static const double millimeter
Definition: Units.h:22
std::deque< input_pointer > m_depos
Definition: tbb_mock.h:37
std::shared_ptr< const IDepo > input_pointer
std::shared_ptr< const IDepo > input_pointer
Definition: ISinkNode.h:32
virtual bool operator()(const input_pointer &in, output_queue &outq)
The calling signature:
Definition: tbb_mock.h:41
QTextStream & endl(QTextStream &s)