Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
wire-cell-build
tbb
test
tbb_mock.h
Go to the documentation of this file.
1
#ifndef WIRECELLTBB_TBB_MOCK
2
#define WIRECELLTBB_TBB_MOCK
3
4
#include "
WireCellIface/IDepoSource.h
"
5
#include "
WireCellIface/IDrifter.h
"
6
#include "
WireCellIface/IDepoSink.h
"
7
#include "
WireCellIface/SimpleDepo.h
"
8
#include "
WireCellUtil/Units.h
"
9
10
#include <iostream>
11
12
13
namespace
WireCellTbb
{
14
15
class
MockDepoSource
:
public
WireCell::IDepoSource
{
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);
30
out =
WireCell::IDepo::pointer
(
new
WireCell::SimpleDepo
(time,pos));
31
std::cerr <<
"Source: "
<< out->time()/WireCell::units::millimeter <<
std::endl
;
32
return
true
;
33
}
34
};
35
36
class
MockDrifter
:
public
WireCell::IDrifter
{
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
59
class
MockDepoSink
:
public
WireCell::IDepoSink
{
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
WireCell::IData< IDepo >::pointer
std::shared_ptr< const IDepo > pointer
Definition:
IData.h:19
WireCellTbb::MockDepoSource::operator()
virtual bool operator()(output_pointer &out)
The calling signature:
Definition:
tbb_mock.h:22
WireCell::IDepoSink
Definition:
IDepoSink.h:11
WireCell::units::microsecond
static const double microsecond
Definition:
Units.h:94
WireCellTbb::MockDrifter::~MockDrifter
virtual ~MockDrifter()
Definition:
tbb_mock.h:39
IDepoSource.h
SimpleDepo.h
IDrifter.h
WireCellTbb::MockDepoSource::MockDepoSource
MockDepoSource(int maxdepos=10000)
Definition:
tbb_mock.h:19
WireCell::D3Vector< double >
WireCell::ISourceNode< IDepo >::output_pointer
std::shared_ptr< const IDepo > output_pointer
Definition:
ISourceNode.h:38
WireCell::IQueuedoutNode< IDepo, IDepo >::output_queue
std::deque< output_pointer > output_queue
Definition:
IQueuedoutNode.h:46
WireCellTbb::MockDrifter
Definition:
tbb_mock.h:36
time
WireCellTbb::MockDepoSource::m_maxdepos
const int m_maxdepos
Definition:
tbb_mock.h:17
WireCell::SimpleDepo
Definition:
SimpleDepo.h:8
WireCellTbb::MockDepoSink::~MockDepoSink
virtual ~MockDepoSink()
Definition:
tbb_mock.h:61
WireCellTbb::MockDepoSink::operator()
virtual bool operator()(const input_pointer &depo)
The calling signature:
Definition:
tbb_mock.h:62
WireCell::IDrifter
Definition:
IDrifter.h:18
MakeVectorFile.pos
tuple pos
Definition:
MakeVectorFile.py:66
WireCellTbb::MockDepoSource::m_count
int m_count
Definition:
tbb_mock.h:16
WireCellTbb
Definition:
DataFlowGraph.h:14
WireCell::units::millimeter
static const double millimeter
Definition:
Units.h:22
WireCellTbb::MockDepoSource
Definition:
tbb_mock.h:15
IDepoSink.h
WireCellTbb::MockDrifter::m_depos
std::deque< input_pointer > m_depos
Definition:
tbb_mock.h:37
WireCell::IQueuedoutNode< IDepo, IDepo >::input_pointer
std::shared_ptr< const IDepo > input_pointer
Definition:
IQueuedoutNode.h:44
WireCell::ISinkNode< IDepo >::input_pointer
std::shared_ptr< const IDepo > input_pointer
Definition:
ISinkNode.h:32
WireCellTbb::MockDepoSink
Definition:
tbb_mock.h:59
WireCellTbb::MockDrifter::operator()
virtual bool operator()(const input_pointer &in, output_queue &outq)
The calling signature:
Definition:
tbb_mock.h:41
endl
QTextStream & endl(QTextStream &s)
Definition:
qtextstream.cpp:2030
Units.h
WireCell::IDepoSource
Definition:
IDepoSource.h:11
WireCellTbb::MockDepoSource::~MockDepoSource
virtual ~MockDepoSource()
Definition:
tbb_mock.h:20
Generated by
1.8.11