Home

Awesome

Pipet

Build Status

Pipet is a lightweight c++17 headers-only library than can be used to build simple processing pipelines at compile time.

Features

Supported Platforms

Tests have been performed on the following platforms:

Install

    > git clone https://github.com/kenavolic/pipet.git
    > mkdir pipet_build
    > cd pipet_build
    > cmake -DCMAKE_INSTALL_PREFIX=$path_to_pipet_install_dir -DPIPET_BUILD_EXAMPLES=[ON|OFF] -DPIPET_BUILD_TESTS=[ON|OFF] ../pipet
    > make
    > make install
+ /!\ On windows, open generated solution and build solution and install target

Usage

Examples

The projet include the following examples:

Import pipet to your project

    find_package(pipet REQUIRED)
    ...
    target_link_libraries(my_proj pipet::pipet)
    > cmake -DCMAKE_PREFIX_PATH=$path_to_pipet_install_dir/cmake $path_to_your_proj_source_dir

Implement a pipeline

The example directory provide two examples of pipet usage. Basically, all you need to do is:

    struct filter
    {
        static constexpr out_type process(in_type my_param)
        {
            // do processing
            return my_result;
        }
        
        static constexpr in_type reverse(out_type my_param)
        {
            // do processing
            return my_result;
        }
    };
    using my_processing_pipe = pipet::pipe<filter1, filter2, filter3>;
    constexpr auto res = my_processing_pipe::process(); // if filter 1 is a data generator (no input type)
    constexpr auto res = my_processing_pipe::process(var); // if filter 1 is processing filter
  struct f1_proc_ct {
    static constexpr auto process(int a) { return a; }
  };

  // compute a*a
  struct f_square_ct {
    static constexpr auto process(int a) { return a * a; }
  };

  // compute a*a*a
  struct f_cube_ct {
    static constexpr auto process(int a) { return a * a * a; }
  };

  // add 3 different inputs
  struct f_add3_ct {
    static constexpr auto process(int a, int b, int c) { return a + b + c; }
  };

  using branch1_t = pipet::pipe<f1_proc_ct, f_square_ct>;
  using branch2_t = pipet::pipe<f_cube_ct, f1_proc_ct>;

  // y = x*x + x*x + x*x*x
  using pipe_with_branches_t =
      pipet::pipe<f1_proc_ct, pipet::branches<branch1_t, branch1_t, branch2_t>,
                  f_add3_ct>;
  
  static_assert(pipe_with_branches_t::process(2) == 16,
                "[-][pipet_test] pipe processing failed");
  ... (see previous sample)

  // y = x + x*x + x*x*x
  using pipe_with_direct_branches_t = pipet::pipe<
      f1_proc_ct,
      pipet::branches<pipet::placeholders::self, branch1_t, branch2_t>,
      f_add3_ct>;
  static_assert(pipe_with_direct_branches_t::process(2) == 14,
                "[-][pipet_test] pipe processing failed");