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 static constexpr unsigned MAX_HD = 26;
25 using HDInUse = std::bitset<MAX_HD>;
26 static std::shared_ptr<HDInUse> getDrivesInUse(MSXMotherBoard& motherBoard);
27
28public:
29 explicit HD(const DeviceConfig& config);
30 ~HD() override;
31
32 [[nodiscard]] const std::string& getName() const { return name; }
33 [[nodiscard]] const Filename& getImageName() const { return filename; }
34 void switchImage(const Filename& filename);
35
36 [[nodiscard]] std::string getTigerTreeHash();
37
38 // MediaInfoProvider
39 void getMediaInfo(TclObject& result) override;
40
41 template<typename Archive>
42 void serialize(Archive& ar, unsigned version);
43
44 [[nodiscard]] MSXMotherBoard& getMotherBoard() const { return motherBoard; }
45
46private:
47 // SectorAccessibleDisk:
48 void readSectorsImpl(
49 std::span<SectorBuffer> buffers, size_t startSector) override;
50 void writeSectorImpl(size_t sector, const SectorBuffer& buf) override;
51 [[nodiscard]] size_t getNbSectorsImpl() const override;
52 [[nodiscard]] bool isWriteProtectedImpl() const override;
53 [[nodiscard]] Sha1Sum getSha1SumImpl(FilePool& filePool) override;
54
55 // DiskContainer:
56 [[nodiscard]] SectorAccessibleDisk* getSectorAccessibleDisk() override;
57 [[nodiscard]] std::string_view getContainerName() const override;
58 [[nodiscard]] bool diskChanged() override;
59 int insertDisk(const std::string& newFilename) override;
60
61 // TTData
62 [[nodiscard]] uint8_t* getData(size_t offset, size_t size) override;
63 [[nodiscard]] bool isCacheStillValid(time_t& time) override;
64
65 void showProgress(size_t position, size_t maxPosition);
66
67private:
68 MSXMotherBoard& motherBoard;
69 std::string name;
70 std::optional<HDCommand> hdCommand; // delayed init
71 std::optional<TigerTree> tigerTree; // delayed init
72
73 File file;
74 Filename filename;
75 size_t filesize;
76
77 std::shared_ptr<HDInUse> hdInUse;
78
79 uint64_t lastProgressTime;
80 bool everDidProgress;
81};
82
85
86} // namespace openmsx
87
88#endif
This class represents a filename.
Definition Filename.hh:18
const Filename & getImageName() const
Definition HD.hh:33
static std::shared_ptr< HDInUse > getDrivesInUse(MSXMotherBoard &motherBoard)
Definition HD.cc:24
void switchImage(const Filename &filename)
Definition HD.cc:96
~HD() override
Definition HD.cc:80
std::string getTigerTreeHash()
Definition HD.cc:158
void getMediaInfo(TclObject &result) override
This method gets called when information is required on the media inserted in the media slot of the p...
Definition HD.cc:90
MSXMotherBoard & getMotherBoard() const
Definition HD.hh:44
std::bitset< MAX_HD > HDInUse
Definition HD.hh:25
const std::string & getName() const
Definition HD.hh:32
void serialize(Archive &ar, unsigned version)
Definition HD.cc:221
static constexpr unsigned MAX_HD
Definition HD.hh:24
This class represents the result of a sha1 calculation (a 160-bit value).
Definition sha1.hh:23
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
#define REGISTER_BASE_CLASS(CLASS, NAME)
#define SERIALIZE_CLASS_VERSION(CLASS, VERSION)