EMAN2
Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes
EMAN::GatanDM4::TagTable Class Reference

#include <dm4io.h>

Collaboration diagram for EMAN::GatanDM4::TagTable:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 TagTable ()
 ~TagTable ()
void add (const string &name, const string &value)
void add_data (char *data)
string get_string (const string &name)
int get_int (const string &name)
float get_float (const string &name)
double get_double (const string &name)
int get_image_counted () const
int get_xsize () const
int get_ysize () const
int get_datatype () const
char * get_data () const
int get_num_images_found () const
void set_num_images_found (int num_found)
void dump () const
template<class T >
void become_host_endian (T *data, int n=1)
void set_endian (bool big_endian)

Private Member Functions

void set_thumb_index (int i)

Private Attributes

int img_counted
int img_index
int num_images_found
bool is_big_endian
std::map< string, string > tags
vector< int > x_list
vector< int > y_list
vector< int > datatype_list
vector< char * > data_list

Static Private Attributes

static const char * IMAGE_WIDTH_TAG = "Dimensions #0"
static const char * IMAGE_HEIGHT_TAG = "Dimensions #1"
static const char * IMAGE_NIMG_TAG = "Dimensions #2"
static const char * IMAGE_DATATYPE_TAG = "DataType"
static const char * IMAGE_THUMB_INDEX_TAG = "ImageIndex"

Detailed Description

Definition at line 45 of file dm4io.h.


Constructor & Destructor Documentation

TagTable::TagTable ( )

Definition at line 50 of file dm4io.cpp.

TagTable::~TagTable ( )

Definition at line 55 of file dm4io.cpp.

References data_list.

{
        for (unsigned int i = 0; i < data_list.size(); i++) {
                if (data_list[i]) {
                        delete[]data_list[i];
                        data_list[i] = 0;
                }
        }
}

Member Function Documentation

void TagTable::add ( const string &  name,
const string &  value 
)

Definition at line 65 of file dm4io.cpp.

References datatype_list, IMAGE_DATATYPE_TAG, IMAGE_HEIGHT_TAG, IMAGE_NIMG_TAG, IMAGE_THUMB_INDEX_TAG, IMAGE_WIDTH_TAG, img_counted, set_thumb_index(), tags, x_list, and y_list.

Referenced by EMAN::GatanDM4::TagData::read_any(), EMAN::GatanDM4::TagData::read_array_data(), and EMAN::GatanDM4::TagData::read_native().

{
        const char *value_str = value.c_str();

        if (name == IMAGE_WIDTH_TAG) {
                x_list.push_back(atoi(value_str));
        }
        else if (name == IMAGE_HEIGHT_TAG) {
                y_list.push_back(atoi(value_str));
        }
        else if (name == IMAGE_DATATYPE_TAG) {
                datatype_list.push_back(atoi(value_str));
        }
        else if (name == IMAGE_THUMB_INDEX_TAG) {
                set_thumb_index(atoi(value_str));
        }
        else if(name == IMAGE_NIMG_TAG){
                img_counted=atoi(value_str);
        }
        else {
                tags[name] = value;
        }
}
void TagTable::add_data ( char *  data)

Definition at line 89 of file dm4io.cpp.

References data_list, and NullPointerException.

Referenced by EMAN::GatanDM4::TagData::read_array_data().

{
        if (!data) {
                throw NullPointerException("DM4 data is NULL");
        }
        else {
                data_list.push_back(data);
        }
}
template<class T >
void EMAN::GatanDM4::TagTable::become_host_endian ( T *  data,
int  n = 1 
) [inline]
void TagTable::dump ( ) const

Definition at line 119 of file dm4io.cpp.

References tags.

{
        map < string, string >::const_iterator p;

        for (p = tags.begin(); p != tags.end(); p++) {
//              LOGDEBUG("  %s: %s", (*p).first.c_str(), (*p).second.c_str());
                printf("  %s: %s\n", (*p).first.c_str(), (*p).second.c_str());
        }
}
char * TagTable::get_data ( ) const

Definition at line 149 of file dm4io.cpp.

References data_list, and img_index.

{
        return data_list[img_index];
}
int TagTable::get_datatype ( ) const

Definition at line 144 of file dm4io.cpp.

References datatype_list, and img_index.

{
        return datatype_list[img_index];
}
double TagTable::get_double ( const string &  name)

Definition at line 114 of file dm4io.cpp.

References tags.

{
        return atof(tags[name].c_str());
}
float TagTable::get_float ( const string &  name)

Definition at line 109 of file dm4io.cpp.

References tags.

{
        return static_cast < float >(atof(tags[name].c_str()));
}
int TagTable::get_image_counted ( ) const

Definition at line 134 of file dm4io.cpp.

References img_counted.

Referenced by EMAN::DM4IO::get_nimg().

{
        return img_counted;
}
int TagTable::get_int ( const string &  name)

Definition at line 104 of file dm4io.cpp.

References tags.

{
        return atoi(tags[name].c_str());
}
int TagTable::get_num_images_found ( ) const

Definition at line 169 of file dm4io.cpp.

References num_images_found.

Referenced by EMAN::GatanDM4::TagData::read_array_data().

{
        return num_images_found;
}
string TagTable::get_string ( const string &  name)

Definition at line 99 of file dm4io.cpp.

References tags.

{
        return tags[name];
}
int TagTable::get_xsize ( ) const

Definition at line 129 of file dm4io.cpp.

References img_index, and x_list.

{
        return x_list[img_index];
}
int TagTable::get_ysize ( ) const

Definition at line 139 of file dm4io.cpp.

References img_index, and y_list.

{
        return y_list[img_index];
}
void EMAN::GatanDM4::TagTable::set_endian ( bool  big_endian) [inline]

Definition at line 75 of file dm4io.h.

References is_big_endian.

                        {
                                is_big_endian = big_endian;
                        }
void TagTable::set_num_images_found ( int  num_found)

Definition at line 174 of file dm4io.cpp.

References num_images_found.

Referenced by EMAN::GatanDM4::TagData::read_array_data().

{
        num_images_found = num_found;
}
void TagTable::set_thumb_index ( int  i) [private]

Definition at line 154 of file dm4io.cpp.

References img_index, and OutofRangeException.

Referenced by add().

{
        if (i != 0 && i != 1) {
                throw OutofRangeException(0, 1, i, "image index");
        }
        else {
                if (i == 0) {
                        img_index = 1;
                }
                else {
                        img_index = 0;
                }
        }
}

Member Data Documentation

vector< char *> EMAN::GatanDM4::TagTable::data_list [private]

Definition at line 97 of file dm4io.h.

Referenced by add_data(), get_data(), and ~TagTable().

vector< int > EMAN::GatanDM4::TagTable::datatype_list [private]

Definition at line 96 of file dm4io.h.

Referenced by add(), and get_datatype().

const char * TagTable::IMAGE_DATATYPE_TAG = "DataType" [static, private]

Definition at line 84 of file dm4io.h.

Referenced by add().

const char * TagTable::IMAGE_HEIGHT_TAG = "Dimensions #1" [static, private]

Definition at line 82 of file dm4io.h.

Referenced by add().

const char * TagTable::IMAGE_NIMG_TAG = "Dimensions #2" [static, private]

Definition at line 83 of file dm4io.h.

Referenced by add().

const char * TagTable::IMAGE_THUMB_INDEX_TAG = "ImageIndex" [static, private]

Definition at line 85 of file dm4io.h.

Referenced by add().

const char * TagTable::IMAGE_WIDTH_TAG = "Dimensions #0" [static, private]

Definition at line 81 of file dm4io.h.

Referenced by add().

Definition at line 89 of file dm4io.h.

Referenced by add(), and get_image_counted().

Definition at line 90 of file dm4io.h.

Referenced by get_data(), get_datatype(), get_xsize(), get_ysize(), and set_thumb_index().

Definition at line 92 of file dm4io.h.

Referenced by become_host_endian(), and set_endian().

Definition at line 91 of file dm4io.h.

Referenced by get_num_images_found(), and set_num_images_found().

std::map< string, string > EMAN::GatanDM4::TagTable::tags [private]

Definition at line 93 of file dm4io.h.

Referenced by add(), dump(), get_double(), get_float(), get_int(), and get_string().

vector< int > EMAN::GatanDM4::TagTable::x_list [private]

Definition at line 94 of file dm4io.h.

Referenced by add(), and get_xsize().

vector< int > EMAN::GatanDM4::TagTable::y_list [private]

Definition at line 95 of file dm4io.h.

Referenced by add(), and get_ysize().


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