
#ifndef PLS_DATAFLOW_INTERNAL_OUTPUT_H_
#define PLS_DATAFLOW_INTERNAL_OUTPUT_H_

#include "token.h"
#include "input.h"

#include "pls/internal/base/error_handling.h"

namespace pls {
namespace dataflow {
namespace internal {

template<int P, typename T>
class output {
  input<P, T> *target_;
  bool connected_;

 public:
  output() : target_{nullptr}, connected_{false} {};

  void connect(input<P, T> &target) {
    if (connected_) {
      PLS_ERROR("Must only connect output once. Please disconnect it before reconnecting.")
    }

    target.connect();
    target_ = &target;
    connected_ = true;
  }

  void push_token(token<T> token) {
    target_->push_token(token);
  }
};

}
}
}

#endif //PLS_DATAFLOW_INTERNAL_OUTPUT_H_
