Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

hdfio2.h

Go to the documentation of this file.
00001 
00005 /*
00006  * Author: Steven Ludtke, 04/10/2003 (sludtke@bcm.edu)
00007  * Copyright (c) 2000-2006 Baylor College of Medicine
00008  * 
00009  * This software is issued under a joint BSD/GNU license. You may use the
00010  * source code in this file under either license. However, note that the
00011  * complete EMAN2 and SPARX software packages have some GPL dependencies,
00012  * so you are responsible for compliance with the licenses of these packages
00013  * if you opt to use BSD licensing. The warranty disclaimer below holds
00014  * in either instance.
00015  * 
00016  * This complete copyright notice must be included in any revised version of the
00017  * source code. Additional authorship citations may be added, but existing
00018  * author citations must be preserved.
00019  * 
00020  * This program is free software; you can redistribute it and/or modify
00021  * it under the terms of the GNU General Public License as published by
00022  * the Free Software Foundation; either version 2 of the License, or
00023  * (at your option) any later version.
00024  * 
00025  * This program is distributed in the hope that it will be useful,
00026  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00027  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00028  * GNU General Public License for more details.
00029  * 
00030  * You should have received a copy of the GNU General Public License
00031  * along with this program; if not, write to the Free Software
00032  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
00033  * 
00034  * */
00035 
00036 #ifndef eman__hdfio2_h__
00037 #define eman__hdfio2_h__ 1
00038 
00039 #ifdef EM_HDF5
00040 
00041 #define H5_USE_16_API
00042 
00043 #include "imageio.h"
00044 
00045 #include <hdf5.h>
00046 #include <vector>
00047 
00048 using std::vector;
00049 
00050 namespace EMAN
00051 {
00064         class HdfIO2:public ImageIO
00065         {
00066           public:
00067                 explicit HdfIO2(const string & filename, IOMode rw_mode = READ_ONLY);
00068                 ~HdfIO2();
00069 
00070                 DEFINE_IMAGEIO_FUNC;
00071                 static bool is_valid(const void *first_block);
00072 
00073                 bool is_single_image_format() const
00074                 {
00075                         return false;
00076                 }
00077         
00078         /* If this version of init() returns -1, then we have an 
00079          * old-style HDF5 file 
00080          * 
00081          * @return 0 for new HDF5 file, -1 for old-style HDF5 file*/
00082                 int init_test();
00083                         
00084                 /* Return the number of images in this HDF file
00085                  * 
00086                  * @return the number of images in this file*/
00087                 int get_nimg();
00088 
00089                 int get_num_dataset();
00090                 vector < int >get_image_indices();
00091 
00092                 /* Write an attribute with specified name to a given open object.
00093                  * The attribute is opened and closed. returns 0 on success
00094                  *
00095                  * @param loc Object (dataset, group, or named datatype) id for this attibute to be attached to
00096                  * @param name name for this attibute
00097                  * @param obj value for this attribute
00098                  * @return 0 on success */
00099                 int write_attr(hid_t loc, const char *name, EMObject obj);
00100 
00101                 /* Read an already opened attribute and returns the results
00102                  * as an EMObject. The attribute is not closed.
00103                  *
00104                  * @param attr Identifier of an attribute to read
00105                  * @return attribute value as an EMObject */
00106                 EMObject read_attr(hid_t attr);
00107 
00110                 hid_t get_fileid() const {return file;}
00111 
00112           private:
00113                 hsize_t nx, ny, nz;
00114                 bool is_exist;  //boolean to tell if the image (group) already exist(to be overwrite)
00115 
00116                 hid_t file;
00117                 hid_t group;
00118                 hid_t accprop;
00119                 hid_t simple_space;
00120                 string filename;
00121                 IOMode rw_mode;
00122                 bool initialized;
00123                 
00124                 Dict meta_attr_dict;    //this is used for the meta attributes stored in /MDF/images
00125 
00126                 /* Erases any existing attributes from the image group
00127                  * prior to writing a new header. For a new image there
00128                  * won't be any, so this should be harmless. 
00129                  * 
00130                  * @param image_index 
00131                  * @return 0 for success*/
00132                 int erase_header(int image_index);
00133 
00134         // render_min and render_max
00135             float rendermin;
00136             float rendermax;
00137         };
00138 }
00139 
00140 #endif
00141 
00142 #endif

Generated on Tue Jun 11 13:46:15 2013 for EMAN2 by  doxygen 1.3.9.1