1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-12-27 01:31:42 +00:00

Minor: made has_disk something that is decided on insertion/deletion.

This commit is contained in:
Thomas Harte 2017-08-20 10:55:08 -04:00
parent 2d9efccc98
commit 5344e3098b
2 changed files with 5 additions and 2 deletions

View File

@ -12,20 +12,22 @@
using namespace Storage::Disk; using namespace Storage::Disk;
Drive::Drive() Drive::Drive()
: head_position_(0), head_(0) {} : head_position_(0), head_(0), has_disk_(false) {}
void Drive::set_disk(const std::shared_ptr<Disk> &disk) { void Drive::set_disk(const std::shared_ptr<Disk> &disk) {
disk_ = disk; disk_ = disk;
track_ = nullptr; track_ = nullptr;
has_disk_ = !!disk_;
} }
void Drive::set_disk_with_track(const std::shared_ptr<Track> &track) { void Drive::set_disk_with_track(const std::shared_ptr<Track> &track) {
disk_ = nullptr; disk_ = nullptr;
track_ = track; track_ = track;
has_disk_ = !!track_;
} }
bool Drive::has_disk() { bool Drive::has_disk() {
return (bool)disk_ || (bool)track_; return has_disk_;
} }
bool Drive::get_is_track_zero() { bool Drive::get_is_track_zero() {

View File

@ -73,6 +73,7 @@ class Drive {
private: private:
std::shared_ptr<Track> track_; std::shared_ptr<Track> track_;
std::shared_ptr<Disk> disk_; std::shared_ptr<Disk> disk_;
bool has_disk_;
int head_position_; int head_position_;
unsigned int head_; unsigned int head_;
}; };