97b26985 |
1 | #ifndef TAPE_BLOCK_H |
2 | #define TAPE_BLOCK_H |
3 | |
97b26985 |
4 | /*! |
0ec6e042 |
5 | *\brief Tape data block base class. |
97b26985 |
6 | * |
7 | * This class represents a Honeywell paper tape block. |
8 | * That may be some kind of data block or a end of tape mark. |
9 | */ |
10 | class tape_block{ |
11 | |
12 | public: // types |
13 | |
14 | /*! |
0ec6e042 |
15 | *\brief Initialisation state. |
97b26985 |
16 | */ |
17 | typedef enum { |
18 | TBS_OK, //!< Block successfully initialised |
19 | TBS_EOF_LEGAL, //!< Legal EOF while initialising |
20 | TBS_EOF_ILLEGAL, //!< Illegal EOF while initialising |
21 | TBS_CHECKSUM, //!< Checksum error |
22 | TBS_IOERR, //!< I/O-Error while reading |
23 | TBS_DEFAULT //!< Block not initialised. |
24 | } tb_state_t; |
25 | |
26 | /*! |
0ec6e042 |
27 | * Tape block types. |
97b26985 |
28 | */ |
29 | typedef enum { |
30 | TBT_DATA=0x10, //!< Data block |
31 | TBT_EOT, //!< End of tape block |
32 | TBT_DISCARD //!< Invalid block, check block_type |
33 | } tb_type_t; |
34 | |
97b26985 |
35 | public: // methods |
36 | |
0ec6e042 |
37 | static tape_block * |
38 | gen_from_fd(int fd, |
97b26985 |
39 | void(*input_start)(void *)=0, |
40 | void (*input_stop)(void *)=0, |
41 | void * start_stop_arg=0 |
42 | ); |
0ec6e042 |
43 | |
97b26985 |
44 | virtual ~tape_block(); |
97b26985 |
45 | tb_state_t get_state(); |
97b26985 |
46 | int get_raw_size(); |
97b26985 |
47 | unsigned char * get_raw_data(); |
97b26985 |
48 | virtual int get_type(); |
97b26985 |
49 | virtual int get_subtype(); |
50 | |
0ec6e042 |
51 | protected: // methods |
52 | tape_block(tape_block &); |
53 | |
54 | private: // methods |
55 | |
56 | |
97b26985 |
57 | private: // methods |
0ec6e042 |
58 | tape_block(); |
59 | tape_block (int fd_p, |
60 | void(*input_start)(void *)=0, |
61 | void (*input_stop)(void *)=0, |
62 | void * start_stop_arg=0 |
63 | ); |
97b26985 |
64 | int init_words(void); |
97b26985 |
65 | int test_checksum(); |
66 | |
67 | protected: // members |
0ec6e042 |
68 | int block_type; //!< Type of this block. |
69 | tb_state_t init_state; //!< Initialisation state. |
70 | int data_read; //!< Total data consumption during intialisation. |
71 | unsigned char * raw_data; //!< Raw block data in bytes. |
72 | int raw_size; //!< Size of the raw data. |
73 | unsigned short * word_data; //!< Data organized in machine words. |
74 | int word_size; //!< Size of the blocks in machine words. |
97b26985 |
75 | |
76 | }; // tape_block |
77 | |
78 | |
79 | #endif |