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 <string>
10 #include <memory>
11 
12 namespace openmsx {
13 
14 class MSXMotherBoard;
15 class HDCommand;
16 class File;
17 class DeviceConfig;
18 
19 class HD : public SectorAccessibleDisk, public DiskContainer
20  , public TTData
21 {
22 public:
23  explicit HD(const DeviceConfig& config);
24  virtual ~HD();
25 
26  const std::string& getName() const { return name; }
27  const Filename& getImageName() const { return filename; }
28  void switchImage(const Filename& filename);
29 
30  std::string getTigerTreeHash();
31 
32  template<typename Archive>
33  void serialize(Archive& ar, unsigned version);
34 
35  MSXMotherBoard& getMotherBoard() const { return motherBoard; }
36 
37 private:
38  // SectorAccessibleDisk:
39  void readSectorImpl (size_t sector, SectorBuffer& buf) override;
40  void writeSectorImpl(size_t sector, const SectorBuffer& buf) override;
41  size_t getNbSectorsImpl() const override;
42  bool isWriteProtectedImpl() const override;
43  Sha1Sum getSha1Sum() override;
44 
45  // Diskcontainer:
46  SectorAccessibleDisk* getSectorAccessibleDisk() override;
47  const std::string& getContainerName() const override;
48  bool diskChanged() override;
49  int insertDisk(string_ref filename) override;
50 
51  // TTData
52  uint8_t* getData(size_t offset, size_t size) override;
53  bool isCacheStillValid(time_t& time) override;
54 
55  void openImage();
56 
57  MSXMotherBoard& motherBoard;
58  std::string name;
59  std::unique_ptr<HDCommand> hdCommand;
60  std::unique_ptr<TigerTree> tigerTree;
61 
62  std::unique_ptr<File> file;
63  Filename filename;
64  size_t filesize;
65  bool alreadyTried;
66 };
67 
68 REGISTER_BASE_CLASS(HD, "HD");
70 
71 } // namespace openmsx
72 
73 #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:26
const std::string & getName() const
Definition: HD.hh:26
virtual ~HD()
Definition: HD.cc:78
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
HD
Definition: HD.cc:306
void switchImage(const Filename &filename)
Definition: HD.cc:120
void serialize(Archive &ar, unsigned version)
Definition: HD.cc:232
size_t size() const
const Filename & getImageName() const
Definition: HD.hh:27
MSXMotherBoard & getMotherBoard() const
Definition: HD.hh:35
std::string getTigerTreeHash()
Definition: HD.cc:169