Advertisement
Guest User

Untitled

a guest
Apr 19th, 2015
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.23 KB | None | 0 0
  1. template <typename... InputPortTypes>
  2. class PipelineReceiver
  3. {
  4.  
  5. protected:
  6.  
  7. // This tuple is used for storing types only
  8. // Hence, I would like to get rid of it, but I am not sure how.
  9. std::tuple<
  10. std::function<std::unique_ptr<InputPortTypes> (int)>...
  11. > InputPortsTuple;
  12.  
  13. // This vector is used for storing the actual objects
  14. // This is needed to be able to access/change its elements
  15. // during run time later on.
  16. // The vector is used for storage of function pointers that represent
  17. // methods of another object upstream the pipeline.
  18. std::vector<boost::any> InputPortsVector;
  19.  
  20. public:
  21.  
  22. PipelineReceiver()
  23. {
  24. // create an empty vector of the required size
  25. InputPortsVector.resize(sizeof...(InputPortTypes));
  26. }
  27.  
  28. void connectPorts(int InputPortIndex, boost::any c_OutputPort)
  29. {
  30. // connect ports
  31. InputPortsVector[InputPortIndex] = c_OutputPort;
  32. }
  33.  
  34. template<int N>
  35. void getInputPortValue(void)
  36. {
  37. std::cout <<
  38. *boost::any_cast<decltype(std::get<N>(this -> InputPortsTuple))>(
  39. InputPortsVector[N]
  40. )(0) <<
  41. std::endl;
  42. }
  43.  
  44. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement