/* Hdf_vd.hpp */ #ifndef HDF_VD_HPP #define HDF_VD_HPP #include #include #include "hdf.h" #include "mfhdf.h" #include "Hdf_vd_field.hpp" class Hdf_vd { /** * The VD reference in the hdf terminology. In fact, the index of the VData in the sds/vdata list */ int32 ref; /** * the name of the VData */ std::string name; /** * the class of the VData */ std::string cls; /** * The interlace mode */ int32 interlace; /** * The number of records common to all fields */ int32 nb_record; /** * the informations for each VData fields */ vector fields; /** * The VData attributes */ vector attrs; void init_member(); void init_fields(const int32 &id, const char *field_name_list, const int32 & nb_field); void init_attributes(const int32 &id); public: /** * @brief Call by Hdf_file to construct itself * @param vd_id the id of the vdata * @param vd_ref the reference of the VData (ie the index in the sds/vdata list) * @param filename the hdf file's name */ Hdf_vd(const int32 &vd_id, const int32 &vd_ref, const char* filename); Hdf_vd(); Hdf_vd(const Hdf_vd &hdf_vd); ~Hdf_vd(); std::string get_name() const { return name; } int32 get_ref() const { return ref; } std::string get_cls() const { return cls; } int32 get_interlace() const { return interlace; } int32 get_nb_record() const { return nb_record; } int32 get_nb_field() const { return fields.size(); } int32 get_nb_attr() const { return attrs.size(); }; /** * @brief access an field using its name * @param field_name the field name * @return the field. * @throw bad_field_name if the field doesn't exists */ Hdf_vd_field get_field(const char *field_name) const; /** * @brief access an field using its index * @param field_idx the field index * @return the field. * @throw bad_field_index if the field doesn't exists */ Hdf_vd_field get_field(const int32 &field_idx) const; /** * @brief test the existence of the field * @param field_name the name of the field * @return true if the field has been found */ const bool has_field( const char * field_name ) const; /** * @brief access an attribute using its name * @param attr_name the attribute name * @return the attribute. * @throw bad_attribute_name if the attribute doesn't exists */ Hdf_attr get_attribute(const char *attr_name) const; /** * @brief access an attribute using its index * @param attr_idx the attribute index * @return the attribute. * @throw bad_attribute_index if the attribute doesn't exists */ Hdf_attr get_attribute(const int32 &attr_idx) const; /** * @brief test the existence of the attribute * @param attr_name the name of the attribute * @return true if the attribute has been found */ const bool has_attr( const char * attr_name ) const; /** * @brief read the value of an attribute * @param attr_name the name of the attribute * @param value the output value (must be allocated by the caller) * @param ival the index of the attribute value (for array attributes) */ void get_attr_value(const char *attr_name,void *value, int32 ival = 0) const; /** * @brief retrieve the index of an attribute using its name * @param attr_name the attribute name * @return the attribute index, or -1 if not found */ int32 get_attr_idx(const char* attr_name) const; /** * @brief retrieve the index of an field using its name * @param field_name the field name * @return the field index, or -1 if not found */ int32 get_field_idx(const char* field_name) const; Hdf_vd &operator= (const Hdf_vd &hdf_vd); std::string to_string() const; friend std::ostream &operator<< (std::ostream &stream, const Hdf_vd &hdf_vd); /** * @brief used by Hdf_file::read_data. * No test are done on parameters validity in this method. TODO Should be private and use a friend encapsulation */ Hdf_vd_field read_field_data( const int32 & file_id, const string &filename, const string &field_name, void* data, int32 start, int32 edges ); }; #endif