00001
00002
00003 #ifndef HDF_SDS_HPP
00004 #define HDF_SDS_HPP
00005
00006 #include <iostream>
00007 #include <string>
00008 #include "mfhdf.h"
00009 #include "Hdf_attr.hpp"
00010
00011 class Hdf_sds {
00012 int32 id;
00013 std::string name;
00014 int32 rank;
00015 int32 data_type;
00016 int32 nattrs;
00017 Hdf_attr *sds_attrs;
00018 int32 *dim_sizes;
00019
00020 public:
00021 typedef struct {
00022 char *sds_name;
00023 int32 sds_type;
00024 int32 sds_rank;
00025 int32 *sds_dimensions;
00026 float64 sds_cal;
00027 float64 sds_cal_err;
00028 float64 sds_offset;
00029 float64 sds_offset_err;
00030 int32 sds_nattrs;
00031 int32 *sds_attributes;
00032 } sds_infos_type;
00033
00034 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);
00035 Hdf_sds();
00036 Hdf_sds(const Hdf_sds &hdf_sds);
00037 ~Hdf_sds();
00038 std::string get_name() const { return name; }
00039 int32 get_id() const { return id; }
00040 int32 get_rank() const { return rank; }
00041 int32 get_data_type() const { return data_type; }
00042 int32 get_nattrs() const { return nattrs; }
00043 int32 get_dimension(int n) const { return dim_sizes[n]; }
00044 void get_fill_value(void* fill_value);
00045 void set_fill_value(void* fill_value);
00046 void set_dimension(int n, int32 dimension) { dim_sizes[n] = dimension ; }
00047 void get_dimensions(int32 *dimensions) const;
00048 Hdf_attr get_attribute(const char *attr_name) const;
00049 void get_attributes(Hdf_attr *attributes) const;
00050 bool has_attr( const char * file_attr ) const;
00051 void read(void *sds_data, int32 *start = NULL, int32 *stride = NULL, int32 *edges = NULL) const;
00052 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;
00053 std::string list_of_dimensions() const;
00054 std::string list_of_attributes(const int32 chars_to_display = 80, const int32 numbers_to_display = 10) const;
00055 std::string to_string() const;
00056
00057 void get_calibration(float64 &cal, float64 &cal_error, float64 &offset, float64 &offset_err, int32 &data_type) const;
00064 void get_attr_value(const char *attr_name,void *value, int32 ival = 0) const;
00065
00066 Hdf_sds &operator= (const Hdf_sds &hdf_sds);
00067 friend std::ostream &operator<< (std::ostream &stream, const Hdf_sds &hdf_sds);
00068
00069 };
00070
00071 #endif