Coverage Report

Created: 2026-02-26 06:47

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/bag/api/bag_vrmetadatadescriptor.cpp
Line
Count
Source
1
2
#include "bag_exceptions.h"
3
#include "bag_private.h"
4
#include "bag_vrmetadatadescriptor.h"
5
6
7
namespace BAG {
8
9
//! Constructor.
10
/*!
11
\param id
12
    The unique layer id.
13
\param chunkSize
14
    The chunk size the HDF5 DataSet will use.
15
\param compressionLevel
16
    The compression level the HDF5 DataSet will use.
17
*/
18
VRMetadataDescriptor::VRMetadataDescriptor(
19
    uint32_t id,
20
    uint32_t rows, uint32_t cols,
21
    uint64_t chunkSize,
22
    int compressionLevel)
23
0
    : LayerDescriptor(id, VR_METADATA_PATH,
24
0
        kLayerTypeMapString.at(VarRes_Metadata), VarRes_Metadata,
25
0
        rows, cols, chunkSize, compressionLevel)
26
0
{
27
0
}
28
29
//! Constructor.
30
/*!
31
\param dataset
32
    The BAG Dataset this layer belongs to.
33
*/
34
VRMetadataDescriptor::VRMetadataDescriptor(
35
    const Dataset& dataset,
36
    uint32_t rows, uint32_t cols)
37
0
    : LayerDescriptor(dataset, VarRes_Metadata, rows, cols, VR_METADATA_PATH)
38
0
{
39
0
}
40
41
//! Create a variable resolution metadata descriptor.
42
/*!
43
\param dataset
44
    The BAG Dataset this layer belongs to.
45
\param chunkSize
46
    The chunk size the HDF5 DataSet will use.
47
\param compressionLevel
48
    The compression level the HDF5 DataSet will use.
49
50
\return
51
    The new variable resolution metadata descriptor.
52
*/
53
std::shared_ptr<VRMetadataDescriptor> VRMetadataDescriptor::create(
54
    const Dataset& dataset,
55
    uint64_t chunkSize,
56
    int compressionLevel)
57
0
{
58
    // The VRMetadataLayer has the same dimensions as the overall BAG file
59
    // (since there should be one element for each cell in the mandatory
60
    // layers).  Reading this from the dataset layer descriptor enforces this
61
    // and keeps the call signature simpler.
62
0
    uint32_t rows, cols;
63
0
    std::tie(rows, cols) = dataset.getDescriptor().getDims();
64
0
    return std::shared_ptr<VRMetadataDescriptor>(
65
0
        new VRMetadataDescriptor{dataset.getNextId(), rows, cols,
66
0
            chunkSize, compressionLevel});
67
0
}
68
69
//! Open an existing variable resolution metadata descriptor.
70
/*!
71
\param dataset
72
    The BAG Dataset this layer belongs to.
73
74
\return
75
    The variable resolution metadata descriptor.
76
*/
77
std::shared_ptr<VRMetadataDescriptor> VRMetadataDescriptor::open(
78
    const Dataset& dataset)
79
0
{
80
    // The VRMetadataLayer has the same dimensions as the overall BAG file
81
    // (since there should be one element for each cell in the mandatory
82
    // layers).  Reading this from the dataset layer descriptor enforces this
83
    // and keeps the call signature simpler.
84
0
    uint32_t rows, cols;
85
0
    std::tie(rows, cols) = dataset.getDescriptor().getDims();
86
0
    return std::shared_ptr<VRMetadataDescriptor>(
87
0
        new VRMetadataDescriptor{dataset, rows, cols});
88
0
}
89
90
91
//! \copydoc LayerDescriptor::getDataType
92
DataType VRMetadataDescriptor::getDataTypeProxy() const noexcept
93
0
{
94
0
    return DT_COMPOUND;
95
0
}
96
97
//! \copydoc LayerDescriptor::getElementSize
98
uint8_t VRMetadataDescriptor::getElementSizeProxy() const noexcept
99
0
{
100
0
    return sizeof(VRMetadataItem);
101
0
}
102
103
//! Retrieve the maximum dimensions.
104
/*!
105
\return
106
    The maximum X and Y dimensions.
107
*/
108
std::tuple<uint32_t, uint32_t>
109
VRMetadataDescriptor::getMaxDimensions() const noexcept
110
0
{
111
0
    return {m_maxDimX, m_maxDimY};
112
0
}
113
114
//! Retrieve the maximum resolution.
115
/*!
116
\return
117
    The maximum X and Y resolution.
118
*/
119
std::tuple<float, float>
120
VRMetadataDescriptor::getMaxResolution() const noexcept
121
0
{
122
0
    return {m_maxResX, m_maxResY};
123
0
}
124
125
//! Retrieve the minimum dimensions.
126
/*!
127
\return
128
    The minimum X and Y dimensions.
129
*/
130
std::tuple<uint32_t, uint32_t>
131
VRMetadataDescriptor::getMinDimensions() const noexcept
132
0
{
133
0
    return {m_minDimX, m_minDimY};
134
0
}
135
136
//! Retrieve the minimum resolution.
137
/*!
138
\return
139
    The minimum X and Y resolution.
140
*/
141
std::tuple<float, float>
142
VRMetadataDescriptor::getMinResolution() const noexcept
143
0
{
144
0
    return {m_minResX, m_minResY};
145
0
}
146
147
//! Set the maximum dimensions.
148
/*!
149
\param maxDimX
150
    The maximum X dimension.
151
\param maxDimY
152
    The maximum Y dimension.
153
154
\return
155
    The variable resolution metadata descriptor.
156
*/
157
VRMetadataDescriptor& VRMetadataDescriptor::setMaxDimensions(
158
    uint32_t maxDimX,
159
    uint32_t maxDimY) & noexcept
160
0
{
161
0
    m_maxDimX = maxDimX;
162
0
    m_maxDimY = maxDimY;
163
0
    return *this;
164
0
}
165
166
//! Set the maximum resolution.
167
/*!
168
\param maxResX
169
    The maximum X resolution.
170
\param maxResY
171
    The maximum Y resolution.
172
173
\return
174
    The variable resolution metadata descriptor.
175
*/
176
VRMetadataDescriptor& VRMetadataDescriptor::setMaxResolution(
177
    float maxResX,
178
    float maxResY) & noexcept
179
0
{
180
0
    m_maxResX = maxResX;
181
0
    m_maxResY = maxResY;
182
0
    return *this;
183
0
}
184
185
//! Set the minimum dimensions.
186
/*!
187
\param minDimX
188
    The minimum X dimension.
189
\param minDimY
190
    The minimum Y dimension.
191
192
\return
193
    The variable resolution metadata descriptor.
194
*/
195
VRMetadataDescriptor& VRMetadataDescriptor::setMinDimensions(
196
    uint32_t minDimX,
197
    uint32_t minDimY) & noexcept
198
0
{
199
0
    m_minDimX = minDimX;
200
0
    m_minDimY = minDimY;
201
0
    return *this;
202
0
}
203
204
//! Set the minimum resolution.
205
/*!
206
\param minResX
207
    The minimum X resolution.
208
\param minResY
209
    The minimum Y resolution.
210
211
\return
212
    The variable resolution metadata descriptor.
213
*/
214
VRMetadataDescriptor& VRMetadataDescriptor::setMinResolution(
215
    float minResX,
216
    float minResY) & noexcept
217
0
{
218
0
    m_minResX = minResX;
219
0
    m_minResY = minResY;
220
0
    return *this;
221
0
}
222
223
}  // namespace BAG
224