• Main Page
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

/home/pascal/depot/filedata/src/parasolfilereader.h

00001 /***************************************************************************
00002  *   Copyright (C) 2005 by Nicolas PASCAL   *
00003  *   nicolas.pascal@icare.univ-lille1.fr   *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU General Public License as published by  *
00007  *   the Free Software Foundation; either version 2 of the License, or     *
00008  *   (at your option) any later version.                                   *
00009  *                                                                         *
00010  *   This program is distributed in the hope that it will be useful,       *
00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00013  *   GNU General Public License for more details.                          *
00014  *                                                                         *
00015  *   You should have received a copy of the GNU General Public License     *
00016  *   along with this program; if not, write to the                         *
00017  *   Free Software Foundation, Inc.,                                       *
00018  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
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     /* number of time the group is repeated */
00038     int ntime;
00039     /* size in bytes of the group */
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     // ***** methods that must implement the inherited class  ***** //
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 //     virtual const int get_entry_offset(const Record rec, const int entry_idx, const int record_idx=-1, const int entry_group_idx=-1, const int val_idx=-1)=0;
00129     virtual const int get_entry_offset(const Record rec, const int entry_idx, const vector <int>& i_val);
00136 //     virtual const int get_entry_group_nb_val(const Record rec, const int entry_idx) const =0;
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

Generated on Thu Feb 14 2013 17:59:03 for filedata.kdevelop by  doxygen 1.7.1