Coverage Report

Created: 2025-07-11 06:33

/src/bag/api/bag_layerdescriptor.h
Line
Count
Source (jump to first uncovered line)
1
#ifndef BAG_LAYERDESCRIPTOR_H
2
#define BAG_LAYERDESCRIPTOR_H
3
4
#include "bag_config.h"
5
#include "bag_fordec.h"
6
#include "bag_types.h"
7
8
#include <limits>
9
#include <memory>
10
#include <string>
11
#include <tuple>
12
13
14
#ifdef _MSC_VER
15
#pragma warning(push)
16
#pragma warning(disable: 4251)  // std classes do not have DLL-interface when exporting
17
#endif
18
19
namespace BAG {
20
21
//! Describe a layer.
22
class BAG_API LayerDescriptor : public std::enable_shared_from_this<LayerDescriptor>
23
{
24
public:
25
268
    virtual ~LayerDescriptor() = default;
26
27
    LayerDescriptor(const LayerDescriptor&) = delete;
28
    LayerDescriptor(LayerDescriptor&&) = delete;
29
30
    LayerDescriptor& operator=(const LayerDescriptor&) = delete;
31
    LayerDescriptor& operator=(LayerDescriptor&&) = delete;
32
33
0
    bool operator==(const LayerDescriptor &rhs) const noexcept {
34
0
        return m_id == rhs.m_id &&
35
0
               m_layerType == rhs.m_layerType &&
36
0
               m_internalPath == rhs.m_internalPath &&
37
0
               m_name == rhs.m_name &&
38
0
               m_compressionLevel == rhs.m_compressionLevel &&
39
0
               m_chunkSize == rhs.m_chunkSize &&
40
0
               m_minMax == rhs.m_minMax;
41
0
    }
42
43
0
    bool operator!=(const LayerDescriptor &rhs) const noexcept {
44
0
        return !(rhs == *this);
45
0
    }
46
47
    uint64_t getChunkSize() const noexcept;
48
    int getCompressionLevel() const noexcept;
49
    DataType getDataType() const noexcept;
50
    uint8_t getElementSize() const noexcept;
51
    uint32_t getId() const noexcept;
52
    const std::string& getInternalPath() const & noexcept;
53
    LayerType getLayerType() const noexcept;
54
    std::tuple<float, float> getMinMax() const noexcept;
55
    const std::string& getName() const & noexcept;
56
57
    LayerDescriptor& setName(std::string inName) & noexcept;
58
    LayerDescriptor& setMinMax(float min, float max) & noexcept;
59
60
protected:
61
    LayerDescriptor(uint32_t id, std::string internalPath, std::string name,
62
        LayerType type, uint64_t chunkSize, int compressionLevel);
63
    LayerDescriptor(const Dataset& dataset, LayerType type,
64
        std::string internalPath = {}, std::string name = {});
65
66
    size_t getReadBufferSize(uint32_t rows, uint32_t columns) const noexcept;
67
68
    LayerDescriptor& setInternalPath(std::string inPath) & noexcept;
69
70
private:
71
    virtual DataType getDataTypeProxy() const noexcept = 0;
72
    virtual uint8_t getElementSizeProxy() const noexcept = 0;
73
74
    //! The unique id.
75
    uint32_t m_id = kInvalidLayerId;
76
    //! The layer type.
77
    LayerType m_layerType = UNKNOWN_LAYER_TYPE;
78
    //! The path of the DataSet in the HDF5 file.
79
    std::string m_internalPath;
80
    //! The name of the layer.
81
    std::string m_name;
82
    //! The compression level of this layer (0-9).
83
    int m_compressionLevel = 0;
84
    //! The chunk size of this layer.
85
    uint64_t m_chunkSize = 0;
86
    //! The minimum and maximum value of this dataset.
87
    std::tuple<float, float> m_minMax{};
88
89
    friend GeorefMetadataLayer;
90
    friend InterleavedLegacyLayer;
91
    friend SurfaceCorrections;
92
    friend SimpleLayer;
93
    friend VRMetadata;
94
};
95
96
#ifdef _MSC_VER
97
#pragma warning(pop)
98
#endif
99
100
}  // namespace BAG
101
102
#endif  // BAG_LAYERDESCRIPTOR_H
103