ISourceNode.h
Go to the documentation of this file.
1 #ifndef WIRECELL_ISOURCENODE
2 #define WIRECELL_ISOURCENODE
3 
4 #include "WireCellIface/INode.h"
5 
6 #include <boost/any.hpp>
7 #include <vector>
8 
9 namespace WireCell {
10 
11  /** A node which acts as a source.
12  */
13  class ISourceNodeBase : public INode
14  {
15  public:
16  typedef std::shared_ptr<ISourceNodeBase> pointer;
17 
18 
19  virtual ~ISourceNodeBase() ;
20 
21  virtual NodeCategory category() {
22  return sourceNode;
23  }
24 
25  virtual bool operator()(boost::any& anyout)=0;
26  };
27 
28 
29  template <typename OutputType>
31  {
32  public:
33  typedef OutputType output_type;
34 
36  typedef std::shared_ptr<signature_type> pointer;
37 
38  typedef std::shared_ptr<const OutputType> output_pointer;
39 
40  virtual ~ISourceNode() {}
41 
42  virtual NodeCategory category() {
43  return sourceNode;
44  }
45 
46  /// Set the signature for all subclasses.
47  virtual std::string signature() {
48  return typeid(signature_type).name();
49  }
50 
51  virtual bool operator()(boost::any& anyout) {
52  output_pointer out;
53  bool ok = (*this)(out);
54  if (!ok) return false;
55  anyout = out;
56 
57  return true;
58  }
59 
60  /// The calling signature:
61  virtual bool operator()(output_pointer& out) = 0;
62 
63  // Return the names of the types this node takes as output.
64  virtual std::vector<std::string> output_types() {
65  return std::vector<std::string>{typeid(output_type).name()};
66  }
67 
68  };
69 
70 }
71 
72 #endif
static QCString name
Definition: declinfo.cpp:673
ISourceNode< OutputType > signature_type
Definition: ISourceNode.h:35
virtual bool operator()(boost::any &anyout)
Definition: ISourceNode.h:51
std::string string
Definition: nybbler.cc:12
virtual std::string signature()
Set the signature for all subclasses.
Definition: ISourceNode.h:47
virtual bool operator()(boost::any &anyout)=0
virtual NodeCategory category()
Return the behavior category type.
Definition: ISourceNode.h:42
std::shared_ptr< const OutputType > output_pointer
Definition: ISourceNode.h:38
virtual NodeCategory category()
Return the behavior category type.
Definition: ISourceNode.h:21
virtual std::vector< std::string > output_types()
Definition: ISourceNode.h:64
Definition: Main.h:22
std::shared_ptr< ISourceNodeBase > pointer
Definition: ISourceNode.h:16
OutputType output_type
Definition: ISourceNode.h:33
std::shared_ptr< signature_type > pointer
Definition: ISourceNode.h:36
virtual ~ISourceNode()
Definition: ISourceNode.h:40