IJoinNode.h
Go to the documentation of this file.
1 #ifndef WIRECELL_IJOINNODE
2 #define WIRECELL_IJOINNODE
3 
4 #include "WireCellIface/INode.h"
5 
7 
8 #include <boost/any.hpp>
9 #include <vector>
10 #include <memory>
11 
12 namespace WireCell {
13 
14  /** A node which joins N data objects each of a distinct type and
15  * arriving synchronously to produce a single output object.
16  */
17 
18  class IJoinNodeBase : public INode
19  {
20  public:
21  typedef std::shared_ptr<IJoinNodeBase> pointer;
22 
23  virtual ~IJoinNodeBase() ;
24 
25  typedef std::vector<boost::any> any_vector;
26 
27  /// The calling signature:
28  virtual bool operator()(const any_vector& anyin, boost::any& anyout) = 0;
29 
30  virtual NodeCategory category() {
31  return joinNode;
32  }
33 
34  /// Join nodes can usually do their thing stateless.
35  virtual int concurrency() { return 0; }
36 
37 
38  };
39 
40  //
41  template <typename InputTuple, typename OutputType>
42  class IJoinNode : public IJoinNodeBase {
43  public:
44 
46  typedef typename port_helper_type::template WrappedConst<std::shared_ptr>::type input_tuple_type;
48 
49  typedef OutputType output_type;
50 
51  typedef std::shared_ptr<const OutputType> output_pointer;
52 
53  virtual ~IJoinNode(){}
54 
55  virtual bool operator()(const any_vector& anyv, boost::any& anyout) {
56  input_helper_type ih;
57  auto intup = ih.from_any(anyv);
58 
59  output_pointer out;
60  bool ok = (*this)(intup, out);
61  if (ok) {
62  anyout = out;
63  }
64  return ok;
65  }
66 
67  virtual bool operator()(const input_tuple_type& intup, output_pointer& out) = 0;
68 
69  // Return the names of the types this node takes as input.
70  virtual std::vector<std::string> input_types() {
71  port_helper_type iph;
72  return iph.type_names();
73  }
74  // Return the names of the types this node produces as output.
75  virtual std::vector<std::string> output_types() {
76  return std::vector<std::string>{typeid(output_type).name()};
77  }
78 
79  };
80 
81 }
82 
83 #endif
static QCString name
Definition: declinfo.cpp:673
virtual NodeCategory category()
Return the behavior category type.
Definition: IJoinNode.h:30
virtual std::vector< std::string > input_types()
Definition: IJoinNode.h:70
virtual bool operator()(const any_vector &anyin, boost::any &anyout)=0
The calling signature:
virtual ~IJoinNode()
Definition: IJoinNode.h:53
std::vector< boost::any > any_vector
Definition: IJoinNode.h:25
port_helper_type::template WrappedConst< std::shared_ptr >::type input_tuple_type
Definition: IJoinNode.h:46
tuple_helper< InputTuple > port_helper_type
Definition: IJoinNode.h:45
tuple_helper< input_tuple_type > input_helper_type
Definition: IJoinNode.h:47
std::shared_ptr< const OutputType > output_pointer
Definition: IJoinNode.h:51
virtual std::vector< std::string > output_types()
Definition: IJoinNode.h:75
Definition: Main.h:22
virtual bool operator()(const any_vector &anyv, boost::any &anyout)
The calling signature:
Definition: IJoinNode.h:55
static QCString type
Definition: declinfo.cpp:672
OutputType output_type
Definition: IJoinNode.h:49
virtual int concurrency()
Join nodes can usually do their thing stateless.
Definition: IJoinNode.h:35
std::shared_ptr< IJoinNodeBase > pointer
Definition: IJoinNode.h:21