openMSX
HD.hh
Go to the documentation of this file.
1 #ifndef HD_HH
2 #define HD_HH
3 
4 #include "Filename.hh"
6 #include "DiskContainer.hh"
7 #include "TigerTree.hh"
8 #include "serialize_meta.hh"
9 #include "openmsx.hh"
10 #include <string>
11 #include <memory>
12 
13 namespace openmsx {
14 
15 class MSXMotherBoard;
16 class HDCommand;
17 class File;
18 class DeviceConfig;
19 
20 class HD : public SectorAccessibleDisk, public DiskContainer
21  , public TTData
22 {
23 public:
24  explicit HD(const DeviceConfig& config);
25  virtual ~HD();
26 
27  const std::string& getName() const;
28  const Filename& getImageName() const;
29  void switchImage(const Filename& filename);
30 
31  std::string getTigerTreeHash();
32 
33  template<typename Archive>
34  void serialize(Archive& ar, unsigned version);
35 
36 private:
37  // SectorAccessibleDisk:
38  virtual void readSectorImpl(size_t sector, byte* buf);
39  virtual void writeSectorImpl(size_t sector, const byte* buf);
40  virtual size_t getNbSectorsImpl() const;
41  virtual bool isWriteProtectedImpl() const;
42  virtual Sha1Sum getSha1Sum();
43 
44  // Diskcontainer:
45  virtual SectorAccessibleDisk* getSectorAccessibleDisk();
46  virtual const std::string& getContainerName() const;
47  virtual bool diskChanged();
48  virtual int insertDisk(const std::string& filename);
49 
50  // TTData
51  virtual uint8_t* getData(size_t offset, size_t size);
52 
53  void openImage();
54 
55  MSXMotherBoard& motherBoard;
56  std::string name;
57  std::unique_ptr<HDCommand> hdCommand;
58  std::unique_ptr<TigerTree> tigerTree;
59 
60  std::unique_ptr<File> file;
61  Filename filename;
62  size_t filesize;
63  bool alreadyTried;
64 };
65 
66 REGISTER_BASE_CLASS(HD, "HD");
68 
69 } // namespace openmsx
70 
71 #endif