Classes | Typedefs | Enumerations | Functions
test_tbb_dfp_any.cxx File Reference
#include "WireCellUtil/Testing.h"
#include <tbb/flow_graph.h>
#include <boost/any.hpp>
#include <string>
#include <deque>
#include <iostream>

Go to the source code of this file.

Classes

class  MockNode
 
class  MockSource
 
class  MockFunction
 
class  MockSink
 
class  TbbNodeWrapper
 
class  TbbSourceBody
 
class  TbbSourceNodeWrapper
 
class  TbbSinkBody
 
class  TbbSinkNodeWrapper
 

Typedefs

typedef std::shared_ptr< MockNodemock_node_pointer
 
typedef tbb::flow::sender< boost::any > sender_type
 
typedef tbb::flow::receiver< boost::any > receiver_type
 
typedef std::shared_ptr< sender_typesender_port_pointer
 
typedef std::shared_ptr< receiver_typereceiver_port_pointer
 
typedef std::vector< sender_port_pointersender_port_vector
 
typedef std::vector< receiver_port_pointerreceiver_port_vector
 
typedef tbb::flow::source_node< boost::any > source_node
 
typedef tbb::flow::function_node< boost::any > sink_node
 
typedef std::shared_ptr< TbbNodeWrapperTbbNode
 

Enumerations

enum  NodeCategory { unknownCat, sourceCat, sinkCat, functionCat }
 

Functions

mock_node_pointer get_node (const std::string &node_desc)
 
TbbNode make_node (tbb::flow::graph &graph, const std::string &node_desc)
 
bool connect (TbbNode sender, TbbNode receiver, size_t sport=0, size_t rport=0)
 
int main ()
 

Typedef Documentation

typedef std::shared_ptr<MockNode> mock_node_pointer

Definition at line 26 of file test_tbb_dfp_any.cxx.

typedef std::shared_ptr<receiver_type> receiver_port_pointer

Definition at line 103 of file test_tbb_dfp_any.cxx.

Definition at line 105 of file test_tbb_dfp_any.cxx.

typedef tbb::flow::receiver<boost::any> receiver_type

Definition at line 101 of file test_tbb_dfp_any.cxx.

typedef std::shared_ptr<sender_type> sender_port_pointer

Definition at line 102 of file test_tbb_dfp_any.cxx.

Definition at line 104 of file test_tbb_dfp_any.cxx.

typedef tbb::flow::sender<boost::any> sender_type

Definition at line 100 of file test_tbb_dfp_any.cxx.

typedef tbb::flow::function_node<boost::any> sink_node

Definition at line 108 of file test_tbb_dfp_any.cxx.

typedef tbb::flow::source_node<boost::any> source_node

Definition at line 107 of file test_tbb_dfp_any.cxx.

typedef std::shared_ptr<TbbNodeWrapper> TbbNode

Definition at line 124 of file test_tbb_dfp_any.cxx.

Enumeration Type Documentation

Enumerator
unknownCat 
sourceCat 
sinkCat 
functionCat 

Definition at line 14 of file test_tbb_dfp_any.cxx.

Function Documentation

bool connect ( TbbNode  sender,
TbbNode  receiver,
size_t  sport = 0,
size_t  rport = 0 
)

Definition at line 259 of file test_tbb_dfp_any.cxx.

260 {
261  Assert(sender);
262  Assert(receiver);
263  auto sports = sender->sender_ports();
264  auto rports = receiver->receiver_ports();
265 
266  Assert(sports.size() > sport);
267  Assert(rports.size() > rport);
268 
269  sender_type* s = sports[sport].get();
270  receiver_type* r = rports[rport].get();
271  Assert(s);
272  Assert(r);
273 
274  cerr << "Connecting " << s << " and " << r << endl;
275  make_edge(*s, *r);
276  return true;
277 }
#define Assert
Definition: Testing.h:7
tbb::flow::sender< boost::any > sender_type
tbb::flow::receiver< boost::any > receiver_type
static QCString * s
Definition: config.cpp:1042
QTextStream & endl(QTextStream &s)
mock_node_pointer get_node ( const std::string node_desc)

Definition at line 82 of file test_tbb_dfp_any.cxx.

83 {
84 
85  if (node_desc == "source") { // note actual desc should be class or class:inst
86  return mock_node_pointer(new MockSource);
87  }
88  if (node_desc == "drift") { // note actual desc should be class or class:inst
89  return mock_node_pointer(new MockFunction);
90  }
91  if (node_desc == "sink") { // note actual desc should be class or class:inst
92  return mock_node_pointer(new MockSink);
93  }
94  return nullptr;
95 }
std::shared_ptr< MockNode > mock_node_pointer
int main ( void  )

Definition at line 279 of file test_tbb_dfp_any.cxx.

280 {
282  TbbNode source = make_node(graph, "source");
283  Assert(source);
284  TbbNode sink = make_node(graph, "sink");
285  Assert(sink);
286 
287  Assert (connect(source, sink));
288 
289  sink->initialize();
290  source->initialize();
291 
292 
293  graph.wait_for_all();
294 
295  return 0;
296 }
bool connect(TbbNode sender, TbbNode receiver, size_t sport=0, size_t rport=0)
const CharType(& source)[N]
Definition: pointer.h:1147
TbbNode make_node(tbb::flow::graph &graph, const std::string &node_desc)
def graph(desc, maker=maker)
Definition: apa.py:294
#define Assert
Definition: Testing.h:7
std::shared_ptr< TbbNodeWrapper > TbbNode
TbbNode make_node ( tbb::flow::graph &  graph,
const std::string node_desc 
)

Definition at line 236 of file test_tbb_dfp_any.cxx.

237 {
238  mock_node_pointer wcnode = get_node(node_desc);
239  if (! wcnode) {
240  cerr << "Failed to get node for " << node_desc << endl;
241  return nullptr;
242  }
243 
244  cerr << "Getting node from category: " << wcnode->category() << endl;
245  switch (wcnode->category()) {
246  case sourceCat:
247  return TbbNode(new TbbSourceNodeWrapper(graph, wcnode));
248  case sinkCat:
249  return TbbNode(new TbbSinkNodeWrapper(graph, wcnode));
250  // case functionCat:
251  // return TbbNode(new TbbFunctionNodeWrapper(garph, wcnode));
252  default:
253  return nullptr;
254  }
255  return nullptr;
256 }
mock_node_pointer get_node(const std::string &node_desc)
def graph(desc, maker=maker)
Definition: apa.py:294
std::shared_ptr< MockNode > mock_node_pointer
std::shared_ptr< TbbNodeWrapper > TbbNode
QTextStream & endl(QTextStream &s)