EMAN2
Public Types | Public Member Functions | Private Attributes
EMAN::Gatan::TagEntry Class Reference

#include <dm3io.h>

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

List of all members.

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 159 of file dm3io.h.


Member Enumeration Documentation

Enumerator:
GROUP_TAG 
DATA_TAG 

Definition at line 162 of file dm3io.h.

                        {
                                GROUP_TAG = 20,
                                DATA_TAG = 21
                        };

Constructor & Destructor Documentation

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

Definition at line 574 of file dm3io.cpp.

        :       in(data_file), tagtable(table), parent_group(parent), name("")
{
}
TagEntry::~TagEntry ( )

Definition at line 579 of file dm3io.cpp.

{
}

Member Function Documentation

int TagEntry::read ( bool  nodata = false)

Definition at line 583 of file dm3io.cpp.

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::TagGroup::read(), EMAN::Gatan::TagData::read(), tagtable, and EMAN::Gatan::to_str().

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

{
        LOGVAR("TagEntry::read()");
        int err = 0;
        char tag_type = 0;
        char *tmp_name = 0;

        size_t nr;
        nr = fread(&tag_type, sizeof(char), 1, in);

        if (tag_type != GROUP_TAG && tag_type != DATA_TAG) {
                LOGERR("TagEntry::read() invalid tag type: %d", tag_type);
                return 1;
        }

        short name_len = 0;
        nr = fread(&name_len, sizeof(short), 1, in);
        ByteOrder::become_big_endian(&name_len);

        if (name_len != 0) {
                tmp_name = new char[name_len + 1];
                nr = fread(tmp_name, name_len, 1, in);
                tmp_name[name_len] = '\0';
        }
        else {
                string parent_name = parent_group->get_name();
                name_len = static_cast < short >(parent_name.size() + 4);
                tmp_name = new char[name_len + 1];
                sprintf(tmp_name, "%s #%d", parent_name.c_str(), parent_group->get_entry_id());
        }

        name = string(tmp_name);

        if (tmp_name) {
                delete [] tmp_name;
                tmp_name = 0;
        }

        LOGVAR("\ntag name: '%s', len: %d, type: '%s'",
                   name.c_str(), name_len, Gatan::to_str((EntryType) tag_type));

        if (tag_type == DATA_TAG) {
                TagData tag_data(in, tagtable, name);
                err = tag_data.read(nodata);
        }
        else if (tag_type == GROUP_TAG) {
                TagGroup group(in, tagtable, name);
                err = group.read(nodata);
        }

        return err;
}

Member Data Documentation

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

Definition at line 174 of file dm3io.h.

Referenced by read().

string EMAN::Gatan::TagEntry::name [private]

Definition at line 177 of file dm3io.h.

Referenced by read().

Definition at line 176 of file dm3io.h.

Referenced by read().

Definition at line 175 of file dm3io.h.

Referenced by read().


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