00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef PARASOLFILEREADER_H
00021 #define PARASOLFILEREADER_H
00022
00023 #include "file_tools.h"
00024 #include "file_exceptions.h"
00025 #include "parasolfilerecord.h"
00026 #include "parasolfileformat.h"
00027
00028 #include <string>
00029 #include <iostream>
00030 using namespace std;
00031
00036 typedef struct EntryBlock {
00037
00038 int ntime;
00039
00040 int size;
00041 EntryBlock (int ntime = -1, int size = -1) : ntime(ntime), size(size) {};
00042 friend ostream &operator<< (std::ostream &stream, const EntryBlock &obj) {
00043 stream << "{ntime = " << obj.ntime << " ; size = " << obj.size << "}" ;
00044 return stream;
00045 }
00046 } EntryBlock;
00047
00052 class PARASOLFileReader{
00053 friend class PARASOLFileData;
00054 protected:
00055 string filename;
00056 PARASOLProduct product;
00057 FILE* fp;
00058
00063 virtual void read_record(const Record &record_code);
00072 void read_entry( void* record, const Record & record_code, int &entry_nb, RecordFormat::iterator & entry_format, const int & record_offset);
00073
00081 const size_t read_value(void* val, const RecordFormat::iterator &val_format, const int &previous_value_offset);
00087 void swap_endianess(void * val, const PARASOLDataType &type);
00088
00089
00094 virtual const bool is_record_loaded(const Record &rec)=0;
00098 virtual void free_records()=0;
00104 virtual PARASOLFileRecord* init_record(const Record &rec)=0;
00111 virtual const int get_record_offset(const Record &rec)=0;
00120
00129 virtual const int get_entry_offset(const Record rec, const int entry_idx, const vector <int>& i_val);
00136
00143 virtual vector <EntryBlock> get_entry_block (const Record rec, const int entry_idx) const = 0;
00149 virtual const RecordFormat* get_record_format(const Record &rec)=0;
00155 virtual PARASOLFileRecord* get_record(const Record &rec)=0;
00160 const bool is_file_loaded(){
00161 return (fp!=NULL);
00162 };
00163 void open_file();
00164 void close_file();
00172 static void fill_buffer_default(void* buf,const int &nb_val,const PARASOLDataType &type);
00173 public:
00174 PARASOLFileReader(const string filename="");
00175 virtual ~PARASOLFileReader();
00176
00182 static PARASOLProduct get_product(const string &filename) ;
00191 static void* custom_new(void* buf, const int& nb_data, const PARASOLDataType &type);
00200 static void* inc_ptr(void* buf_start, const int& inc, const PARASOLDataType &type);
00201 };
00202
00203 #endif