#pragma once

#include "xtr/doc/OSSDoc.h"

namespace xtr::io {

//! Legacy loader
class OSSLegacyLoader {
  io::CArchiveAdapter& ar;
  ccl::oss::OSSchema& oss;

public:
  OSSVersion version{ OSSVersion::old };
  ccl::oss::PictID selection{};

public:
  OSSLegacyLoader(CArchiveAdapter& ar, ccl::oss::OSSchema& oss) noexcept
    : ar{ ar }, oss{ oss } {}

public:
  void LoadVersion();
  void DoLoad();

private:
  void LoadFirstGen();
  void LoadPictGen1();
  [[nodiscard]] static uint32_t LoadPictStatus(uint32_t code) noexcept;
  [[nodiscard]] static ccl::ops::Type LoadOperationType(uint32_t code) noexcept;
  
  void LoadSecondGen();
  void LoadPictGen2();
  ccl::meta::UniqueCPPtr<ccl::ops::Options> LoadOptionsGen2();
  ccl::meta::UniqueCPPtr<ccl::ops::TranslationData> LoadTranslationsGen2();

  void LoadThirdGen();
  void LoadPictGen3();
  ccl::meta::UniqueCPPtr<ccl::ops::Options> LoadOptionsGen3();
  ccl::meta::UniqueCPPtr<ccl::ops::TranslationData> LoadTranslationsGen3();

  void LoadDependencies();
};


} // namespace xtr::io