Midge  v3.9.2
Data Processing Framework
_input.hh
Go to the documentation of this file.
1 #ifndef _midge__input_hh_
2 #define _midge__input_hh_
3 
4 #include "midge_error.hh"
5 #include "_stream.hh"
6 #include "input.hh"
7 
8 #include "typename.hh"
9 
10 namespace midge
11 {
12 
13  template< class x_node, class x_type >
14  class _input :
15  public input
16  {
17  public:
18  _input( x_node* p_node, void (x_node::*p_member)( _stream< x_type >* ) ) :
19  f_node( p_node ),
20  f_member( p_member )
21  {
22  }
23  virtual ~_input()
24  {
25  }
26 
27  public:
28  void set( stream* p_stream )
29  {
30  stream* t_stream = p_stream;
31  _stream< x_type >* t_typed_stream = dynamic_cast< _stream< x_type >* >( t_stream );
32  if( t_typed_stream == NULL )
33  {
34  throw error() << "input <" << get_name() << "> on node <" << f_node->get_name() << "> cannot cast the provided stream down to the expected specific type\n" <<
35  "Look for a mismatch between the data types in:\n" <<
36  "\tOutput: " << scarab::type( *p_stream ) << '\n' <<
37  "\tInput: " << scarab::type( t_typed_stream );
38  }
39 
40  t_typed_stream->label() = f_node->get_name() + ":" + get_name();
41  (f_node->*f_member)( t_typed_stream );
42  return;
43  }
44 
45  private:
46  x_node* f_node;
47  void (x_node::*f_member)( _stream< x_type >* );
48  };
49 
50 }
51 
52 #endif
virtual ~_input()
Definition: _input.hh:23
Definition: _buffer.hh:11
void(x_node::* f_member)(_stream< x_type > *)
Definition: _input.hh:47
x_node * f_node
Definition: _input.hh:46
_input(x_node *p_node, void(x_node::*p_member)(_stream< x_type > *))
Definition: _input.hh:18