32#ifndef eman__hdfio_h__
33#define eman__hdfio_h__ 1
58 class HdfIO :
public ImageIO
62 { INT, FLOAT, STRING };
65 explicit HdfIO(
const string & fname, IOMode rw_mode = READ_ONLY);
69 static bool is_valid(
const void *first_block);
71 int read_ctf(Ctf & ctf,
int image_index = 0);
72 void write_ctf(
const Ctf & ctf,
int image_index = 0);
74 int read_euler_angles(Dict & euler_angles,
int image_index = 0);
75 void write_euler_angles(
const Dict & euler_angles,
int image_index = 0);
77 int read_array_attr(
int image_index,
const string & attr_name,
void *value);
78 int write_array_attr(
int image_index,
const string & attr_name,
79 int nitems,
void *data, DataType type);
81 bool is_single_image_format()
const
89 int read_int_attr(
int image_index,
const string & attr_name);
90 float read_float_attr(
int image_index,
const string & attr_name);
91 string read_string_attr(
int image_index,
const string & attr_name);
92 int read_global_int_attr(
const string & attr_name);
93 float read_global_float_attr(
const string & attr_name);
95 int read_mapinfo_attr(
int image_index,
const string & attr_name);
97 int write_int_attr(
int image_index,
const string & attr_name,
int value);
98 int write_float_attr(
int image_index,
const string & attr_name,
float value);
99 int write_string_attr(
int image_index,
const string & attr_name,
100 const string & value);
102 int write_float_attr_from_dict(
int image_index,
const string & attr_name,
105 int write_global_int_attr(
const string & attr_name,
int value);
107 int write_mapinfo_attr(
int image_index,
const string & attr_name,
int value);
109 int delete_attr(
int image_index,
const string & attr_name);
111 int get_num_dataset();
112 vector < int >get_image_indices();
116 { ROOT_GROUP, CTFIT, NUMDATASET, COMPOUND_DATA_MAGIC, EULER };
118 void create_cur_dataset(
int image_index,
int nx,
int ny,
int nz);
120 int *read_dims(
int image_index,
int *p_ndim);
122 int read_compound_dict(Nametype compound_type,
123 Dict & values,
int image_index);
125 void write_compound_dict(Nametype compound_type,
126 const Dict & values,
int image_index);
129 static const char *HDF5_SIGNATURE;
139 herr_t(*old_func) (
void *);
140 void *old_client_data;
142 static hid_t mapinfo_type;
144 vector < int >image_indices;
149 int delete_attr(
const string & attr_name);
151 void set_dataset(
int image_index);
152 int create_compound_attr(
int image_index,
const string & attr_name);
153 void close_cur_dataset();
154 static string get_item_name(Nametype type);
155 void increase_num_dataset();
157 static void create_enum_types();
158 string get_compound_name(
int id,
const string & name);
160 float read_float_attr(
const string & attr_name);
161 int write_int_attr(
const string & attr_name,
int value);
162 int write_float_attr(
const string & attr_name,
float value);
164 int get_hdf_dims(
int image_index,
int *p_nx,
int *p_ny,
int *p_nz);
166 static herr_t file_info(hid_t loc_id,
const char *name,
void *opdata);
167 int create_region_space(hid_t * p_dataspace_id, hid_t * p_memspace_id,
168 const Region * area,
int nx,
int ny,
int nz,
#define DEFINE_IMAGEIO_FUNC
DEFINE_IMAGEIO_FUNC declares the functions that needs to be implemented by any subclass of ImageIO.