mirror of
https://github.com/TomHarte/CLK.git
synced 2025-08-08 14:25:05 +00:00
Add an ability to avoid track flushing when file formats have sub-track precision.
This commit is contained in:
@@ -61,6 +61,12 @@ class Disk {
|
|||||||
@returns whether the disk image is read only. Defaults to @c true if not overridden.
|
@returns whether the disk image is read only. Defaults to @c true if not overridden.
|
||||||
*/
|
*/
|
||||||
virtual bool get_is_read_only() = 0;
|
virtual bool get_is_read_only() = 0;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
@returns @c true if the tracks at the two addresses are different. @c false if they are the same track.
|
||||||
|
This can avoid some degree of work when disk images offer sub-head-position precision.
|
||||||
|
*/
|
||||||
|
virtual bool tracks_differ(Track::Address, Track::Address) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -67,6 +67,12 @@ class DiskImage {
|
|||||||
@returns whether the disk image is read only. Defaults to @c true if not overridden.
|
@returns whether the disk image is read only. Defaults to @c true if not overridden.
|
||||||
*/
|
*/
|
||||||
virtual bool get_is_read_only() { return true; }
|
virtual bool get_is_read_only() { return true; }
|
||||||
|
|
||||||
|
/*!
|
||||||
|
@returns @c true if the tracks at the two addresses are different. @c false if they are the same track.
|
||||||
|
This can avoid some degree of work when disk images offer sub-head-position precision.
|
||||||
|
*/
|
||||||
|
virtual bool tracks_differ(Track::Address lhs, Track::Address rhs) { return lhs == rhs; }
|
||||||
};
|
};
|
||||||
|
|
||||||
class DiskImageHolderBase: public Disk {
|
class DiskImageHolderBase: public Disk {
|
||||||
@@ -93,6 +99,7 @@ template <typename T> class DiskImageHolder: public DiskImageHolderBase {
|
|||||||
void set_track_at_position(Track::Address address, const std::shared_ptr<Track> &track);
|
void set_track_at_position(Track::Address address, const std::shared_ptr<Track> &track);
|
||||||
void flush_tracks();
|
void flush_tracks();
|
||||||
bool get_is_read_only();
|
bool get_is_read_only();
|
||||||
|
bool tracks_differ(Track::Address lhs, Track::Address rhs);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
T disk_image_;
|
T disk_image_;
|
||||||
|
@@ -58,3 +58,7 @@ template <typename T> std::shared_ptr<Track> DiskImageHolder<T>::get_track_at_po
|
|||||||
template <typename T> DiskImageHolder<T>::~DiskImageHolder() {
|
template <typename T> DiskImageHolder<T>::~DiskImageHolder() {
|
||||||
if(update_queue_) update_queue_->flush();
|
if(update_queue_) update_queue_->flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename T> bool DiskImageHolder<T>::tracks_differ(Track::Address lhs, Track::Address rhs) {
|
||||||
|
return disk_image_.tracks_differ(lhs, rhs);
|
||||||
|
}
|
||||||
|
@@ -84,6 +84,13 @@ class Track {
|
|||||||
int rhs_largest_position = rhs.position.as_largest();
|
int rhs_largest_position = rhs.position.as_largest();
|
||||||
return std::tie(head, largest_position) < std::tie(rhs.head, rhs_largest_position);
|
return std::tie(head, largest_position) < std::tie(rhs.head, rhs_largest_position);
|
||||||
}
|
}
|
||||||
|
constexpr bool operator == (const Address &rhs) const {
|
||||||
|
return head == rhs.head && position == rhs.position;
|
||||||
|
}
|
||||||
|
constexpr bool operator != (const Address &rhs) const {
|
||||||
|
return head != rhs.head || position != rhs.position;
|
||||||
|
}
|
||||||
|
|
||||||
constexpr Address(int head, HeadPosition position) : head(head), position(position) {}
|
constexpr Address(int head, HeadPosition position) : head(head), position(position) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -107,11 +114,11 @@ class Track {
|
|||||||
virtual Event get_next_event() = 0;
|
virtual Event get_next_event() = 0;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
Jumps to the event latest offset that is less than or equal to the input time.
|
Jumps to the start of the fist event that will occur after @c time_since_index_hole.
|
||||||
|
|
||||||
@returns the time jumped to.
|
@returns the time jumped to.
|
||||||
*/
|
*/
|
||||||
virtual Time seek_to(const Time &time_since_index_hole) = 0;
|
virtual float seek_to(float time_since_index_hole) = 0;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
The virtual copy constructor pattern; returns a copy of the Track.
|
The virtual copy constructor pattern; returns a copy of the Track.
|
||||||
|
Reference in New Issue
Block a user