1
0
mirror of https://github.com/TomHarte/CLK.git synced 2025-02-05 21:32:55 +00:00

Fix through route to TargetPlatform::TypeDistinguisher.

This commit is contained in:
Thomas Harte 2021-12-25 17:06:12 -05:00
parent 4d9589af7c
commit 6c606b5506

View File

@ -14,6 +14,7 @@
#include "../Disk.hpp" #include "../Disk.hpp"
#include "../Track/Track.hpp" #include "../Track/Track.hpp"
#include "../../TargetPlatforms.hpp"
namespace Storage { namespace Storage {
namespace Disk { namespace Disk {
@ -86,8 +87,11 @@ class DiskImageHolderBase: public Disk {
Provides a wrapper that wraps a DiskImage to make it into a Disk, providing caching and, Provides a wrapper that wraps a DiskImage to make it into a Disk, providing caching and,
thereby, an intermediate store for modified tracks so that mutable disk images can either thereby, an intermediate store for modified tracks so that mutable disk images can either
update on the fly or perform a block update on closure, as appropriate. update on the fly or perform a block update on closure, as appropriate.
Implements TargetPlatform::TypeDistinguisher to return either no information whatsoever, if
the underlying image doesn't implement TypeDistinguisher, or else to pass the call along.
*/ */
template <typename T> class DiskImageHolder: public DiskImageHolderBase { template <typename T> class DiskImageHolder: public DiskImageHolderBase, public TargetPlatform::TypeDistinguisher {
public: public:
template <typename... Ts> DiskImageHolder(Ts&&... args) : template <typename... Ts> DiskImageHolder(Ts&&... args) :
disk_image_(args...) {} disk_image_(args...) {}
@ -103,6 +107,14 @@ template <typename T> class DiskImageHolder: public DiskImageHolderBase {
private: private:
T disk_image_; T disk_image_;
TargetPlatform::Type target_platform_type() final {
if constexpr (std::is_base_of<TargetPlatform::TypeDistinguisher, T>::value) {
return static_cast<TargetPlatform::TypeDistinguisher *>(&disk_image_)->target_platform_type();
} else {
return TargetPlatform::Type(~0);
}
}
}; };
#include "DiskImageImplementation.hpp" #include "DiskImageImplementation.hpp"