EMAN::Gatan::TagTable Class Reference

#include <dm3io.h>

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_xsize () const
int get_ysize () const
int get_datatype () const
char * get_data () const
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_index
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_DATATYPE_TAG = "DataType"
static const char * IMAGE_THUMB_INDEX_TAG = "ImageIndex"


Detailed Description

Definition at line 48 of file dm3io.h.


Constructor & Destructor Documentation

TagTable::TagTable (  ) 

Definition at line 50 of file dm3io.cpp.

00051         :       img_index(0), is_big_endian(true)
00052 {
00053 }

TagTable::~TagTable (  ) 

Definition at line 55 of file dm3io.cpp.

References data_list.

00056 {
00057         for (unsigned int i = 0; i < data_list.size(); i++) {
00058                 if (data_list[i]) {
00059                         delete[]data_list[i];
00060                         data_list[i] = 0;
00061                 }
00062         }
00063 }


Member Function Documentation

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

Definition at line 66 of file dm3io.cpp.

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

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

00067 {
00068         const char *value_str = value.c_str();
00069 
00070         if (name == IMAGE_WIDTH_TAG) {
00071                 x_list.push_back(atoi(value_str));
00072         }
00073         else if (name == IMAGE_HEIGHT_TAG) {
00074                 y_list.push_back(atoi(value_str));
00075         }
00076         else if (name == IMAGE_DATATYPE_TAG) {
00077                 datatype_list.push_back(atoi(value_str));
00078         }
00079         else if (name == IMAGE_THUMB_INDEX_TAG) {
00080                 set_thumb_index(atoi(value_str));
00081         }
00082         else {
00083                 tags[name] = value;
00084         }
00085 }

void TagTable::add_data ( char *  data  ) 

Definition at line 87 of file dm3io.cpp.

References data_list, and NullPointerException.

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

00088 {
00089         if (!data) {
00090                 throw NullPointerException("DM3 data is NULL");
00091         }
00092         else {
00093                 data_list.push_back(data);
00094         }
00095 }

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

Definition at line 69 of file dm3io.h.

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

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

00069                                                                                           {
00070                                 if (is_big_endian != ByteOrder::is_host_big_endian()) {
00071                                         ByteOrder::swap_bytes(data, n);
00072                                 }
00073                         }

void TagTable::dump (  )  const

Definition at line 117 of file dm3io.cpp.

References tags.

00118 {
00119         map < string, string >::const_iterator p;
00120 
00121         for (p = tags.begin(); p != tags.end(); p++) {
00122 //              LOGDEBUG("  %s: %s", (*p).first.c_str(), (*p).second.c_str());
00123                 printf("  %s: %s\n", (*p).first.c_str(), (*p).second.c_str());
00124         }
00125 }

char * TagTable::get_data (  )  const

Definition at line 142 of file dm3io.cpp.

References data_list, and img_index.

00143 {
00144         return data_list[img_index];
00145 }

int TagTable::get_datatype (  )  const

Definition at line 137 of file dm3io.cpp.

References datatype_list, and img_index.

00138 {
00139         return datatype_list[img_index];
00140 }

double TagTable::get_double ( const string &  name  ) 

Definition at line 112 of file dm3io.cpp.

References tags.

00113 {
00114         return atof(tags[name].c_str());
00115 }

float TagTable::get_float ( const string &  name  ) 

Definition at line 107 of file dm3io.cpp.

References tags.

00108 {
00109         return static_cast < float >(atof(tags[name].c_str()));
00110 }

int TagTable::get_int ( const string &  name  ) 

Definition at line 102 of file dm3io.cpp.

References tags.

00103 {
00104         return atoi(tags[name].c_str());
00105 }

string TagTable::get_string ( const string &  name  ) 

Definition at line 97 of file dm3io.cpp.

References tags.

00098 {
00099         return tags[name];
00100 }

int TagTable::get_xsize (  )  const

Definition at line 127 of file dm3io.cpp.

References img_index, and x_list.

00128 {
00129         return x_list[img_index];
00130 }

int TagTable::get_ysize (  )  const

Definition at line 132 of file dm3io.cpp.

References img_index, and y_list.

00133 {
00134         return y_list[img_index];
00135 }

void EMAN::Gatan::TagTable::set_endian ( bool  big_endian  )  [inline]

Definition at line 75 of file dm3io.h.

References is_big_endian.

00076                         {
00077                                 is_big_endian = big_endian;
00078                         }

void TagTable::set_thumb_index ( int  i  )  [private]

Definition at line 147 of file dm3io.cpp.

References img_index, and OutofRangeException.

Referenced by add().

00148 {
00149         if (i != 0 && i != 1) {
00150                 throw OutofRangeException(0, 1, i, "image index");
00151         }
00152         else {
00153                 if (i == 0) {
00154                         img_index = 1;
00155                 }
00156                 else {
00157                         img_index = 0;
00158                 }
00159         }
00160 }


Member Data Documentation

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

Definition at line 94 of file dm3io.h.

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

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

Definition at line 93 of file dm3io.h.

Referenced by add(), and get_datatype().

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

Definition at line 83 of file dm3io.h.

Referenced by add().

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

Definition at line 82 of file dm3io.h.

Referenced by add().

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

Definition at line 84 of file dm3io.h.

Referenced by add().

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

Definition at line 81 of file dm3io.h.

Referenced by add().

int EMAN::Gatan::TagTable::img_index [private]

Definition at line 88 of file dm3io.h.

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

bool EMAN::Gatan::TagTable::is_big_endian [private]

Definition at line 89 of file dm3io.h.

Referenced by become_host_endian(), and set_endian().

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

Definition at line 90 of file dm3io.h.

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

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

Definition at line 91 of file dm3io.h.

Referenced by add(), and get_xsize().

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

Definition at line 92 of file dm3io.h.

Referenced by add(), and get_ysize().


The documentation for this class was generated from the following files:
Generated on Tue Jun 11 12:45:37 2013 for EMAN2 by  doxygen 1.4.7