#include <parasolfilereader.h>
Public Member Functions | |
PARASOLFileReader (const string filename="") | |
Static Public Member Functions | |
static PARASOLProduct | get_product (const string &filename) |
access to the product using parsing the name | |
static void * | custom_new (void *buf, const int &nb_data, const PARASOLDataType &type) |
allocate a buffer to read data from a PARASOL data file. | |
static void * | inc_ptr (void *buf_start, const int &inc, const PARASOLDataType &type) |
find the element of a buffer at index inc, for buffer of type void*. It is a method equivalent to buf_start[inc] for void* typed buffer | |
Protected Member Functions | |
virtual void | read_record (const Record &record_code) |
read the whole data of a record | |
void | read_entry (void *record, const Record &record_code, int &entry_nb, RecordFormat::iterator &entry_format, const int &record_offset) |
read the values of an entry. | |
const size_t | read_value (void *val, const RecordFormat::iterator &val_format, const int &previous_value_offset) |
read ONE value in the PARASOL file | |
void | swap_endianess (void *val, const PARASOLDataType &type) |
swap the given value endianess. | |
virtual const bool | is_record_loaded (const Record &rec)=0 |
check if a record has been read. | |
virtual void | free_records ()=0 |
Free the objects used to store the values read in the file records. | |
virtual PARASOLFileRecord * | init_record (const Record &rec)=0 |
Initialize a record class. | |
virtual const int | get_record_offset (const Record &rec)=0 |
access to ones record file offset If the record isn't in the leader leader file, it returns -1 | |
virtual const int | get_entry_offset (const Record rec, const int entry_idx, const vector< int > &i_val) |
return the offset of a record entry, in record unit. It means that the first entry (ie the record number) has an entry_offset of 0 | |
virtual vector< EntryBlock > | get_entry_block (const Record rec, const int entry_idx) const =0 |
returns the number of times an entry group is repeated in the data record. If the entry is not repeated in a record, returns 1 | |
virtual const RecordFormat * | get_record_format (const Record &rec)=0 |
access to the RecordFormat object that describes the name, type, offset and length of each record entry | |
virtual PARASOLFileRecord * | get_record (const Record &rec)=0 |
access to one record entry | |
const bool | is_file_loaded () |
check if the file to read has been laded | |
void | open_file () |
void | close_file () |
Static Protected Member Functions | |
static void | fill_buffer_default (void *buf, const int &nb_val, const PARASOLDataType &type) |
fill a buffer used to read the file with fill values It uses a memset to do that | |
Protected Attributes | |
string | filename |
PARASOLProduct | product |
FILE * | fp |
Friends | |
class | PARASOLFileData |
This class contains the methods used to read the PARASOL that are common to the leader and the data files.
void * PARASOLFileReader::custom_new | ( | void * | buf, | |
const int & | nb_data, | |||
const PARASOLDataType & | type | |||
) | [static] |
allocate a buffer to read data from a PARASOL data file.
buf | the buffer to be allocated | |
nb_data | the buffer's length | |
type | the buffer's data type (using PARASOLDataType) |
void PARASOLFileReader::fill_buffer_default | ( | void * | buf, | |
const int & | nb_val, | |||
const PARASOLDataType & | type | |||
) | [static, protected] |
fill a buffer used to read the file with fill values It uses a memset to do that
buf | the buffer | |
nb_val | the number of values of the buffer | |
type | the data type |
References PARASOLFileFormat::get_size_of().
Referenced by PARASOLData::read_data().
virtual vector<EntryBlock> PARASOLFileReader::get_entry_block | ( | const Record | rec, | |
const int | entry_idx | |||
) | const [protected, pure virtual] |
returns the number of times an entry group is repeated in the data record. If the entry is not repeated in a record, returns 1
bad_parametre_idx | if the entry idx is invalid for the current product |
entry_idx | index of the entry (product specific) |
rec | current record | |
entry_idx | indice of the entry |
Implemented in PARASOLData, and PARASOLLeader.
Referenced by get_entry_offset(), and read_entry().
const int PARASOLFileReader::get_entry_offset | ( | const Record | rec, | |
const int | entry_idx, | |||
const vector< int > & | i_val | |||
) | [protected, virtual] |
return the offset of a record entry, in record unit. It means that the first entry (ie the record number) has an entry_offset of 0
record_idx | the record code | |
entry_idx | the index of the entry to find the offset, start at 0. The record number has an entry_index of 0 | |
entry_group_idx | (optional) for an entry that is in a repeated group, the index of the repetition. It is an abstraction, but for example, it is the index a direction for a directional parameter, starting at 0. | |
val_idx | (optional) an index to select a particular value |
rec | the concerned record | |
entry_idx | index of the entry, start at 0, record_number is index 0 | |
i_val | indices of the value, for parametres repeated many times in a record |
References get_entry_block(), and get_record_format().
Referenced by PARASOLData::read_data(), and read_entry().
PARASOLProduct PARASOLFileReader::get_product | ( | const string & | filename | ) | [static] |
access to the product using parsing the name
filename | the PARASOL file name (without the path) |
virtual PARASOLFileRecord* PARASOLFileReader::get_record | ( | const Record & | rec | ) | [protected, pure virtual] |
access to one record entry
rec | the record code |
Implemented in PARASOLData, and PARASOLLeader.
Referenced by read_record().
virtual const RecordFormat* PARASOLFileReader::get_record_format | ( | const Record & | rec | ) | [protected, pure virtual] |
access to the RecordFormat object that describes the name, type, offset and length of each record entry
rec | the record code |
Implemented in PARASOLData, and PARASOLLeader.
Referenced by get_entry_offset(), and read_record().
virtual const int PARASOLFileReader::get_record_offset | ( | const Record & | rec | ) | [protected, pure virtual] |
access to ones record file offset If the record isn't in the leader leader file, it returns -1
rec | the record code |
Implemented in PARASOLData, and PARASOLLeader.
Referenced by read_record().
void * PARASOLFileReader::inc_ptr | ( | void * | buf_start, | |
const int & | inc, | |||
const PARASOLDataType & | type | |||
) | [static] |
find the element of a buffer at index inc, for buffer of type void*. It is a method equivalent to buf_start[inc] for void* typed buffer
buf_start | the buffer start pointer | |
inc | the increment | |
type | the buffer's type code |
Referenced by PARASOLData::read_data().
virtual PARASOLFileRecord* PARASOLFileReader::init_record | ( | const Record & | rec | ) | [protected, pure virtual] |
Initialize a record class.
rec | the record code |
Implemented in PARASOLData, and PARASOLLeader.
Referenced by read_record().
const bool PARASOLFileReader::is_file_loaded | ( | ) | [inline, protected] |
check if the file to read has been laded
Referenced by PARASOLFileData::close_file(), PARASOLFileData::is_file_loaded(), PARASOLFileData::load_geolocation_data(), PARASOLData::read_data(), and read_record().
virtual const bool PARASOLFileReader::is_record_loaded | ( | const Record & | rec | ) | [protected, pure virtual] |
check if a record has been read.
Implemented in PARASOLData, and PARASOLLeader.
Referenced by read_record().
void PARASOLFileReader::read_entry | ( | void * | record, | |
const Record & | record_code, | |||
int & | entry_nb, | |||
RecordFormat::iterator & | entry_format, | |||
const int & | record_offset | |||
) | [protected] |
read the values of an entry.
entry | the variable where to put the read value(s) | |
entry_nb | the number of the entry. Updated by the method | |
record_code | the code of the current processed record | |
entry_format | the entry record format descriptor (a RecordFormat::iterator) Updated by the method | |
record_offset | the start offset of the read record. |
References get_entry_block(), get_entry_offset(), and read_value().
Referenced by read_record().
void PARASOLFileReader::read_record | ( | const Record & | record_code | ) | [protected, virtual] |
read the whole data of a record
record_code | code of the record to load |
References get_record(), get_record_format(), get_record_offset(), init_record(), is_file_loaded(), is_record_loaded(), and read_entry().
Referenced by PARASOLLeader::get_record_offset(), PARASOLData::get_record_offset(), and PARASOLFileData::load_viewing_directions_data().
const size_t PARASOLFileReader::read_value | ( | void * | val, | |
const RecordFormat::iterator & | val_format, | |||
const int & | previous_value_offset | |||
) | [protected] |
read ONE value in the PARASOL file
val | the variable where to put the read value | |
val_format | a RecordFormat element describing the value format | |
previous_value_offset | the file offset of the nearest preceeding value. |
References PARASOLFileFormat::get_size_of(), and swap_endianess().
Referenced by read_entry().
void PARASOLFileReader::swap_endianess | ( | void * | val, | |
const PARASOLDataType & | type | |||
) | [protected] |
swap the given value endianess.
val | the value to be swapped | |
type | the type code of this value |
Referenced by PARASOLData::read_data(), and read_value().