
#ifndef PLS_DATAFLOW_INPUT_H_
#define PLS_DATAFLOW_INPUT_H_

#include "token.h"

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

namespace pls {
namespace dataflow {

template<typename T>
class input {
  template<typename OT>
  friend
  class output;

  token<T> token_;
  bool filled_;
  bool connected_;

  void connect() {
    if (connected_) {
      PLS_ERROR("Must only connect on input once. Disconnect the output pointing to it before reconnecting.")
    }
    connected_ = true;
  }

 public:
  input() : filled_{false}, connected_{false} {};

  bool has_token(color color) const {
    return filled_ && token_.color() == color;
  }
  const token<T> &get_token() const { return token_; }
};

}
}

#endif //PLS_DATAFLOW_INPUT_H_
