RaftLib  0.3a
C++ Stream Processing Template Library
splitmethod.hpp
1 
20 #ifndef _SPLITMETHOD_HPP_
21 #define _SPLITMETHOD_HPP_ 1
22 
23 #include "signalvars.hpp"
24 #include "port.hpp"
25 #include "fifo.hpp"
26 
28 {
29 public:
30  splitmethod() = default;
31  virtual ~splitmethod() = default;
32 
33  template < class T /* item */ >
34  bool send( T &item, const raft::signal signal, Port &outputs )
35  {
36  auto *fifo( select_fifo( outputs, sendtype ) );
37  if( fifo != nullptr )
38  {
39  fifo->push( item, signal );
40  return( true );
41  }
42  else
43  {
44  return( false );
45  }
46  }
47 
48  template < class T /* item */ >
49  bool get( T &item, raft::signal &signal, Port &inputs )
50  {
51  auto *fifo( select_fifo( inputs, gettype ) );
52  if( fifo != nullptr )
53  {
54  fifo->pop< T >( item, &signal );
55  return( true );
56  }
57  else
58  {
59  return( false );
60  }
61  }
62 protected:
63  enum functype { sendtype, gettype };
64  virtual FIFO* select_fifo( Port &port_list, const functype type ) = 0;
65 };
66 #endif /* END _SPLITMETHOD_HPP_ */
Definition: port.hpp:50
Definition: fifo.hpp:41
Definition: splitmethod.hpp:27