2024-10-19 02:36:22 +00:00
|
|
|
#ifndef TAPE_H
|
|
|
|
#define TAPE_H
|
|
|
|
|
|
|
|
#include <cstdint>
|
|
|
|
|
2024-10-22 00:24:13 +00:00
|
|
|
namespace tape {
|
|
|
|
|
2024-10-19 02:36:22 +00:00
|
|
|
/**
|
2024-10-21 08:03:12 +00:00
|
|
|
* Abstract class representing a magnetic tape.
|
|
|
|
*
|
|
|
|
* Tape is a storage medium consisting of N cells, where each cell contains a
|
2024-10-25 03:56:52 +00:00
|
|
|
* 32-bit unsigned integer. Data can be read or written into one cell at a time.
|
2024-10-21 08:03:12 +00:00
|
|
|
* Tape can be moved one cell forward or backwards in order to change the
|
|
|
|
* targeted cell. Tape performs every operation sequentially. The amount of data
|
|
|
|
* stored on a single tape could exceed the amount of available RAM. Moving tape
|
|
|
|
* forward or backwards is a very time-consuming operation.
|
|
|
|
*/
|
2024-10-19 02:36:22 +00:00
|
|
|
class Tape {
|
2024-10-23 11:41:12 +00:00
|
|
|
public:
|
2024-10-26 01:23:11 +00:00
|
|
|
/**
|
|
|
|
* Compiler provided constructors and destructor definitions.
|
|
|
|
* Make move constructor and destructor default, copy construcotr delete,
|
|
|
|
* and allow destrucor to be overriden.
|
|
|
|
*/
|
2024-10-24 14:48:55 +00:00
|
|
|
Tape() = default;
|
2024-10-26 01:23:11 +00:00
|
|
|
Tape(const Tape &) = delete;
|
|
|
|
Tape(Tape &&) = default;
|
|
|
|
Tape &operator=(const Tape &) = delete;
|
|
|
|
Tape &operator=(Tape &&) = default;
|
2024-10-23 11:41:12 +00:00
|
|
|
virtual ~Tape() = default;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Advances the tape one cell forward.
|
|
|
|
*
|
|
|
|
* @return false if the next cell doesn't exist (reached end of tape),
|
|
|
|
* otherwise true.
|
|
|
|
*/
|
|
|
|
virtual bool seek_forward() = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Rewinds the tape one cell backwards.
|
|
|
|
*
|
|
|
|
* @return false if the previous cell doesn't exist (reached beginning of
|
|
|
|
* tape), otherwise true.
|
|
|
|
*/
|
|
|
|
virtual bool seek_backwards() = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Reads data from the current cell.
|
|
|
|
*
|
|
|
|
* @return number, that is stored on the current cell.
|
|
|
|
*/
|
2024-10-25 03:56:52 +00:00
|
|
|
virtual uint32_t read() = 0;
|
2024-10-23 11:41:12 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Writes data to the current cell.
|
|
|
|
*
|
|
|
|
* @param data Number, that should be written to the current cell.
|
|
|
|
*/
|
2024-10-25 03:56:52 +00:00
|
|
|
virtual void write(uint32_t data) = 0;
|
2024-10-19 02:36:22 +00:00
|
|
|
};
|
|
|
|
|
2024-10-22 00:24:13 +00:00
|
|
|
} // namespace tape
|
|
|
|
|
2024-10-19 02:36:22 +00:00
|
|
|
#endif
|