
#ifndef PLS_DATAFLOW_INTERNAL_BUFFER_H_
#define PLS_DATAFLOW_INTERNAL_BUFFER_H_

#include <array>

#include "in_port.h"

namespace pls {
namespace dataflow {
namespace internal {

template<int P, typename T>
struct static_buffer_impl {
  std::array<T, P> buffer_;

  const T &operator[](size_t i) const { return buffer_[i]; }
  T &operator[](size_t i) { return buffer_[i]; }

  static_buffer_impl() : buffer_{} {};
  explicit static_buffer_impl(T init) : buffer_(init) {};

  int capacity() const {
    return P;
  }
};

template<int P>
struct static_buffer {
  template<typename T>
  using type = static_buffer_impl<P, T>;
};

}
}
}

#endif //PLS_DATAFLOW_INTERNAL_BUFFER_H_
