Jakowlew

Untitled

Mar 4th, 2021
950
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. template<typename, typename>
  2. struct PipeNode {};
  3.  
  4. template<Filter T, Filter U>
  5. struct PipeNode<T, U> {
  6.     using input_t = typename T::resource_t;
  7.     using return_t = decltype(std::declval<U>()(std::declval<T>()(std::declval<input_t&>())));
  8.  
  9.     T left;
  10.     U right;
  11.  
  12.     decltype(auto) operator()(input_t& frame)
  13.     {
  14.         return right(left(frame));
  15.     }
  16. };
  17.  
  18. template<typename Pipe, Filter T>
  19.     requires std::is_convertible_v<typename Pipe::return_t, typename T::resource_t>
  20. struct PipeNode<Pipe, T> {
  21.     using input_t = typename Pipe::input_t;
  22.     using return_t = decltype(std::declval<T>()(std::declval<Pipe>()(std::declval<input_t&>())));
  23.  
  24.     Pipe left;
  25.     T right;
  26.  
  27.     decltype(auto) operator()(input_t& frame)
  28.     {
  29.         return right(left(frame));
  30.     };
  31. };
  32.  
  33. template<Filter T, Filter U>
  34. auto addToPipe(T&& left, U&& right) {
  35.     return PipeNode<T, U>{std::move(left), std::move(right)};
  36. }
  37.  
  38. template<typename Pipe, Filter U>
  39. auto addToPipe(Pipe&& left, U&& right) {
  40.     return PipeNode<Pipe, U>{std::move(left), std::move(right)};
  41. }
  42.  
  43. int main()
  44. {
  45.     ImageManager imageManager;
  46.     auto img = imageManager.read("C:/Users/jakow/Documents/Programming/aart/test.png");
  47.     show(img);
  48.  
  49.     //ScaleFilter scaleFilter{0.5f, 0.5f};
  50.     //scaleFilter(img);
  51.  
  52.     //GrayscaleFilter grayscaleFilter{};
  53.     //grayscaleFilter(img);
  54.  
  55.     //auto pipe = addToPipe(ScaleFilter{0.5f, 0.5f}, GrayscaleFilter{});
  56.     //auto pipe2 = addToPipe(std::move(pipe), ScaleFilter{2.f, 2.f});
  57.     //auto pipe3 = addToPipe(std::move(pipe2), ScaleFilter{2.f, 2.f});
  58.     auto pipe = addToPipe(addToPipe(addToPipe(ScaleFilter{0.5f, 0.5f}, GrayscaleFilter{}), ScaleFilter{2.f, 2.f}), ScaleFilter{2.f, 2.f});
  59.     pipe(img);
  60.     show(img);
  61.  
  62. }
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×