yadro-task/include/tape.h
erius e16a1a6f6e Integrated clang-tidy into cmake
Enabled warnings as errors when building project target
Changed checks for clang-tidy
Changed indentation from 2 spaces to 4 in clang-format
Added pre-commit hook to apply clang-format formatting to the source tree
2024-10-23 14:41:12 +03:00

60 lines
1.5 KiB
C++

#ifndef TAPE_H
#define TAPE_H
#include <cstdint>
namespace tape {
/**
* Abstract class representing a magnetic tape.
*
* Tape is a storage medium consisting of N cells, where each cell contains a
* 32-bit signed integer. Data can be read or written into one cell at a time.
* 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.
*/
class Tape {
public:
Tape(const Tape &) = default;
Tape(Tape &&) = default;
Tape &operator=(const Tape &) = default;
Tape &operator=(Tape &&) = default;
Tape() = default;
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.
*/
virtual int32_t read() = 0;
/**
* Writes data to the current cell.
*
* @param data Number, that should be written to the current cell.
*/
virtual void write(int32_t data) = 0;
};
} // namespace tape
#endif