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           private:
00093                 hid_t file;
00094                 hid_t group;
00095                 hid_t accprop;
00096                 hid_t simple_space;
00097                 string filename;
00098                 IOMode rw_mode;
00099                 bool initialized;
00100                 
00101                 /* Erases any existing attributes from the image group
00102                  * prior to writing a new header. For a new image there
00103                  * won't be any, so this should be harmless. 
00104                  * 
00105                  * @param image_index 
00106                  * @return 0 for success*/
00107                 int erase_header(int image_index);
00108                 
00109                 /* Write an attribute with specified name to a given open object.
00110                  * The attribute is opened and closed. returns 0 on success 
00111                  * 
00112                  * @param loc Object (dataset, group, or named datatype) id for this attibute to be attached to
00113                  * @param name name for this attibute
00114                  * @param obj value for this attribute
00115                  * @return 0 on success */
00116                 int write_attr(hid_t loc, const char *name, EMObject obj);
00117                 
00118                 /* Read an already opened attribute and returns the results 
00119                  * as an EMObject. The attribute is not closed. 
00120                  * 
00121                  * @param attr Identifier of an attribute to read
00122                  * @return attribute value as an EMObject */
00123                 EMObject read_attr(hid_t attr);
00124         };
00125 }
00126 
00127 #endif
00128 
00129 #endif

Generated on Tue May 25 17:13:32 2010 for EMAN2 by  doxygen 1.4.7