1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-11-26 08:49:37 +00:00

Improved naming: this now explains what, not the mechanics of how.

This commit is contained in:
Thomas Harte 2016-11-26 23:35:11 +08:00
parent 2f459690d4
commit f44542c18c
12 changed files with 22 additions and 16 deletions

View File

@ -16,7 +16,7 @@ std::shared_ptr<Track> Disk::get_track_at_position(unsigned int head, unsigned i
std::map<int, std::shared_ptr<Track>>::iterator cached_track = cached_tracks_.find(address);
if(cached_track != cached_tracks_.end()) return cached_track->second;
std::shared_ptr<Track> track = virtual_get_track_at_position(head, position);
std::shared_ptr<Track> track = get_uncached_track_at_position(head, position);
cached_tracks_[address] = track;
return track;
}

View File

@ -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<Track> get_track_at_position(unsigned int head, unsigned int position);
protected:
virtual std::shared_ptr<Track> 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<Track> get_uncached_track_at_position(unsigned int head, unsigned int position) = 0;
private:
std::map<int, std::shared_ptr<Track>> cached_tracks_;

View File

@ -47,7 +47,7 @@ unsigned int AcornADF::get_head_count()
return 1;
}
std::shared_ptr<Track> AcornADF::virtual_get_track_at_position(unsigned int head, unsigned int position)
std::shared_ptr<Track> AcornADF::get_uncached_track_at_position(unsigned int head, unsigned int position)
{
std::shared_ptr<Track> track;

View File

@ -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<Track> virtual_get_track_at_position(unsigned int head, unsigned int position);
std::shared_ptr<Track> get_uncached_track_at_position(unsigned int head, unsigned int position);
};
}

View File

@ -41,7 +41,7 @@ unsigned int D64::get_head_position_count()
return number_of_tracks_*2;
}
std::shared_ptr<Track> D64::virtual_get_track_at_position(unsigned int head, unsigned int position)
std::shared_ptr<Track> 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)

View File

@ -36,7 +36,7 @@ class D64: public Disk, public Storage::FileHolder {
unsigned int get_head_position_count();
private:
std::shared_ptr<Track> virtual_get_track_at_position(unsigned int head, unsigned int position);
std::shared_ptr<Track> get_uncached_track_at_position(unsigned int head, unsigned int position);
unsigned int number_of_tracks_;
uint16_t disk_id_;
};

View File

@ -40,7 +40,7 @@ unsigned int G64::get_head_position_count()
return number_of_tracks_ > 84 ? number_of_tracks_ : 84;
}
std::shared_ptr<Track> G64::virtual_get_track_at_position(unsigned int head, unsigned int position)
std::shared_ptr<Track> G64::get_uncached_track_at_position(unsigned int head, unsigned int position)
{
std::shared_ptr<Track> resulting_track;

View File

@ -39,7 +39,7 @@ class G64: public Disk, public Storage::FileHolder {
unsigned int get_head_position_count();
private:
std::shared_ptr<Track> virtual_get_track_at_position(unsigned int head, unsigned int position);
std::shared_ptr<Track> get_uncached_track_at_position(unsigned int head, unsigned int position);
uint8_t number_of_tracks_;
uint16_t maximum_track_size_;
};

View File

@ -36,7 +36,7 @@ unsigned int OricMFMDSK::get_head_count()
return head_count_;
}
std::shared_ptr<Track> OricMFMDSK::virtual_get_track_at_position(unsigned int head, unsigned int position)
std::shared_ptr<Track> OricMFMDSK::get_uncached_track_at_position(unsigned int head, unsigned int position)
{
long seek_offset = 0;
switch(geometry_type_)

View File

@ -37,7 +37,7 @@ class OricMFMDSK: public Disk, public Storage::FileHolder {
unsigned int get_head_count();
private:
std::shared_ptr<Track> virtual_get_track_at_position(unsigned int head, unsigned int position);
std::shared_ptr<Track> get_uncached_track_at_position(unsigned int head, unsigned int position);
uint32_t head_count_;
uint32_t track_count_;
uint32_t geometry_type_;

View File

@ -40,7 +40,7 @@ unsigned int SSD::get_head_count()
return head_count_;
}
std::shared_ptr<Track> SSD::virtual_get_track_at_position(unsigned int head, unsigned int position)
std::shared_ptr<Track> SSD::get_uncached_track_at_position(unsigned int head, unsigned int position)
{
std::shared_ptr<Track> track;

View File

@ -37,7 +37,7 @@ class SSD: public Disk, public Storage::FileHolder {
unsigned int get_head_count();
private:
std::shared_ptr<Track> virtual_get_track_at_position(unsigned int head, unsigned int position);
std::shared_ptr<Track> get_uncached_track_at_position(unsigned int head, unsigned int position);
unsigned int head_count_;
unsigned int track_count_;
};