Coverage Report

Created: 2025-07-11 06:33

/src/bag/api/bag_georefmetadatalayer.h
Line
Count
Source (jump to first uncovered line)
1
#ifndef BAG_GEOREFMETDATALAYER
2
#define BAG_GEOREFMETDATALAYER
3
4
#include "bag_compounddatatype.h"
5
#include "bag_georefmetadatalayerdescriptor.h"
6
#include "bag_config.h"
7
#include "bag_deleteh5dataset.h"
8
#include "bag_fordec.h"
9
#include "bag_layer.h"
10
#include "bag_types.h"
11
#include "bag_valuetable.h"
12
13
#include <memory>
14
#include <string>
15
16
namespace H5 {
17
18
class DataSet;
19
20
}  // namespace H5
21
22
namespace BAG {
23
24
#ifdef _MSC_VER
25
#pragma warning(push)
26
#pragma warning(disable: 4251)  // std classes do not have DLL-interface when exporting
27
#endif
28
29
//! The interface for a georeferenced metadata layer (spatial metadata).
30
class BAG_API GeorefMetadataLayer final : public Layer
31
{
32
public:
33
    GeorefMetadataLayer(Dataset& dataset, GeorefMetadataLayerDescriptor& descriptor,
34
                        std::unique_ptr<::H5::DataSet, DeleteH5dataSet> h5keyDataSet,
35
                        std::unique_ptr<::H5::DataSet, DeleteH5dataSet> h5vrKeyDataSet,
36
                        std::unique_ptr<::H5::DataSet, DeleteH5dataSet> h5recordDataSet);
37
38
    GeorefMetadataLayer(const GeorefMetadataLayer&) = delete;
39
    GeorefMetadataLayer(GeorefMetadataLayer&&) = delete;
40
41
    GeorefMetadataLayer& operator=(const GeorefMetadataLayer&) = delete;
42
    GeorefMetadataLayer& operator=(GeorefMetadataLayer&&) = delete;
43
44
0
    bool operator==(const GeorefMetadataLayer &rhs) const noexcept {
45
0
        return m_pH5keyDataSet == rhs.m_pH5keyDataSet &&
46
0
               m_pH5vrKeyDataSet == rhs.m_pH5vrKeyDataSet &&
47
0
               m_pH5valueDataSet == rhs.m_pH5valueDataSet &&
48
0
               m_pValueTable == rhs.m_pValueTable;
49
0
    }
50
51
0
    bool operator!=(const GeorefMetadataLayer &rhs) const noexcept {
52
0
        return !(rhs == *this);
53
0
    }
54
55
    std::shared_ptr<GeorefMetadataLayerDescriptor> getDescriptor() & noexcept;
56
    std::shared_ptr<const GeorefMetadataLayerDescriptor> getDescriptor() const & noexcept;
57
58
    ValueTable& getValueTable() & noexcept;
59
    const ValueTable& getValueTable() const & noexcept;
60
61
    UInt8Array readVR(uint32_t indexStart, uint32_t indexEnd) const;
62
    void writeVR(uint32_t indexStart, uint32_t indexEnd, const uint8_t* buffer);
63
64
protected:
65
    static std::shared_ptr<GeorefMetadataLayer> create(DataType keyType,
66
                                                       const std::string& name, GeorefMetadataProfile profile, Dataset& dataset,
67
                                                       const RecordDefinition& definition, uint64_t chunkSize,
68
                                                       int compressionLevel);
69
    static std::shared_ptr<GeorefMetadataLayer> open(Dataset& dataset,
70
                                                     GeorefMetadataLayerDescriptor& descriptor);
71
72
private:
73
    static std::unique_ptr<::H5::DataSet, DeleteH5dataSet>
74
        createH5keyDataSet(const Dataset& inDataSet,
75
            const GeorefMetadataLayerDescriptor& descriptor);
76
77
    static std::unique_ptr<::H5::DataSet, DeleteH5dataSet>
78
        createH5vrKeyDataSet(const Dataset& inDataSet,
79
            const GeorefMetadataLayerDescriptor& descriptor);
80
81
    static std::unique_ptr<::H5::DataSet, DeleteH5dataSet>
82
        createH5valueDataSet(const Dataset& inDataSet,
83
            const GeorefMetadataLayerDescriptor& descriptor);
84
85
    const ::H5::DataSet& getValueDataSet() const &;
86
87
    void setValueTable(std::unique_ptr<ValueTable> table) noexcept;
88
89
    UInt8Array readProxy(uint32_t rowStart, uint32_t columnStart,
90
        uint32_t rowEnd, uint32_t columnEnd) const override;
91
92
    void writeProxy(uint32_t rowStart, uint32_t columnStart, uint32_t rowEnd,
93
        uint32_t columnEnd, const uint8_t* buffer) override;
94
95
    void writeAttributesProxy() const override;
96
97
    //! The HDF5 DataSet containing the single resolution keys.
98
    std::unique_ptr<::H5::DataSet, DeleteH5dataSet> m_pH5keyDataSet;
99
    //! The HDF5 DataSet containing the variable resolution keys.
100
    std::unique_ptr<::H5::DataSet, DeleteH5dataSet> m_pH5vrKeyDataSet;
101
    //! The HDF5 DataSet containing the values of the spatial metadata.
102
    std::unique_ptr<::H5::DataSet, DeleteH5dataSet> m_pH5valueDataSet;
103
    //! The records in memory.
104
    std::unique_ptr<ValueTable> m_pValueTable;
105
106
    friend Dataset;
107
    friend ValueTable;
108
};
109
110
#ifdef _MSC_VER
111
#pragma warning(pop)
112
#endif
113
114
}  // namespace BAG
115
116
#endif  // BAG_GEOREFMETDATALAYER
117