EMAN2
hdfio2.h
Go to the documentation of this file.
1/*
2 * Author: Steven Ludtke, 04/10/2003 (sludtke@bcm.edu)
3 * Copyright (c) 2000-2006 Baylor College of Medicine
4 *
5 * This software is issued under a joint BSD/GNU license. You may use the
6 * source code in this file under either license. However, note that the
7 * complete EMAN2 and SPARX software packages have some GPL dependencies,
8 * so you are responsible for compliance with the licenses of these packages
9 * if you opt to use BSD licensing. The warranty disclaimer below holds
10 * in either instance.
11 *
12 * This complete copyright notice must be included in any revised version of the
13 * source code. Additional authorship citations may be added, but existing
14 * author citations must be preserved.
15 *
16 * This program is free software; you can redistribute it and/or modify
17 * it under the terms of the GNU General Public License as published by
18 * the Free Software Foundation; either version 2 of the License, or
19 * (at your option) any later version.
20 *
21 * This program is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details.
25 *
26 * You should have received a copy of the GNU General Public License
27 * along with this program; if not, write to the Free Software
28 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29 *
30 * */
31
32#ifndef eman__hdfio2_h__
33#define eman__hdfio2_h__ 1
34
35#ifdef USE_HDF5
36
37#define H5_USE_16_API
38
39#include "imageio.h"
40
41#include <hdf5.h>
42#undef __STDINT_H
43#ifndef __STDC_LIMIT_MACROS
44 #define __STDC_LIMIT_MACROS 1
45#endif
46#ifndef __STDC_LIMIT_MACROS
47 #define __STDC_CONSTANT_MACROS 1
48#endif
49#include <vector>
50
51using std::vector;
52
53namespace EMAN
54{
67 class HdfIO2 : public ImageIO
68 {
69 public:
70 explicit HdfIO2(const string & fname, IOMode rw_mode = READ_ONLY);
71 ~HdfIO2();
72
74 static bool is_valid(const void *first_block);
75
76 bool is_single_image_format() const
77 {
78 return false;
79 }
80
81 /* If this version of init() returns -1, then we have an
82 * old-style HDF5 file
83 *
84 * @return 0 for new HDF5 file, -1 for old-style HDF5 file*/
85 int init_test();
86
87 /* Return the number of images in this HDF file
88 *
89 * @return the number of images in this file*/
90 int get_nimg();
91
92 int get_num_dataset();
93 vector < int >get_image_indices();
94
95 /* Write an attribute with specified name to a given open object.
96 * The attribute is opened and closed. returns 0 on success
97 *
98 * @param loc Object (dataset, group, or named datatype) id for this attibute to be attached to
99 * @param name name for this attibute
100 * @param obj value for this attribute
101 * @return 0 on success */
102 int write_attr(hid_t loc, const char *name, EMObject obj);
103
104 /* Read an already opened attribute and returns the results
105 * as an EMObject. The attribute is not closed.
106 *
107 * @param attr Identifier of an attribute to read
108 * @return attribute value as an EMObject */
109 static EMObject read_attr(hid_t attr);
110
111 // this one is only defined in classes that implement it
112 int read_data_8bit(unsigned char *data, int image_index = 0, const Region * area = 0, bool is_3d = false, float minval = 0.0f, float maxval = 0.0f);
113
116 hid_t get_fileid() const {return file;}
117
118 private:
119 hsize_t nx, ny, nz;
120 bool is_exist; //boolean to tell if the image (group) already exist(to be overwrite)
121
122 hid_t file;
123 hid_t group;
124 hid_t accprop;
125 hid_t simple_space;
126
127 Dict meta_attr_dict; //this is used for the meta attributes stored in /MDF/images
128
129 /* Erases any existing attributes from the image group
130 * prior to writing a new header. For a new image there
131 * won't be any, so this should be harmless.
132 *
133 * @param image_index
134 * @return 0 for success*/
135 int erase_header(int image_index);
136
137 // render_min and render_max
138 float rendermin;
139 float rendermax;
140 int renderbits;
141 int renderlevel; // compression level
142 };
143}
144
145#endif
146
147#endif
#define DEFINE_IMAGEIO_FUNC
DEFINE_IMAGEIO_FUNC declares the functions that needs to be implemented by any subclass of ImageIO.
Definition: imageio.h:361
E2Exception class.
Definition: aligner.h:40