EMAN2
Public Member Functions | Static Public Member Functions | Public Attributes | Private Attributes | List of all members
EMAN::XYZIO Class Reference

XYZIO is a sample Image IO class. More...

#include <io_template.h>

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

Public Member Functions

 XYZIO (const string &filename, IOMode rw_mode=READ_ONLY)
 
 ~XYZIO ()
 
int get_nimg ()
 Return the number of images in this image file. More...
 
- Public Member Functions inherited from EMAN::ImageIO
 ImageIO (const string &fname, IOMode rw)
 
virtual ~ImageIO ()
 
virtual int read_header (Dict &dict, int image_index=0, const Region *area=0, bool is_3d=false)=0
 Read the header from an image. More...
 
virtual int write_header (const Dict &dict, int image_index=0, const Region *area=0, EMUtil::EMDataType filestoragetype=EMUtil::EM_FLOAT, bool use_host_endian=true)=0
 Write a header to an image. More...
 
virtual int read_data (float *data, int image_index=0, const Region *area=0, bool is_3d=false)=0
 Read the data from an image. More...
 
virtual 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)
 Read the data from an image as an 8 bit array, regardless of format. More...
 
virtual int write_data (float *data, int image_index=0, const Region *area=0, EMUtil::EMDataType filestoragetype=EMUtil::EM_FLOAT, bool use_host_endian=true)=0
 Write data to an image. More...
 
virtual int read_ctf (Ctf &ctf, int image_index=0)
 Read CTF data from this image. More...
 
virtual void write_ctf (const Ctf &ctf, int image_index=0)
 Write CTF data to this image. More...
 
virtual void flush ()=0
 Flush the IO buffer. More...
 
virtual bool is_complex_mode ()=0
 Is this an complex image or not. More...
 
virtual bool is_image_big_endian ()=0
 Is this image in big endian or not. More...
 
virtual bool is_single_image_format () const
 Is this image format only storing 1 image or not. More...
 
template<class T >
void become_host_endian (T *data, size_t n=1)
 Convert data of this image into host endian format. More...
 
string get_filename () const
 

Static Public Member Functions

static bool is_valid (const void *first_block)
 

Public Attributes

 DEFINE_IMAGEIO_FUNC
 

Private Attributes

string filename
 
IOMode rw_mode
 
FILE * xyz_file
 
bool is_big_endian
 
bool initialized
 

Additional Inherited Members

- Public Types inherited from EMAN::ImageIO
enum  IOMode { READ_ONLY = 1 , READ_WRITE = 2 , WRITE_ONLY = 3 }
 
- Protected Member Functions inherited from EMAN::ImageIO
virtual void init ()=0
 Do some initialization before doing the read/write. More...
 
void check_read_access (int image_index)
 Validate 'image_index' in file reading. More...
 
void check_read_access (int image_index, const float *data)
 Validate 'image_index' and 'data' in file reading. More...
 
void check_write_access (IOMode rw_mode, int image_index, int max_nimg=0)
 Validate rw_mode and image_index in file writing. More...
 
void check_write_access (IOMode rw_mode, int image_index, int max_nimg, const float *data)
 Validate rw_mode, image_index, and data pointer in file writing. More...
 
void check_region (const Region *area, const FloatSize &max_size, bool is_new_file=false, bool inbounds_only=true)
 Validate image I/O region. More...
 
void check_region (const Region *area, const IntSize &max_size, bool is_new_file=false, bool inbounds_only=true)
 Validate image I/O region. More...
 
FILE * sfopen (const string &filename, IOMode mode, bool *is_new=0, bool overwrite=false)
 Run fopen safely. More...
 
- Protected Attributes inherited from EMAN::ImageIO
string filename
 
IOMode rw_mode
 
FILE * file = nullptr
 
bool initialized = false
 

Detailed Description

XYZIO is a sample Image IO class.

It defines all required API that you may need to implement.

Definition at line 43 of file io_template.h.

Constructor & Destructor Documentation

◆ XYZIO()

XYZIO::XYZIO ( const string &  filename,
IOMode  rw_mode = READ_ONLY 
)

Definition at line 37 of file io_template.cpp.

38: filename(file), rw_mode(rw), xyz_file(0), initialized(false)
39{
41}
static bool is_host_big_endian()
Definition: byteorder.cpp:40
FILE * file
Definition: imageio.h:354
bool initialized
Definition: io_template.h:59
bool is_big_endian
Definition: io_template.h:58
IOMode rw_mode
Definition: io_template.h:55
string filename
Definition: io_template.h:54
FILE * xyz_file
Definition: io_template.h:56

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

◆ ~XYZIO()

XYZIO::~XYZIO ( )

Definition at line 43 of file io_template.cpp.

44{
45 if (xyz_file) {
46 fclose(xyz_file);
47 xyz_file = 0;
48 }
49}

References xyz_file.

Member Function Documentation

◆ get_nimg()

int XYZIO::get_nimg ( )
virtual

Return the number of images in this image file.

Reimplemented from EMAN::ImageIO.

Definition at line 145 of file io_template.cpp.

146{
147 init();
148
149 return 1;
150}
virtual void init()=0
Do some initialization before doing the read/write.

References EMAN::ImageIO::init().

◆ is_valid()

bool XYZIO::is_valid ( const void *  first_block)
static

Definition at line 70 of file io_template.cpp.

71{
73 bool result = false;
74 if (!first_block) {
75 result = false;
76 }
77
78 // check image format validality here
79
81 return result;
82}
#define ENTERFUNC
Definition: log.h:48
#define EXITFUNC
Definition: log.h:49

References ENTERFUNC, and EXITFUNC.

Member Data Documentation

◆ DEFINE_IMAGEIO_FUNC

EMAN::XYZIO::DEFINE_IMAGEIO_FUNC

Definition at line 49 of file io_template.h.

◆ filename

string EMAN::XYZIO::filename
private

Definition at line 54 of file io_template.h.

◆ initialized

bool EMAN::XYZIO::initialized
private

Definition at line 59 of file io_template.h.

◆ is_big_endian

bool EMAN::XYZIO::is_big_endian
private

Definition at line 58 of file io_template.h.

Referenced by XYZIO().

◆ rw_mode

IOMode EMAN::XYZIO::rw_mode
private

Definition at line 55 of file io_template.h.

◆ xyz_file

FILE* EMAN::XYZIO::xyz_file
private

Definition at line 56 of file io_template.h.

Referenced by ~XYZIO().


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