// Headers are available because we added the pls target
#include <string>
#include <cstdio>
#include <tuple>

#include <pls/pls.h>
#include <pls/dataflow/graph.h>
#include <pls/dataflow/internal/token.h>

int main() {
  using namespace pls::dataflow;

  graph<inputs<int, int>, outputs<int, int>, 2> graph2;
  graph2.input<0>() >> graph2.output<1>();
  graph2.input<1>() >> graph2.output<0>();

  graph<inputs<int, int>, outputs<int, int>, 2> graph1;
  graph1.input<0>() >> graph2.external_input<0>();
  graph1.input<1>() >> graph2.external_input<1>();
  graph2.external_output<0>() >> graph1.output<0>();
  graph2.external_output<1>() >> graph1.output<1>();

  graph1.push_input(1, 2);
  graph1.push_input(3, 4);

  auto result1 = graph1.get_output();
  std::cout << std::get<0>(result1) << ", " << std::get<1>(result1) << std::endl;

  graph1.push_input(5, 6);

  auto result2 = graph1.get_output();
  std::cout << std::get<0>(result2) << ", " << std::get<1>(result2) << std::endl;

  auto result3 = graph1.get_output();
  std::cout << std::get<0>(result3) << ", " << std::get<1>(result3) << std::endl;
}
