File: HDFCmpRootGroup.hpp

package info (click to toggle)
pbseqlib 5.3.4%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 7,020 kB
  • sloc: cpp: 77,246; python: 331; sh: 103; makefile: 42
file content (76 lines) | stat: -rw-r--r-- 2,186 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#ifndef _BLASR_HDF_CMP_ROOT_GROUP_HPP_
#define _BLASR_HDF_CMP_ROOT_GROUP_HPP_

#include <alignment/datastructures/alignment/CmpFile.hpp>
#include <hdf/HDF2DArray.hpp>
#include <hdf/HDFAtom.hpp>

template <typename T_Alignment>
class HDFCmpRootGroup
{
public:
    HDFGroup rootGroup;
    HDFAtom<std::string> version;
    HDFAtom<std::string> index;
    HDFAtom<std::string> readType;
    HDFAtom<std::string> commandLine;
    HDF2DArray<std::string> fileLog;

    ~HDFCmpRootGroup() { rootGroup.Close(); }

    int Initialize(H5::H5File &cmpFile)
    {
        if (rootGroup.Initialize(cmpFile, "/") == 0) {
            return 0;
        }
        if (rootGroup.ContainsObject("Version")) {
            if (version.Initialize(rootGroup.group, "Version") == 0) {
                return 0;
            }
        }
        if (rootGroup.ContainsObject("Index")) {
            if (index.Initialize(rootGroup.group, "Index") == 0) {
                return 0;
            }
        }
        if (rootGroup.ContainsObject("ReadType")) {
            if (readType.Initialize(rootGroup.group, "ReadType") == 0) {
                return 0;
            }
        }
        if (rootGroup.ContainsObject("CommandLine")) {
            if (commandLine.Initialize(rootGroup.group, "CommandLine") == 0) {
                return 0;
            }
        }

        //
        // For now, disable file log initialization until
        // hdf2darray<std::string> is tested more thoroughly
        //
        // if (fileLog.Initialize(rootGroup.group, "FileLog") == 0) {
        // return 0;}
        //
        return 1;
    }

    void ReadAttributes(CmpFile &cmpFile)
    {
        if (rootGroup.ContainsObject("Version")) {
            version.Read(cmpFile.version);
        }
        if (rootGroup.ContainsObject("Index")) {
            index.Read(cmpFile.index);
        }
        if (rootGroup.ContainsObject("ReadType")) {
            std::string readTypeString;
            readType.Read(readTypeString);
            cmpFile.StoreReadType(readTypeString);
        }
        if (rootGroup.ContainsObject("CommandLine")) {
            commandLine.Read(cmpFile.commandLine);
        }
    }
};

#endif