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

serio.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__serio_h__
00037 #define eman__serio_h__ 1
00038 
00039 #include "imageio.h"
00040 
00041 namespace EMAN
00042 {
00053         class SerIO : public ImageIO
00054         {
00055         public:
00056                 explicit SerIO(const string & filename, IOMode rw_mode = READ_ONLY);
00057                 ~SerIO();
00058 
00059                 DEFINE_IMAGEIO_FUNC;
00060                 static bool is_valid(const void *first_block);
00061                 int get_nimg();
00062 
00063         private:
00064                 enum SerImgMode {
00065                         oneD = 0x4120,
00066                         twoD = 0x4122
00067                 };
00068 
00069                 enum SerTagType {
00070                         timeOnly = 0x4152,
00071                         posTime  = 0x4122
00072                 };
00073 
00074                 enum SerDataMode {
00075                         SER_UCHAR = 1,
00076                         SER_USHORT,
00077                         SER_UINT,
00078                         SER_CHAR,
00079                         SER_SHORT,
00080                         SER_INT,
00081                         SER_FLOAT,
00082                         SER_DOUBLE,
00083                         SER_COMPLEX8,
00084                         SER_COMPLEX16,
00085                         UNKNOWN
00086                 };
00087 
00088                 //This header struct has an alignment issue. It's size is 32 instead of 30.
00089                 //So we need read the item one by one.
00090                 struct SerHeader {
00091                         short   ByteOrder;
00092                         short   SeriesID;
00093                         short   SeriesVersion;
00094                         int             DataTypeID;
00095                         int             TagTypeID;
00096                         int     TotalNumberElements;
00097                         int             ValidNumberElements;
00098                         int             OffsetArrayOffset;
00099                         int             NumberDimensions;
00100                 };
00101 
00102                 string  filename;
00103                 IOMode  rw_mode;
00104                 FILE *  serfile;
00105                 bool    initialized;
00106                 bool    is_new_file;
00107 
00108                 SerHeader serh;
00109 
00110                 int * data_offset_array;
00111                 int * tag_offset_array;
00112                 int nimg;       //total image number in this file
00113                 int nx;
00114                 int ny;
00115                 int nz;
00116                 int datatypeid; //1D or 2D image
00117                 int datamode;   //data value mode (int, float, etc.)
00118 
00120                 void read_dim_arr(Dict & dict, int idx);
00121 
00123                 void read_data_element(Dict & dict);
00124 
00126                 void read_data_tag(Dict & dict);
00127         };
00128 
00129 }
00130 
00131 #endif  //eman__serio_h__

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