CNES / EleFits

A modern C++ API on top of CFitsIO
https://cnes.github.io/EleFits
Other
13 stars 5 forks source link

Double dispatch CompressionAction to remove fptr from API #54

Closed kabasset closed 1 year ago

kabasset commented 1 year ago

CompressionAction::algo(Initializer<T>) -> std::unique_ptr<Compression>; // nullptr instead of false

template <typename T>
Strategy::compress(fitsfile* fptr, const ImageHdu::Initializer<T>& init) {
  for (const auto& c : m_compression) {
    if (auto algo = c->algo(init); algo) {
      algo->compress(fptr);
      return true;
    }
  }
  NoCompression().compress(fptr);
  return false;
}