Coverage Report

Created: 2025-07-11 06:33

/src/bag/api/bag_metadata.h
Line
Count
Source (jump to first uncovered line)
1
#ifndef BAG_METADATA_H
2
#define BAG_METADATA_H
3
4
#include "bag_config.h"
5
#include "bag_deleteh5dataset.h"
6
#include "bag_fordec.h"
7
#include "bag_metadatatypes.h"
8
9
#include <memory>
10
#include <string>
11
12
13
namespace H5 {
14
15
class DataSet;
16
17
}  // namespace H5
18
19
namespace BAG {
20
21
#ifdef _MSC_VER
22
#pragma warning(push)
23
#pragma warning(disable: 4251)  // std classes do not have DLL-interface when exporting
24
#endif
25
26
//! The interface for the metadata.
27
class BAG_API Metadata final
28
{
29
public:
30
    Metadata() noexcept;
31
    explicit Metadata(Dataset& dataset);
32
    explicit Metadata(std::shared_ptr<Dataset> pDataset);
33
    ~Metadata() noexcept;
34
35
    Metadata(const Metadata& other) = delete;
36
0
    Metadata(Metadata&& other) = default;
37
38
    Metadata& operator=(const Metadata&) = delete;
39
    Metadata& operator=(Metadata&&) = delete;
40
41
0
    bool operator==(const Metadata &rhs) const noexcept {
42
0
        return m_pMetaStruct == rhs.m_pMetaStruct &&
43
0
               m_pH5dataSet == rhs.m_pH5dataSet &&
44
0
               m_xmlLength == rhs.m_xmlLength &&
45
0
               weak_ptr_equals(m_pBagDataset, rhs.m_pBagDataset);
46
0
    }
47
48
0
    bool operator!=(const Metadata &rhs) const noexcept {
49
0
        return !(rhs == *this);
50
0
    }
51
52
    const BagMetadata& getStruct() const & noexcept;
53
54
    uint32_t columns() const noexcept;
55
    double columnResolution() const noexcept;
56
    std::string horizontalReferenceSystemAsWKT() const;
57
    double llCornerX() const noexcept;
58
    double llCornerY() const noexcept;
59
    double rowResolution() const noexcept;
60
    uint32_t rows() const noexcept;
61
    double urCornerX() const noexcept;
62
    double urCornerY() const noexcept;
63
    std::string verticalReferenceSystemAsWKT() const;
64
65
    void loadFromFile(const std::string& fileName);
66
    void loadFromBuffer(const std::string& xmlBuffer);
67
68
    size_t getXMLlength() const noexcept;
69
70
private:
71
    void createH5dataSet(const Dataset& inDataSet);
72
73
    void write() const;
74
75
    //! The BAG Dataset the metadata is part of.
76
    std::weak_ptr<const Dataset> m_pBagDataset;
77
    //! The C struct behind this class.
78
    std::unique_ptr<BagMetadata> m_pMetaStruct;
79
    //! The HDF5 DataSet this class wraps.
80
    std::unique_ptr<::H5::DataSet, DeleteH5dataSet> m_pH5dataSet;
81
    //! Length of the XML (from file or buffer).
82
    size_t m_xmlLength = 0;
83
84
    friend Dataset;
85
};
86
87
#ifdef _MSC_VER
88
#pragma warning(pop)
89
#endif
90
91
}  // namespace BAG
92
93
#endif  // BAG_METADATA_H
94
95