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 <bitset>
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 { return name; }
28  const Filename& getImageName() const { return filename; }
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  MSXMotherBoard& getMotherBoard() const { return motherBoard; }
37 
38 private:
39  // SectorAccessibleDisk:
40  void readSectorImpl (size_t sector, SectorBuffer& buf) override;
41  void writeSectorImpl(size_t sector, const SectorBuffer& buf) override;
42  size_t getNbSectorsImpl() const override;
43  bool isWriteProtectedImpl() const override;
44  Sha1Sum getSha1Sum() override;
45 
46  // Diskcontainer:
47  SectorAccessibleDisk* getSectorAccessibleDisk() override;
48  const std::string& getContainerName() const override;
49  bool diskChanged() override;
50  int insertDisk(string_ref filename) override;
51 
52  // TTData
53  uint8_t* getData(size_t offset, size_t size) override;
54  bool isCacheStillValid(time_t& time) override;
55 
56  void openImage();
57 
58  MSXMotherBoard& motherBoard;
59  std::string name;
60  std::unique_ptr<HDCommand> hdCommand;
61  std::unique_ptr<TigerTree> tigerTree;
62 
63  std::unique_ptr<File> file;
64  Filename filename;
65  size_t filesize;
66  bool alreadyTried;
67 
68  static const unsigned MAX_HD = 26;
69  typedef std::bitset<MAX_HD> HDInUse;
70  std::shared_ptr<HDInUse> hdInUse;
71 };
72 
73 REGISTER_BASE_CLASS(HD, "HD");
75 
76 } // namespace openmsx
77 
78 #endif
signed char offset
Definition: CPUCore.cc:252
The TigerTree class will query the to-be-hashed data via this abstract interface. ...
Definition: TigerTree.hh:42
HD(const DeviceConfig &config)
Definition: HD.cc:22
const std::string & getName() const
Definition: HD.hh:27
virtual ~HD()
Definition: HD.cc:68
This class implements a subset of the proposal for std::string_ref (proposed for the next c++ standar...
Definition: string_ref.hh:18
REGISTER_BASE_CLASS(Connector,"Connector")
This class represents the result of a sha1 calculation (a 160-bit value).
Definition: sha1.hh:19
SERIALIZE_CLASS_VERSION(CassettePlayer, 2)
This class represents a filename.
Definition: Filename.hh:17
Thanks to enen for testing this on a real cartridge:
Definition: Autofire.cc:7
HD
Definition: HD.cc:285
void switchImage(const Filename &filename)
Definition: HD.cc:99
void serialize(Archive &ar, unsigned version)
Definition: HD.cc:211
size_t size(string_ref utf8)
const Filename & getImageName() const
Definition: HD.hh:28
MSXMotherBoard & getMotherBoard() const
Definition: HD.hh:36
std::string getTigerTreeHash()
Definition: HD.cc:148