From f44542c18c6d0d91814137baf7396e7b52ff6b93 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Sat, 26 Nov 2016 23:35:11 +0800 Subject: [PATCH] Improved naming: this now explains what, not the mechanics of how. --- Storage/Disk/Disk.cpp | 2 +- Storage/Disk/Disk.hpp | 16 +++++++++++----- Storage/Disk/Formats/AcornADF.cpp | 2 +- Storage/Disk/Formats/AcornADF.hpp | 2 +- Storage/Disk/Formats/D64.cpp | 2 +- Storage/Disk/Formats/D64.hpp | 2 +- Storage/Disk/Formats/G64.cpp | 2 +- Storage/Disk/Formats/G64.hpp | 2 +- Storage/Disk/Formats/OricMFMDSK.cpp | 2 +- Storage/Disk/Formats/OricMFMDSK.hpp | 2 +- Storage/Disk/Formats/SSD.cpp | 2 +- Storage/Disk/Formats/SSD.hpp | 2 +- 12 files changed, 22 insertions(+), 16 deletions(-) diff --git a/Storage/Disk/Disk.cpp b/Storage/Disk/Disk.cpp index aee00e39d..b2945ce3a 100644 --- a/Storage/Disk/Disk.cpp +++ b/Storage/Disk/Disk.cpp @@ -16,7 +16,7 @@ std::shared_ptr Disk::get_track_at_position(unsigned int head, unsigned i std::map>::iterator cached_track = cached_tracks_.find(address); if(cached_track != cached_tracks_.end()) return cached_track->second; - std::shared_ptr track = virtual_get_track_at_position(head, position); + std::shared_ptr track = get_uncached_track_at_position(head, position); cached_tracks_[address] = track; return track; } diff --git a/Storage/Disk/Disk.hpp b/Storage/Disk/Disk.hpp index 2f974c2fb..937e2767c 100644 --- a/Storage/Disk/Disk.hpp +++ b/Storage/Disk/Disk.hpp @@ -67,25 +67,31 @@ class Disk { public: /*! - Returns the number of discrete positions that this disk uses to model its complete surface area. + @returns the number of discrete positions that this disk uses to model its complete surface area. This is not necessarily a track count. There is no implicit guarantee that every position will - return a distinct track, or — if the media is holeless — will return any track at all. + return a distinct track, or — e.g. if the media is holeless — will return any track at all. */ virtual unsigned int get_head_position_count() = 0; /*! - Returns the number of heads (and, therefore, impliedly surfaces) available on this disk. + @returns the number of heads (and, therefore, impliedly surfaces) available on this disk. */ virtual unsigned int get_head_count() { return 1; } /*! - Returns the @c Track at @c position if there are any detectable events there; returns @c nullptr otherwise. + @returns the @c Track at @c position underneath @c head if there are any detectable events there; + returns @c nullptr otherwise. */ std::shared_ptr get_track_at_position(unsigned int head, unsigned int position); protected: - virtual std::shared_ptr virtual_get_track_at_position(unsigned int head, unsigned int position) = 0; + /*! + Subclasses should implement this to return the @c Track at @c position underneath @c head. Returned tracks + are cached internally so subclasses shouldn't attempt to build their own caches or worry about preparing + for track accesses at file load time. Appropriate behaviour is to create them lazily, on demand. + */ + virtual std::shared_ptr get_uncached_track_at_position(unsigned int head, unsigned int position) = 0; private: std::map> cached_tracks_; diff --git a/Storage/Disk/Formats/AcornADF.cpp b/Storage/Disk/Formats/AcornADF.cpp index b0ca1144a..5eb7d7dce 100644 --- a/Storage/Disk/Formats/AcornADF.cpp +++ b/Storage/Disk/Formats/AcornADF.cpp @@ -47,7 +47,7 @@ unsigned int AcornADF::get_head_count() return 1; } -std::shared_ptr AcornADF::virtual_get_track_at_position(unsigned int head, unsigned int position) +std::shared_ptr AcornADF::get_uncached_track_at_position(unsigned int head, unsigned int position) { std::shared_ptr track; diff --git a/Storage/Disk/Formats/AcornADF.hpp b/Storage/Disk/Formats/AcornADF.hpp index ccd2ea200..11109d5ea 100644 --- a/Storage/Disk/Formats/AcornADF.hpp +++ b/Storage/Disk/Formats/AcornADF.hpp @@ -36,7 +36,7 @@ class AcornADF: public Disk, public Storage::FileHolder { unsigned int get_head_position_count(); unsigned int get_head_count(); private: - std::shared_ptr virtual_get_track_at_position(unsigned int head, unsigned int position); + std::shared_ptr get_uncached_track_at_position(unsigned int head, unsigned int position); }; } diff --git a/Storage/Disk/Formats/D64.cpp b/Storage/Disk/Formats/D64.cpp index 75277d986..6c991bf89 100644 --- a/Storage/Disk/Formats/D64.cpp +++ b/Storage/Disk/Formats/D64.cpp @@ -41,7 +41,7 @@ unsigned int D64::get_head_position_count() return number_of_tracks_*2; } -std::shared_ptr D64::virtual_get_track_at_position(unsigned int head, unsigned int position) +std::shared_ptr D64::get_uncached_track_at_position(unsigned int head, unsigned int position) { // every other track is missing, as is any head above 0 if(position&1 || head) diff --git a/Storage/Disk/Formats/D64.hpp b/Storage/Disk/Formats/D64.hpp index afe0a16d8..6280331d9 100644 --- a/Storage/Disk/Formats/D64.hpp +++ b/Storage/Disk/Formats/D64.hpp @@ -36,7 +36,7 @@ class D64: public Disk, public Storage::FileHolder { unsigned int get_head_position_count(); private: - std::shared_ptr virtual_get_track_at_position(unsigned int head, unsigned int position); + std::shared_ptr get_uncached_track_at_position(unsigned int head, unsigned int position); unsigned int number_of_tracks_; uint16_t disk_id_; }; diff --git a/Storage/Disk/Formats/G64.cpp b/Storage/Disk/Formats/G64.cpp index ddc3bf791..68aeb4ed9 100644 --- a/Storage/Disk/Formats/G64.cpp +++ b/Storage/Disk/Formats/G64.cpp @@ -40,7 +40,7 @@ unsigned int G64::get_head_position_count() return number_of_tracks_ > 84 ? number_of_tracks_ : 84; } -std::shared_ptr G64::virtual_get_track_at_position(unsigned int head, unsigned int position) +std::shared_ptr G64::get_uncached_track_at_position(unsigned int head, unsigned int position) { std::shared_ptr resulting_track; diff --git a/Storage/Disk/Formats/G64.hpp b/Storage/Disk/Formats/G64.hpp index 34ec84c13..825851f19 100644 --- a/Storage/Disk/Formats/G64.hpp +++ b/Storage/Disk/Formats/G64.hpp @@ -39,7 +39,7 @@ class G64: public Disk, public Storage::FileHolder { unsigned int get_head_position_count(); private: - std::shared_ptr virtual_get_track_at_position(unsigned int head, unsigned int position); + std::shared_ptr get_uncached_track_at_position(unsigned int head, unsigned int position); uint8_t number_of_tracks_; uint16_t maximum_track_size_; }; diff --git a/Storage/Disk/Formats/OricMFMDSK.cpp b/Storage/Disk/Formats/OricMFMDSK.cpp index a581985da..7ab373bd7 100644 --- a/Storage/Disk/Formats/OricMFMDSK.cpp +++ b/Storage/Disk/Formats/OricMFMDSK.cpp @@ -36,7 +36,7 @@ unsigned int OricMFMDSK::get_head_count() return head_count_; } -std::shared_ptr OricMFMDSK::virtual_get_track_at_position(unsigned int head, unsigned int position) +std::shared_ptr OricMFMDSK::get_uncached_track_at_position(unsigned int head, unsigned int position) { long seek_offset = 0; switch(geometry_type_) diff --git a/Storage/Disk/Formats/OricMFMDSK.hpp b/Storage/Disk/Formats/OricMFMDSK.hpp index 1f02ba36d..f4d944a4b 100644 --- a/Storage/Disk/Formats/OricMFMDSK.hpp +++ b/Storage/Disk/Formats/OricMFMDSK.hpp @@ -37,7 +37,7 @@ class OricMFMDSK: public Disk, public Storage::FileHolder { unsigned int get_head_count(); private: - std::shared_ptr virtual_get_track_at_position(unsigned int head, unsigned int position); + std::shared_ptr get_uncached_track_at_position(unsigned int head, unsigned int position); uint32_t head_count_; uint32_t track_count_; uint32_t geometry_type_; diff --git a/Storage/Disk/Formats/SSD.cpp b/Storage/Disk/Formats/SSD.cpp index 07ddf242e..af4661dc1 100644 --- a/Storage/Disk/Formats/SSD.cpp +++ b/Storage/Disk/Formats/SSD.cpp @@ -40,7 +40,7 @@ unsigned int SSD::get_head_count() return head_count_; } -std::shared_ptr SSD::virtual_get_track_at_position(unsigned int head, unsigned int position) +std::shared_ptr SSD::get_uncached_track_at_position(unsigned int head, unsigned int position) { std::shared_ptr track; diff --git a/Storage/Disk/Formats/SSD.hpp b/Storage/Disk/Formats/SSD.hpp index 7d8ccf0df..d75475370 100644 --- a/Storage/Disk/Formats/SSD.hpp +++ b/Storage/Disk/Formats/SSD.hpp @@ -37,7 +37,7 @@ class SSD: public Disk, public Storage::FileHolder { unsigned int get_head_count(); private: - std::shared_ptr virtual_get_track_at_position(unsigned int head, unsigned int position); + std::shared_ptr get_uncached_track_at_position(unsigned int head, unsigned int position); unsigned int head_count_; unsigned int track_count_; };