openMSX
HD.hh
Go to the documentation of this file.
1#ifndef HD_HH
2#define HD_HH
3
4#include "DiskContainer.hh"
5#include "File.hh"
6#include "Filename.hh"
7#include "HDCommand.hh"
9#include "MSXMotherBoard.hh"
10#include "TigerTree.hh"
11#include "serialize_meta.hh"
12#include <bitset>
13#include <string>
14#include <optional>
15
16namespace openmsx {
17
18class DeviceConfig;
19
21 , public TTData, public MediaInfoProvider
22{
23public:
24 explicit HD(const DeviceConfig& config);
25 ~HD() override;
26
27 [[nodiscard]] const std::string& getName() const { return name; }
28 [[nodiscard]] const Filename& getImageName() const { return filename; }
29 void switchImage(const Filename& filename);
30
31 [[nodiscard]] std::string getTigerTreeHash();
32
33 // MediaInfoProvider
34 void getMediaInfo(TclObject& result);
35
36 template<typename Archive>
37 void serialize(Archive& ar, unsigned version);
38
39 [[nodiscard]] MSXMotherBoard& getMotherBoard() const { return motherBoard; }
40
41private:
42 // SectorAccessibleDisk:
43 void readSectorsImpl(
44 SectorBuffer* buffers, size_t startSector, size_t num) override;
45 void writeSectorImpl(size_t sector, const SectorBuffer& buf) override;
46 [[nodiscard]] size_t getNbSectorsImpl() const override;
47 [[nodiscard]] bool isWriteProtectedImpl() const override;
48 [[nodiscard]] Sha1Sum getSha1SumImpl(FilePool& filePool) override;
49
50 // Diskcontainer:
51 [[nodiscard]] SectorAccessibleDisk* getSectorAccessibleDisk() override;
52 [[nodiscard]] std::string_view getContainerName() const override;
53 [[nodiscard]] bool diskChanged() override;
54 int insertDisk(const std::string& newFilename) override;
55
56 // TTData
57 [[nodiscard]] uint8_t* getData(size_t offset, size_t size) override;
58 [[nodiscard]] bool isCacheStillValid(time_t& time) override;
59
60 void showProgress(size_t position, size_t maxPosition);
61
62private:
63 MSXMotherBoard& motherBoard;
64 std::string name;
65 std::optional<HDCommand> hdCommand; // delayed init
66 std::optional<TigerTree> tigerTree; // delayed init
67
68 File file;
69 Filename filename;
70 size_t filesize;
71
72 static constexpr unsigned MAX_HD = 26;
73 using HDInUse = std::bitset<MAX_HD>;
74 std::shared_ptr<HDInUse> hdInUse;
75
76 uint64_t lastProgressTime;
77 bool everDidProgress;
78};
79
82
83} // namespace openmsx
84
85#endif
This class represents a filename.
Definition: Filename.hh:18
const Filename & getImageName() const
Definition: HD.hh:28
void switchImage(const Filename &filename)
Definition: HD.cc:89
~HD() override
Definition: HD.cc:73
HD(const DeviceConfig &config)
Definition: HD.cc:22
std::string getTigerTreeHash()
Definition: HD.cc:151
void getMediaInfo(TclObject &result)
This method gets called when information is required on the media inserted in the media slot of the p...
Definition: HD.cc:83
MSXMotherBoard & getMotherBoard() const
Definition: HD.hh:39
const std::string & getName() const
Definition: HD.hh:27
void serialize(Archive &ar, unsigned version)
Definition: HD.cc:214
This class represents the result of a sha1 calculation (a 160-bit value).
Definition: sha1.hh:22
The TigerTree class will query the to-be-hashed data via this abstract interface.
Definition: TigerTree.hh:44
This file implemented 3 utility functions:
Definition: Autofire.cc:9
SERIALIZE_CLASS_VERSION(CassettePlayer, 2)
REGISTER_BASE_CLASS(Connector, "Connector")
size_t size(std::string_view utf8)