2016-09-26 01:24:16 +00:00
|
|
|
//
|
|
|
|
// Drive.hpp
|
|
|
|
// Clock Signal
|
|
|
|
//
|
|
|
|
// Created by Thomas Harte on 25/09/2016.
|
|
|
|
// Copyright © 2016 Thomas Harte. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
#ifndef Drive_hpp
|
|
|
|
#define Drive_hpp
|
|
|
|
|
|
|
|
#include <memory>
|
|
|
|
#include "Disk.hpp"
|
|
|
|
|
|
|
|
namespace Storage {
|
|
|
|
namespace Disk {
|
|
|
|
|
|
|
|
class Drive {
|
|
|
|
public:
|
|
|
|
Drive();
|
|
|
|
|
|
|
|
/*!
|
|
|
|
Inserts @c disk into the drive.
|
|
|
|
*/
|
|
|
|
void set_disk(std::shared_ptr<Disk> disk);
|
|
|
|
|
|
|
|
/*!
|
|
|
|
@returns @c true if a disk is currently inserted; @c false otherwise.
|
|
|
|
*/
|
|
|
|
bool has_disk();
|
|
|
|
|
|
|
|
/*!
|
|
|
|
@returns @c true if the drive head is currently at track zero; @c false otherwise.
|
|
|
|
*/
|
|
|
|
bool get_is_track_zero();
|
|
|
|
|
|
|
|
/*!
|
2016-12-25 03:37:20 +00:00
|
|
|
Steps the disk head the specified number of tracks. Positive numbers step inwards (i.e. away from track 0),
|
|
|
|
negative numbers step outwards (i.e. towards track 0).
|
2016-09-26 01:24:16 +00:00
|
|
|
*/
|
|
|
|
void step(int direction);
|
|
|
|
|
|
|
|
/*!
|
2016-12-25 03:37:20 +00:00
|
|
|
Sets the current read head.
|
2016-09-26 01:24:16 +00:00
|
|
|
*/
|
|
|
|
void set_head(unsigned int head);
|
|
|
|
|
2016-12-25 03:37:20 +00:00
|
|
|
/*!
|
|
|
|
@returns @c true if the inserted disk is read-only; @c false otherwise.
|
|
|
|
*/
|
2016-12-25 03:11:31 +00:00
|
|
|
bool get_is_read_only();
|
|
|
|
|
2016-12-25 03:37:20 +00:00
|
|
|
/*!
|
|
|
|
@returns the track underneath the current head at the location now stepped to.
|
|
|
|
*/
|
2016-09-26 01:24:16 +00:00
|
|
|
std::shared_ptr<Track> get_track();
|
2016-12-25 03:37:20 +00:00
|
|
|
|
|
|
|
/*!
|
|
|
|
Attempts to set @c track as the track underneath the current head at the location now stepped to.
|
|
|
|
*/
|
2016-12-25 03:11:31 +00:00
|
|
|
void set_track(const std::shared_ptr<Track> &track);
|
2016-09-26 01:24:16 +00:00
|
|
|
|
|
|
|
private:
|
2016-12-03 16:59:28 +00:00
|
|
|
std::shared_ptr<Disk> disk_;
|
|
|
|
int head_position_;
|
|
|
|
unsigned int head_;
|
2016-09-26 01:24:16 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* Drive_hpp */
|