From 56dd677e9cdcd11586fa3a8c7f18dbe41b13c810 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Sun, 27 Aug 2017 15:19:03 -0400 Subject: [PATCH] Creates a virtual interface that can be adopted by classes that are able to provide some insight as to target machine. --- Storage/Tape/Formats/ZX80O81P.cpp | 6 ++++++ Storage/Tape/Formats/ZX80O81P.hpp | 9 +++++++-- Storage/TargetPlatforms.hpp | 5 +++++ 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/Storage/Tape/Formats/ZX80O81P.cpp b/Storage/Tape/Formats/ZX80O81P.cpp index 65e508019..82b33bcc1 100644 --- a/Storage/Tape/Formats/ZX80O81P.cpp +++ b/Storage/Tape/Formats/ZX80O81P.cpp @@ -20,9 +20,11 @@ ZX80O81P::ZX80O81P(const char *file_name) : // If it's a ZX81 file, prepend a file name. std::string type = extension(); + platform_type_ = TargetPlatform::ZX80; if(type == "p" || type == "81") { // TODO, maybe: prefix a proper file name; this is leaving the file nameless. data_.insert(data_.begin(), 0x80); + platform_type_ = TargetPlatform::ZX81; } std::shared_ptr<::Storage::Data::ZX8081::File> file = Storage::Data::ZX8081::FileFromData(data_); @@ -100,3 +102,7 @@ Tape::Pulse ZX80O81P::virtual_get_next_pulse() { return pulse; } + +TargetPlatform::Type ZX80O81P::target_platform_type() { + return platform_type_; +} diff --git a/Storage/Tape/Formats/ZX80O81P.hpp b/Storage/Tape/Formats/ZX80O81P.hpp index efc2a5425..ef161db03 100644 --- a/Storage/Tape/Formats/ZX80O81P.hpp +++ b/Storage/Tape/Formats/ZX80O81P.hpp @@ -11,6 +11,7 @@ #include "../Tape.hpp" #include "../../FileHolder.hpp" +#include "../../TargetPlatforms.hpp" #include #include @@ -21,7 +22,7 @@ namespace Tape { /*! Provides a @c Tape containing a ZX80-format .O tape image, which is a byte stream capture. */ -class ZX80O81P: public Tape, public Storage::FileHolder { +class ZX80O81P: public Tape, public Storage::FileHolder, public TargetPlatform::TypeDistinguisher { public: /*! Constructs a @c ZX80O containing content from the file with name @c file_name. @@ -34,10 +35,14 @@ class ZX80O81P: public Tape, public Storage::FileHolder { ErrorNotZX80O81P }; + private: // implemented to satisfy @c Tape bool is_at_end(); - private: + // implemented to satisfy TargetPlatform::TypeDistinguisher + TargetPlatform::Type target_platform_type(); + TargetPlatform::Type platform_type_; + void virtual_reset(); Pulse virtual_get_next_pulse(); bool has_finished_data(); diff --git a/Storage/TargetPlatforms.hpp b/Storage/TargetPlatforms.hpp index b1182741b..89f6bdb1c 100644 --- a/Storage/TargetPlatforms.hpp +++ b/Storage/TargetPlatforms.hpp @@ -26,6 +26,11 @@ enum Type: IntType { AllDisk = Acorn | AmstradCPC | Commodore | Oric, }; +class TypeDistinguisher { + public: + virtual Type target_platform_type() = 0; +}; + } #endif /* TargetPlatforms_h */