RaftLib  0.3a
C++ Stream Processing Template Library
kernel.hpp
1 
20 #ifndef _KERNEL_HPP_
21 #define _KERNEL_HPP_ 1
22 
23 #include <utility>
24 
25 #include "port.hpp"
26 #include "signalvars.hpp"
27 #include "rafttypes.hpp"
28 
29 class MapBase;
30 class Schedule;
31 
32 #ifndef CLONE
33 namespace raft
34 {
35  class kernel;
36 }
37 
38 #define CLONE() \
39 virtual raft::kernel* clone()\
40 {\
41  return( new typename std::remove_reference< decltype( *this ) >::type( ( *(\
42  (typename std::decay< decltype( *this ) >::type * ) \
43  this ) ) ) );\
44 }
45 #endif
46 
47 namespace raft {
48 class kernel
49 {
50 public:
52  kernel();
53 
55  kernel( void * const ptr,
56  const std::size_t nbytes );
57 
58  virtual ~kernel() = default;
59 
60 
68  virtual raft::kstatus run() = 0;
69 
70 
71  template < class T ,
72  class ... Args >
73  static kernel* make( Args&&... params )
74  {
75  return( new T( std::forward< Args >( params )... ) );
76  }
77 
87  virtual raft::kernel* clone()
88  {
89  //FIXME, needs to throw an exception
90  assert( false );
91  return( nullptr );
92  }
93 
94  std::size_t get_id();
95 protected:
100  Port input = { this };
101  Port output = { this };
102 
103 
104  friend class ::MapBase;
105  friend class ::Schedule;
106  friend class ::GraphTools;
107 
113  static std::size_t kernel_count;
114 
115 private:
116  const std::size_t kernel_id;
117  bool active = true;
118 };
119 }
120 #endif /* END _KERNEL_HPP_ */
Port input
Definition: kernel.hpp:100
kernel()
Definition: kernel.cpp:11
Definition: mapbase.hpp:98
virtual raft::kstatus run()=0
virtual raft::kernel * clone()
Definition: kernel.hpp:87
Definition: port.hpp:50
Definition: schedule.hpp:31
Definition: kernel.hpp:48
Definition: globalmap.cpp:3
static std::size_t kernel_count
Definition: kernel.hpp:113