/* Hdf_sds.hpp */ #ifndef HDF_SDS_HPP #define HDF_SDS_HPP #include #include #include "mfhdf.h" #include "Hdf_attr.hpp" class Hdf_sds { int32 id; std::string name; int32 rank; int32 data_type; int32 nattrs; Hdf_attr *sds_attrs; int32 *dim_sizes; public: typedef struct { char *sds_name; int32 sds_type; int32 sds_rank; int32 *sds_dimensions; float64 sds_cal; float64 sds_cal_err; float64 sds_offset; float64 sds_offset_err; int32 sds_nattrs; int32 *sds_attributes; } sds_infos_type; Hdf_sds(const int32 sds_id, const char *sds_name, const int32 sds_rank, const int32 *sds_dim_sizes, const int32 sds_data_type, const int32 sds_nattrs); Hdf_sds(); Hdf_sds(const Hdf_sds &hdf_sds); ~Hdf_sds(); std::string get_name() const { return name; } int32 get_id() const { return id; } int32 get_rank() const { return rank; } int32 get_data_type() const { return data_type; } int32 get_nattrs() const { return nattrs; } int32 get_dimension(int n) const { return dim_sizes[n]; } void get_fill_value(void* fill_value); void set_fill_value(void* fill_value); void set_dimension(int n, int32 dimension) { dim_sizes[n] = dimension ; } void get_dimensions(int32 *dimensions) const; Hdf_attr get_attribute(const char *attr_name) const; void get_attributes(Hdf_attr *attributes) const; bool has_attr( const char * file_attr ) const; void read(void *sds_data, int32 *start = NULL, int32 *stride = NULL, int32 *edges = NULL) const; void write(const void *sds_data, int32 *start, int32 *stride, int32 *edges, float64 cal = 0., float64 offset = 0., float64 cal_err = 0., float64 off_err = 0.) const; std::string list_of_dimensions() const; std::string list_of_attributes(const int32 chars_to_display = 80, const int32 numbers_to_display = 10) const; std::string to_string() const; void get_calibration(float64 &cal, float64 &cal_error, float64 &offset, float64 &offset_err, int32 &data_type) 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; Hdf_sds &operator= (const Hdf_sds &hdf_sds); friend std::ostream &operator<< (std::ostream &stream, const Hdf_sds &hdf_sds); }; #endif