File: HDFGroup.cpp

package info (click to toggle)
pbseqlib 5.3.5%2Bdfsg-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 7,020 kB
  • sloc: cpp: 77,250; python: 331; sh: 103; makefile: 41
file content (55 lines) | stat: -rw-r--r-- 1,231 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include <hdf/HDFGroup.hpp>

using namespace H5;

HDFGroup::HDFGroup() : HDFAttributable() { groupIsInitialized = false; }

void HDFGroup::AddGroup(std::string groupName)
{
    group.createGroup(groupName);
    return;
}

H5Object *HDFGroup::GetObject() { return &group; }

int HDFGroup::Initialize(CommonFG &fg, std::string groupName)
{
    try {
        group = fg.openGroup(groupName.c_str());
        groupIsInitialized = true;
        return 1;
    } catch (FileIException &e) {
        return 0;
    } catch (GroupIException &e) {
        return 0;
    } catch (Exception &e) {
        return 0;
    }
    return 1;
}

int HDFGroup::Initialize(HDFGroup &parentGroup, std::string groupName)
{
    return Initialize(parentGroup.group, groupName);
}

bool HDFGroup::ContainsObject(std::string queryObjectName)
{
    hsize_t objIdx;
    hsize_t numGroupObjs = group.getNumObjs();
    for (objIdx = 0; objIdx < numGroupObjs; objIdx++) {
        H5std_string groupObjectName;
        groupObjectName = group.getObjnameByIdx(objIdx);
        if (groupObjectName == queryObjectName) {
            return true;
        }
    }
    return false;
}

void HDFGroup::Close()
{
    if (groupIsInitialized) {
        group.close();
    }
}