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