/*************************************************************************** * Copyright (C) 2005 by Nicolas PASCAL * * nicolas.pascal@icare.univ-lille1.fr * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ #ifndef PARASOLLEADER_H #define PARASOLLEADER_H #define PARASOLLEADER_TEST 0 #include "parasolfilereader.h" #include using namespace std; /** * manages the reading of a PARASOL leader file. * @warning this class is designed to be general and treat all PARASOL leader files BUT it only has been fully implemented and tested for * -> Level 2 products * -> only the records "leader file descriptor", "header" and "scaling factors" have been tested because of the developper proper needs (and time) * @author Nicolas PASCAL */ class PARASOLLeader : public PARASOLFileReader{ friend class PARASOLFileData; public: LeaderFileDescriptorRecord *leader_file_descriptor; protected: string filename; PARASOLLeaderFormat *leader_file_format; // record storage classes HeaderRecord *header; SpatioTemporalCharacteristicsRecord *spatio_temp_char; InstrumentSettingParametersRecord *instrument_setting_param; TechnologicalParametersRecord *techno_param; DataProcessingParametersRecord *data_processing_param; ScalingFactorsRecord *scaling_factors; AnnotationsRecord *annotations; /** * @brief access to the leader file format for a given product level * @return the leader file format */ virtual const PARASOLFileFormat* get_leader_file_format(){ return leader_file_format; }; /** * @brief check if a record has been read. * @return true if the record has already been read */ const bool is_record_loaded(const Record &rec); /** * @brief free the given record data * @param rec the record code */ void free_record(const Record &rec); /** * @brief Free all records */ void free_records(); /** * @brief Initialize a record class * @param rec the record code * @return the initialized object (or NULL in case of problem) */ PARASOLFileRecord* init_record(const Record &rec); /** * @brief access to ones record file offset * If the record isn't in the leader leader file, it returns -1 * @param rec the record code * @return the record's offset in the leader file */ const int get_record_offset(const Record &rec); /** * @brief access to the offset of an entry, relative to the record start * TODO example * @param rec the concerned record * @param entry_idx index of the entry, start at 0, record_number is index 0 * @param group_idx index of an entry that is repeated in a record. Ex : In the spatio-temporal characteristic of L1 products, the sequence number of the entry : the "line number of pixel at nadir for 670" * @param subgroup_index unused at this time. Should be useful for technological param that has seq_nb and im_nb imbricated * @param val_index unused * @return the offset, from the record start */ const int get_entry_offset( const Record rec, const int entry_idx, const int group_idx=-1, const int subgroup_index=-1, const int val_index=-1); /** * @brief access to the offset of an entry, relative to the record start * TODO example * @param rec the concerned record * @param entry_idx index of the entry, start at 0, record_number is index 0 * @param i_val indices of the value, for parametres repeated many times in a record * @return the offset, from the record start */ // const int get_entry_offset( const Record rec, const int entry_idx, const vector & i_val); /** * @brief returns the size (ni bytes) an a group that contains the given entry. If the entry is not repeated in a record, returns 0 * @throw bad_parametre_idx if the entry idx is invalid for the current product * @param rec the considered record * @param entry_idx index of the entry (product specific) * @return the size of the container group, in bytes. O if the entry is not in a group */ // const int get_entry_group_size(const Record rec, const int entry_idx); /** * @brief 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 * @throw bad_parametre_idx if the entry idx is invalid for the current product * @param entry_idx index of the entry (product specific) * @return the number of times the group is repeated */ // const int get_entry_group_nb_val(const Record rec, const int entry_idx) const; /** * @brief return the block describing the given entry : the number of times the entry is repeated and the size in bytes of the group * @param rec current record * @param entry_idx indice of the entry * @return the block(s) of the entry. If the entry is composed of a unique value, returns an empty vector */ vector get_entry_block (const Record rec, const int entry_idx) const; /** * @brief access to the RecordFormat object that describes the name, type, offset and length of each record entry * @param rec the record code * @return the RecordFormat corresponding to @a record code */ const RecordFormat* get_record_format(const Record &rec); /** * @brief access to one record entry * @param rec the record code * @return the entry corresponding to @a record code */ PARASOLFileRecord* get_record(const Record &rec); public: PARASOLLeader( const string leader_filename =""); virtual ~PARASOLLeader(); /** * @brief print out the leader file descriptor */ void print_leader_file_descriptor(); /** * @brief print out the spatio-temporal characteristics set in the leader file */ void print_spatio_temp_char(); /** * @brief print out the header set in the leader file */ void print_header(); /** * @brief print out the instrument settings parameters set in the leader file */ void print_instr_setting_param(); /** * @brief print out the scaling factors set in the leader file */ void print_scaling_factors(); /** * @brief print out the technological parameters set in the leader file */ void print_techno_param(); }; #endif