HD.hh 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. #ifndef HD_HH
  2. #define HD_HH
  3. #include "Filename.hh"
  4. #include "File.hh"
  5. #include "SectorAccessibleDisk.hh"
  6. #include "DiskContainer.hh"
  7. #include "TigerTree.hh"
  8. #include "serialize_meta.hh"
  9. #include <bitset>
  10. #include <string>
  11. #include <memory>
  12. namespace openmsx {
  13. class MSXMotherBoard;
  14. class HDCommand;
  15. class DeviceConfig;
  16. class HD : public SectorAccessibleDisk, public DiskContainer
  17. , public TTData
  18. {
  19. public:
  20. explicit HD(const DeviceConfig& config);
  21. ~HD() override;
  22. const std::string& getName() const { return name; }
  23. const Filename& getImageName() const { return filename; }
  24. void switchImage(const Filename& filename);
  25. std::string getTigerTreeHash();
  26. template<typename Archive>
  27. void serialize(Archive& ar, unsigned version);
  28. MSXMotherBoard& getMotherBoard() const { return motherBoard; }
  29. private:
  30. // SectorAccessibleDisk:
  31. void readSectorImpl (size_t sector, SectorBuffer& buf) override;
  32. void writeSectorImpl(size_t sector, const SectorBuffer& buf) override;
  33. size_t getNbSectorsImpl() const override;
  34. bool isWriteProtectedImpl() const override;
  35. Sha1Sum getSha1SumImpl(FilePool& filePool) override;
  36. // Diskcontainer:
  37. SectorAccessibleDisk* getSectorAccessibleDisk() override;
  38. const std::string& getContainerName() const override;
  39. bool diskChanged() override;
  40. int insertDisk(std::string_view newFilename) override;
  41. // TTData
  42. uint8_t* getData(size_t offset, size_t size) override;
  43. bool isCacheStillValid(time_t& time) override;
  44. void showProgress(size_t position, size_t maxPosition);
  45. MSXMotherBoard& motherBoard;
  46. std::string name;
  47. std::unique_ptr<HDCommand> hdCommand;
  48. std::unique_ptr<TigerTree> tigerTree;
  49. File file;
  50. Filename filename;
  51. size_t filesize;
  52. static constexpr unsigned MAX_HD = 26;
  53. using HDInUse = std::bitset<MAX_HD>;
  54. std::shared_ptr<HDInUse> hdInUse;
  55. uint64_t lastProgressTime;
  56. bool everDidProgress;
  57. };
  58. REGISTER_BASE_CLASS(HD, "HD");
  59. SERIALIZE_CLASS_VERSION(HD, 2);
  60. } // namespace openmsx
  61. #endif