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

#include <dm4io.h>

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 41 of file dm4io.h.

Constructor & Destructor Documentation

◆ TagTable()

TagTable::TagTable ( )

Definition at line 46 of file dm4io.cpp.

◆ ~TagTable()

TagTable::~TagTable ( )

Definition at line 51 of file dm4io.cpp.

52{
53 for (unsigned int i = 0; i < data_list.size(); i++) {
54 if (data_list[i]) {
55 delete[]data_list[i];
56 data_list[i] = 0;
57 }
58 }
59}
vector< char * > data_list
Definition: dm4io.h:93

References data_list.

Member Function Documentation

◆ add()

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

Definition at line 61 of file dm4io.cpp.

62{
63 const char *value_str = value.c_str();
64
65 if (name == IMAGE_WIDTH_TAG) {
66 x_list.push_back(atoi(value_str));
67 }
68 else if (name == IMAGE_HEIGHT_TAG) {
69 y_list.push_back(atoi(value_str));
70 }
71 else if (name == IMAGE_DATATYPE_TAG) {
72 datatype_list.push_back(atoi(value_str));
73 }
74 else if (name == IMAGE_THUMB_INDEX_TAG) {
75 set_thumb_index(atoi(value_str));
76 }
77 else if(name == IMAGE_NIMG_TAG){
78 img_counted=atoi(value_str);
79 }
80 else {
81 tags[name] = value;
82 }
83}
static const char * IMAGE_HEIGHT_TAG
Definition: dm4io.h:78
std::map< string, string > tags
Definition: dm4io.h:89
vector< int > datatype_list
Definition: dm4io.h:92
vector< int > y_list
Definition: dm4io.h:91
static const char * IMAGE_NIMG_TAG
Definition: dm4io.h:79
static const char * IMAGE_THUMB_INDEX_TAG
Definition: dm4io.h:81
static const char * IMAGE_WIDTH_TAG
Definition: dm4io.h:77
void set_thumb_index(int i)
Definition: dm4io.cpp:150
vector< int > x_list
Definition: dm4io.h:90
static const char * IMAGE_DATATYPE_TAG
Definition: dm4io.h:80

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().

◆ add_data()

void TagTable::add_data ( char *  data)

Definition at line 85 of file dm4io.cpp.

86{
87 if (!data) {
88 throw NullPointerException("DM4 data is NULL");
89 }
90 else {
91 data_list.push_back(data);
92 }
93}
#define NullPointerException(desc)
Definition: exception.h:241

References data_list, and NullPointerException.

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

◆ become_host_endian()

template<class T >
void EMAN::GatanDM4::TagTable::become_host_endian ( T *  data,
int  n = 1 
)
inline

Definition at line 65 of file dm4io.h.

65 {
67 ByteOrder::swap_bytes(data, n);
68 }
69 }
static bool is_host_big_endian()
Definition: byteorder.cpp:40
static void swap_bytes(T *data, size_t n=1)
swap the byte order of data with 'n' T-type elements.
Definition: byteorder.h:131

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

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

◆ dump()

void TagTable::dump ( ) const

Definition at line 115 of file dm4io.cpp.

116{
117 map < string, string >::const_iterator p;
118
119 for (p = tags.begin(); p != tags.end(); p++) {
120// LOGDEBUG(" %s: %s", (*p).first.c_str(), (*p).second.c_str());
121 printf(" %s: %s\n", (*p).first.c_str(), (*p).second.c_str());
122 }
123}

References tags.

◆ get_data()

char * TagTable::get_data ( ) const

Definition at line 145 of file dm4io.cpp.

146{
147 return data_list[img_index];
148}

References data_list, and img_index.

◆ get_datatype()

int TagTable::get_datatype ( ) const

Definition at line 140 of file dm4io.cpp.

141{
142 return datatype_list[img_index];
143}

References datatype_list, and img_index.

◆ get_double()

double TagTable::get_double ( const string &  name)

Definition at line 110 of file dm4io.cpp.

111{
112 return atof(tags[name].c_str());
113}

References tags.

◆ get_float()

float TagTable::get_float ( const string &  name)

Definition at line 105 of file dm4io.cpp.

106{
107 return static_cast < float >(atof(tags[name].c_str()));
108}

References tags.

◆ get_image_counted()

int TagTable::get_image_counted ( ) const

Definition at line 130 of file dm4io.cpp.

131{
132 return img_counted;
133}

References img_counted.

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

◆ get_int()

int TagTable::get_int ( const string &  name)

Definition at line 100 of file dm4io.cpp.

101{
102 return atoi(tags[name].c_str());
103}

References tags.

◆ get_num_images_found()

int TagTable::get_num_images_found ( ) const

Definition at line 165 of file dm4io.cpp.

166{
167 return num_images_found;
168}

References num_images_found.

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

◆ get_string()

string TagTable::get_string ( const string &  name)

Definition at line 95 of file dm4io.cpp.

96{
97 return tags[name];
98}

References tags.

◆ get_xsize()

int TagTable::get_xsize ( ) const

Definition at line 125 of file dm4io.cpp.

126{
127 return x_list[img_index];
128}

References img_index, and x_list.

◆ get_ysize()

int TagTable::get_ysize ( ) const

Definition at line 135 of file dm4io.cpp.

136{
137 return y_list[img_index];
138}

References img_index, and y_list.

◆ set_endian()

void EMAN::GatanDM4::TagTable::set_endian ( bool  big_endian)
inline

Definition at line 71 of file dm4io.h.

72 {
73 is_big_endian = big_endian;
74 }

References is_big_endian.

◆ set_num_images_found()

void TagTable::set_num_images_found ( int  num_found)

Definition at line 170 of file dm4io.cpp.

171{
172 num_images_found = num_found;
173}

References num_images_found.

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

◆ set_thumb_index()

void TagTable::set_thumb_index ( int  i)
private

Definition at line 150 of file dm4io.cpp.

151{
152 if (i != 0 && i != 1) {
153 throw OutofRangeException(0, 1, i, "image index");
154 }
155 else {
156 if (i == 0) {
157 img_index = 1;
158 }
159 else {
160 img_index = 0;
161 }
162 }
163}
#define OutofRangeException(low, high, input, objname)
Definition: exception.h:334

References img_index, and OutofRangeException.

Referenced by add().

Member Data Documentation

◆ data_list

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

Definition at line 93 of file dm4io.h.

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

◆ datatype_list

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

Definition at line 92 of file dm4io.h.

Referenced by add(), and get_datatype().

◆ IMAGE_DATATYPE_TAG

const char * TagTable::IMAGE_DATATYPE_TAG = "DataType"
staticprivate

Definition at line 80 of file dm4io.h.

Referenced by add().

◆ IMAGE_HEIGHT_TAG

const char * TagTable::IMAGE_HEIGHT_TAG = "Dimensions #1"
staticprivate

Definition at line 78 of file dm4io.h.

Referenced by add().

◆ IMAGE_NIMG_TAG

const char * TagTable::IMAGE_NIMG_TAG = "Dimensions #2"
staticprivate

Definition at line 79 of file dm4io.h.

Referenced by add().

◆ IMAGE_THUMB_INDEX_TAG

const char * TagTable::IMAGE_THUMB_INDEX_TAG = "ImageIndex"
staticprivate

Definition at line 81 of file dm4io.h.

Referenced by add().

◆ IMAGE_WIDTH_TAG

const char * TagTable::IMAGE_WIDTH_TAG = "Dimensions #0"
staticprivate

Definition at line 77 of file dm4io.h.

Referenced by add().

◆ img_counted

int EMAN::GatanDM4::TagTable::img_counted
private

Definition at line 85 of file dm4io.h.

Referenced by add(), and get_image_counted().

◆ img_index

int EMAN::GatanDM4::TagTable::img_index
private

Definition at line 86 of file dm4io.h.

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

◆ is_big_endian

bool EMAN::GatanDM4::TagTable::is_big_endian
private

Definition at line 88 of file dm4io.h.

Referenced by become_host_endian(), and set_endian().

◆ num_images_found

int EMAN::GatanDM4::TagTable::num_images_found
private

Definition at line 87 of file dm4io.h.

Referenced by get_num_images_found(), and set_num_images_found().

◆ tags

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

Definition at line 89 of file dm4io.h.

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

◆ x_list

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

Definition at line 90 of file dm4io.h.

Referenced by add(), and get_xsize().

◆ y_list

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

Definition at line 91 of file dm4io.h.

Referenced by add(), and get_ysize().


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