00001 00014 #ifndef BIN_IO_HANDLER_HH 00015 #define BIN_IO_HANDLER_HH 00016 00017 #include <string> 00018 #include <cstdio> 00019 00020 #include "decoder_base.hh" 00021 00026 class bin_io_handler : public decoder_base { 00027 00028 public: 00029 00031 enum MODE{ 00032 READ, 00033 WRITE 00034 }; 00035 00037 enum STATUS{ 00038 INIT, 00039 OPENED, 00040 OPERATING, 00041 CLOSED 00042 }; 00043 00045 bin_io_handler(FORMAT::INPUT_FILE type=FORMAT::UNDEFINED); 00046 00048 ~bin_io_handler(){}; 00049 00051 bool write_word(const PMT::word_t word); 00052 00054 bool write_multi_word(const PMT::word_t *words, const size_t entries); 00055 00057 PMT::word_t read_word(); 00058 00060 void set_format(FORMAT::INPUT_FILE f) {_format=f;}; 00061 00063 void set_mode(MODE mode) {_mode=mode;}; 00064 00066 void set_filename(std::string name) {_filename=name;}; 00067 00069 bool eof() const {return _eof;}; 00070 00072 bool open(); 00073 00075 bool is_open() const; 00076 00078 void close(); 00079 00081 void reset(); 00082 00083 PMT::word_t read_multi_word(size_t length=0); 00084 00085 private: 00086 00087 std::string _filename; 00088 00089 bool _eof; 00090 UShort_t _nwords_in_file; 00091 UInt_t _checksum; 00092 size_t _file_suffix; 00093 00094 PMT::word_t _single_word[1]; 00095 PMT::word_t _word; 00096 PMT::word_t _nchars; 00097 FORMAT::INPUT_FILE _format; 00098 STATUS _status; 00099 MODE _mode; 00100 FILE* _handler; 00101 00102 00103 std::vector<PMT::word_t> _read_word_buffer; 00104 size_t _multi_word_index; 00105 }; 00106 00107 #endif 00108 // end of doxygen group
1.4.7