EMAN2
Public Types | Public Member Functions | Private Attributes | List of all members
EMAN::Gatan::TagEntry Class Reference

#include <dm3io.h>

Collaboration diagram for EMAN::Gatan::TagEntry:
Collaboration graph
[legend]

Public Types

enum  EntryType { GROUP_TAG = 20 , DATA_TAG = 21 }
 

Public Member Functions

 TagEntry (FILE *data_file, TagTable *tagtable, TagGroup *parent_group)
 
 ~TagEntry ()
 
int read (bool nodata=false)
 

Private Attributes

FILE * in
 
TagTabletagtable
 
TagGroupparent_group
 
string name
 

Detailed Description

Definition at line 155 of file dm3io.h.

Member Enumeration Documentation

◆ EntryType

Enumerator
GROUP_TAG 
DATA_TAG 

Definition at line 158 of file dm3io.h.

159 {
160 GROUP_TAG = 20,
161 DATA_TAG = 21
162 };

Constructor & Destructor Documentation

◆ TagEntry()

TagEntry::TagEntry ( FILE *  data_file,
TagTable tagtable,
TagGroup parent_group 
)

Definition at line 570 of file dm3io.cpp.

571 : in(data_file), tagtable(table), parent_group(parent), name("")
572{
573}
TagGroup * parent_group
Definition: dm3io.h:172
TagTable * tagtable
Definition: dm3io.h:171

◆ ~TagEntry()

TagEntry::~TagEntry ( )

Definition at line 575 of file dm3io.cpp.

576{
577}

Member Function Documentation

◆ read()

int TagEntry::read ( bool  nodata = false)

Definition at line 579 of file dm3io.cpp.

580{
581 LOGVAR("TagEntry::read()");
582 int err = 0;
583 char tag_type = 0;
584 char *tmp_name = 0;
585
586 size_t nr;
587 nr = fread(&tag_type, sizeof(char), 1, in); nr++;
588
589 if (tag_type != GROUP_TAG && tag_type != DATA_TAG) {
590 LOGERR("TagEntry::read() invalid tag type: %d", tag_type);
591 return 1;
592 }
593
594 short name_len = 0;
595 nr = fread(&name_len, sizeof(short), 1, in); nr++;
597
598 if (name_len != 0) {
599 tmp_name = new char[name_len + 1];
600 nr = fread(tmp_name, name_len, 1, in); nr++;
601 tmp_name[name_len] = '\0';
602 }
603 else {
604 string parent_name = parent_group->get_name();
605 name_len = static_cast < short >(parent_name.size() + 4);
606 tmp_name = new char[name_len + 1];
607 sprintf(tmp_name, "%s #%d", parent_name.c_str(), parent_group->get_entry_id());
608 }
609
610 name = string(tmp_name);
611
612 if (tmp_name) {
613 delete [] tmp_name;
614 tmp_name = 0;
615 }
616
617 LOGVAR("\ntag name: '%s', len: %d, type: '%s'",
618 name.c_str(), name_len, Gatan::to_str((EntryType) tag_type));
619
620 if (tag_type == DATA_TAG) {
621 TagData tag_data(in, tagtable, name);
622 err = tag_data.read(nodata);
623 }
624 else if (tag_type == GROUP_TAG) {
625 TagGroup group(in, tagtable, name);
626 err = group.read(nodata);
627 }
628
629 return err;
630}
static void become_big_endian(T *data, size_t n=1)
convert data from host byte order to big endian order.
Definition: byteorder.h:112
string get_name() const
Definition: dm3io.cpp:556
#define LOGERR
Definition: log.h:51
#define LOGVAR
Definition: log.h:57
const char * to_str(Gatan::TagData::Type type)
Definition: dm3io.cpp:925

References EMAN::ByteOrder::become_big_endian(), DATA_TAG, EMAN::Gatan::TagGroup::get_entry_id(), EMAN::Gatan::TagGroup::get_name(), GROUP_TAG, in, LOGERR, LOGVAR, name, parent_group, EMAN::Gatan::TagData::read(), EMAN::Gatan::TagGroup::read(), tagtable, and EMAN::Gatan::to_str().

Referenced by EMAN::Gatan::TagGroup::read().

Member Data Documentation

◆ in

FILE* EMAN::Gatan::TagEntry::in
private

Definition at line 170 of file dm3io.h.

Referenced by read().

◆ name

string EMAN::Gatan::TagEntry::name
private

Definition at line 173 of file dm3io.h.

Referenced by read().

◆ parent_group

TagGroup* EMAN::Gatan::TagEntry::parent_group
private

Definition at line 172 of file dm3io.h.

Referenced by read().

◆ tagtable

TagTable* EMAN::Gatan::TagEntry::tagtable
private

Definition at line 171 of file dm3io.h.

Referenced by read().


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