Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- template <typename... InputPortTypes>
- class PipelineReceiver
- {
- protected:
- // This tuple is used for storing types only
- // Hence, I would like to get rid of it, but I am not sure how.
- std::tuple<
- std::function<std::unique_ptr<InputPortTypes> (int)>...
- > InputPortsTuple;
- // This vector is used for storing the actual objects
- // This is needed to be able to access/change its elements
- // during run time later on.
- // The vector is used for storage of function pointers that represent
- // methods of another object upstream the pipeline.
- std::vector<boost::any> InputPortsVector;
- public:
- PipelineReceiver()
- {
- // create an empty vector of the required size
- InputPortsVector.resize(sizeof...(InputPortTypes));
- }
- void connectPorts(int InputPortIndex, boost::any c_OutputPort)
- {
- // connect ports
- InputPortsVector[InputPortIndex] = c_OutputPort;
- }
- template<int N>
- void getInputPortValue(void)
- {
- std::cout <<
- *boost::any_cast<decltype(std::get<N>(this -> InputPortsTuple))>(
- InputPortsVector[N]
- )(0) <<
- std::endl;
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement