OXYGENHUB
◆ main openmsx / src / fdc / DiskPartition.hh
1.2 KiB · C++ · last changed chore(): initial commit 1 month ago source blame history raw
1
#ifndef DISKPARTITION_HH
2
#define DISKPARTITION_HH
3
4
#include "SectorBasedDisk.hh"
5
#include <memory>
6
7
namespace openmsx {
8
9
class DiskPartition final : public SectorBasedDisk
10
{
11
public:
12
	/** Return a partition (as a SectorBasedDisk) from another Disk.
13
	 * @param disk The whole disk.
14
	 * @param partition The partition number.
15
	 *        0 for the whole disk
16
	 *        >0 for a specific partition, this must be a valid partition.
17
	 * @param owned If specified it should be a shared_ptr to the Disk
18
	 *              object passed as first parameter. This DiskPartition
19
	 *              will then take (shared) ownership of that Disk.
20
	 */
21
	DiskPartition(SectorAccessibleDisk& disk, unsigned partition,
22
	              std::shared_ptr<SectorAccessibleDisk> owned = nullptr);
23
24
	DiskPartition(SectorAccessibleDisk& parent,
25
	              size_t start, size_t length);
26
27
private:
28
	void readSectorImpl (size_t sector,       SectorBuffer& buf) override;
29
	void writeSectorImpl(size_t sector, const SectorBuffer& buf) override;
30
	[[nodiscard]] bool isWriteProtectedImpl() const override;
31
32
private:
33
	SectorAccessibleDisk& parent;
34
	std::shared_ptr<SectorAccessibleDisk> owned;
35
	size_t start;
36
};
37
38
} // namespace openmsx
39
40
#endif