#pragma once
class Image;
//! хранилище для простых текстур
class BankTex {
protected:
  Image* pTex = nullptr;
  index_t MAX = 0;
public:
  BankTex() = default;
  explicit constexpr BankTex(int size) { init(size); }
  nocopy(BankTex);
  ~BankTex() { free(); }
  void init(index_t size);
  void free();
  Image& operator[](index_t i);
  CN(Image) operator[](index_t i) const;
};
void BankTex::init(index_t size) {
  free();
  MAX = size;
  pTex = new Image[MAX];
}
void BankTex::free() {
  zdelete_arr(pTex);
  MAX = 0;
}
Image& BankTex::operator[](index_t i) {
  #ifdef DEBUG
  IFERROR( !pTex, "BankTex[] -> data is null");
  if (i >= MAX)
    a83::error("BankTex[] -> index overflow. Index(" + a83::n2s(i) + ")");
  #endif
  return pTex[i];
}
CN(Image) BankTex::operator[](index_t i) const {
  #ifdef DEBUG
  IFERROR( !pTex, "BankTex[] -> data is null");
  if (i >= MAX)
    a83::error("BankTex[] -> index overflow. Index(" + a83::n2s(i) + ")");
  #endif
  return pTex[i];
}