37 lines
764 B
C++
37 lines
764 B
C++
#ifndef DEVICE_H
|
|
#define DEVICE_H
|
|
#include <iostream>
|
|
#include <fstream>
|
|
using namespace std;
|
|
|
|
class Device {
|
|
public:
|
|
virtual bool test();
|
|
virtual unsigned char read();
|
|
virtual void write(unsigned char value);
|
|
virtual ~Device() = default;
|
|
};
|
|
|
|
class InputDevice : public Device {
|
|
istream* input;
|
|
public:
|
|
InputDevice(istream& in);
|
|
unsigned char read() override;
|
|
};
|
|
|
|
class OutputDevice : public Device {
|
|
ostream* output;
|
|
public:
|
|
OutputDevice(ostream& out);
|
|
void write(unsigned char value) override;
|
|
};
|
|
|
|
class FileDevice : public Device {
|
|
fstream file;
|
|
public:
|
|
FileDevice(string& filename);
|
|
bool test() override;
|
|
unsigned char read() override;
|
|
void write(unsigned char value) override;
|
|
};
|
|
#endif // DEVICE_H
|