EMAN2
Classes | Public Member Functions | Static Public Member Functions | Public Attributes | Private Types | Private Member Functions | Private Attributes
EMAN::Gatan2IO Class Reference

Gatan2 Image file = header + data. More...

#include <gatan2io.h>

Inheritance diagram for EMAN::Gatan2IO:
Inheritance graph
[legend]
Collaboration diagram for EMAN::Gatan2IO:
Collaboration graph
[legend]

List of all members.

Classes

struct  Gatan2Header

Public Member Functions

 Gatan2IO (const string &filename, IOMode rw_mode=READ_ONLY)
 ~Gatan2IO ()

Static Public Member Functions

static bool is_valid (const void *first_block)

Public Attributes

 DEFINE_IMAGEIO_FUNC

Private Types

enum  DataType {
  GATAN2_SHORT = 1, GATAN2_FLOAT = 2, GATAN2_COMPLEX = 3, GATAN2_PACKED_COMPLEX = 5,
  GATAN2_CHAR = 6, GATAN2_INT = 7, GATAN2_INVALID
}

Private Member Functions

int to_em_datatype (int gatan_type)

Private Attributes

string filename
IOMode rw_mode
FILE * gatan2_file
Gatan2Header gatanh
bool is_big_endian
bool initialized

Detailed Description

Gatan2 Image file = header + data.

header is defined in Gatan2Header. data is nx by ny. A Gatan2 file contains 1 2D image.

Definition at line 49 of file gatan2io.h.


Member Enumeration Documentation

enum EMAN::Gatan2IO::DataType [private]
Enumerator:
GATAN2_SHORT 
GATAN2_FLOAT 
GATAN2_COMPLEX 
GATAN2_PACKED_COMPLEX 
GATAN2_CHAR 
GATAN2_INT 
GATAN2_INVALID 

Definition at line 58 of file gatan2io.h.


Constructor & Destructor Documentation

Gatan2IO::Gatan2IO ( const string &  filename,
IOMode  rw_mode = READ_ONLY 
) [explicit]

Definition at line 43 of file gatan2io.cpp.

References gatanh, is_big_endian, and EMAN::ByteOrder::is_host_big_endian().

:       filename(file), rw_mode(rw), gatan2_file(0), initialized(false)
{
        is_big_endian = ByteOrder::is_host_big_endian();
        memset(&gatanh, 0, sizeof(Gatan2Header));
}
Gatan2IO::~Gatan2IO ( )

Definition at line 50 of file gatan2io.cpp.

References gatan2_file.

{
        if (gatan2_file) {
                fclose(gatan2_file);
                gatan2_file = 0;
        }
}

Member Function Documentation

bool Gatan2IO::is_valid ( const void *  first_block) [static]

Definition at line 86 of file gatan2io.cpp.

References data, ENTERFUNC, EXITFUNC, GATAN2_INVALID, EMAN::ByteOrder::is_data_big_endian(), EMAN::ByteOrder::is_host_big_endian(), and EMAN::ByteOrder::swap_bytes().

Referenced by EMAN::EMUtil::fast_get_image_type(), and EMAN::EMUtil::get_image_type().

{
        ENTERFUNC;
        bool result = false;
        
        if (!first_block) {
                result = false;
        }
        else {
                const short *data = static_cast < const short *>(first_block);
                short len = data[5];
                short type = data[6];

                bool data_big_endian = ByteOrder::is_data_big_endian(&len);

                if (data_big_endian != ByteOrder::is_host_big_endian()) {
                        ByteOrder::swap_bytes(&len);
                        ByteOrder::swap_bytes(&type);
                }

                int double_size = sizeof(double);
                if (len > 0 && len <= double_size && type > 0 && type <= GATAN2_INVALID) {
                        result = true;
                }
        }
        EXITFUNC;
        return result;
}
int Gatan2IO::to_em_datatype ( int  gatan_type) [private]

Member Data Documentation

Definition at line 55 of file gatan2io.h.

string EMAN::Gatan2IO::filename [private]

Definition at line 83 of file gatan2io.h.

FILE* EMAN::Gatan2IO::gatan2_file [private]

Definition at line 85 of file gatan2io.h.

Referenced by ~Gatan2IO().

Definition at line 86 of file gatan2io.h.

Referenced by Gatan2IO().

Definition at line 89 of file gatan2io.h.

Definition at line 88 of file gatan2io.h.

Referenced by Gatan2IO().

Definition at line 84 of file gatan2io.h.


The documentation for this class was generated from the following files: