Coverage Report

Created: 2025-11-16 06:25

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/gdal/gcore/gdal_multidim.h
Line
Count
Source
1
/******************************************************************************
2
 *
3
 * Name:     gdal_multidim.h
4
 * Project:  GDAL Core
5
 * Purpose:  Declaration of classes for multidimensional support
6
 * Author:   Even Rouault <even.rouault at spatialys.com>
7
 *
8
 ******************************************************************************
9
 * Copyright (c) 2019, Even Rouault <even.rouault at spatialys.com>
10
 *
11
 * SPDX-License-Identifier: MIT
12
 ****************************************************************************/
13
14
#ifndef GDALMULTIDIM_H_INCLUDED
15
#define GDALMULTIDIM_H_INCLUDED
16
17
#include "cpl_conv.h"
18
#include "cpl_string.h"
19
#include "gdal.h"
20
#include "gdal_geotransform.h"
21
22
#include <cstddef>
23
#include <cstdint>
24
#include <limits>
25
#include <memory>
26
#include <vector>
27
28
/* ******************************************************************** */
29
/*                       Multidimensional array API                     */
30
/* ******************************************************************** */
31
32
class GDALMDArray;
33
class GDALAttribute;
34
class GDALDataset;
35
class GDALDimension;
36
class GDALEDTComponent;
37
class GDALRasterAttributeTable;
38
class GDALRasterBand;
39
class OGRLayer;
40
class OGRSpatialReference;
41
42
/* ******************************************************************** */
43
/*                         GDALExtendedDataType                         */
44
/* ******************************************************************** */
45
46
/**
47
 * Class used to represent potentially complex data types.
48
 * Several classes of data types are supported: numeric (based on GDALDataType),
49
 * compound or string.
50
 *
51
 * @since GDAL 3.1
52
 */
53
class CPL_DLL GDALExtendedDataType
54
{
55
  public:
56
    ~GDALExtendedDataType();
57
58
    GDALExtendedDataType(GDALExtendedDataType &&);
59
    GDALExtendedDataType(const GDALExtendedDataType &);
60
61
    GDALExtendedDataType &operator=(const GDALExtendedDataType &);
62
    GDALExtendedDataType &operator=(GDALExtendedDataType &&);
63
64
    static GDALExtendedDataType Create(GDALDataType eType);
65
    static GDALExtendedDataType
66
    Create(const std::string &osName, GDALDataType eBaseType,
67
           std::unique_ptr<GDALRasterAttributeTable>);
68
    static GDALExtendedDataType
69
    Create(const std::string &osName, size_t nTotalSize,
70
           std::vector<std::unique_ptr<GDALEDTComponent>> &&components);
71
    static GDALExtendedDataType
72
    CreateString(size_t nMaxStringLength = 0,
73
                 GDALExtendedDataTypeSubType eSubType = GEDTST_NONE);
74
75
    bool operator==(const GDALExtendedDataType &) const;
76
77
    /** Non-equality operator */
78
    bool operator!=(const GDALExtendedDataType &other) const
79
0
    {
80
0
        return !(operator==(other));
81
0
    }
82
83
    /** Return type name.
84
     *
85
     * This is the same as the C function GDALExtendedDataTypeGetName()
86
     */
87
    const std::string &GetName() const
88
0
    {
89
0
        return m_osName;
90
0
    }
91
92
    /** Return type class.
93
     *
94
     * This is the same as the C function GDALExtendedDataTypeGetClass()
95
     */
96
    GDALExtendedDataTypeClass GetClass() const
97
0
    {
98
0
        return m_eClass;
99
0
    }
100
101
    /** Return numeric data type (only valid when GetClass() == GEDTC_NUMERIC)
102
     *
103
     * This is the same as the C function
104
     * GDALExtendedDataTypeGetNumericDataType()
105
     */
106
    GDALDataType GetNumericDataType() const
107
0
    {
108
0
        return m_eNumericDT;
109
0
    }
110
111
    /** Return subtype.
112
     *
113
     * This is the same as the C function GDALExtendedDataTypeGetSubType()
114
     *
115
     * @since 3.4
116
     */
117
    GDALExtendedDataTypeSubType GetSubType() const
118
0
    {
119
0
        return m_eSubType;
120
0
    }
121
122
    /** Return the components of the data type (only valid when GetClass() ==
123
     * GEDTC_COMPOUND)
124
     *
125
     * This is the same as the C function GDALExtendedDataTypeGetComponents()
126
     */
127
    const std::vector<std::unique_ptr<GDALEDTComponent>> &GetComponents() const
128
0
    {
129
0
        return m_aoComponents;
130
0
    }
131
132
    /** Return data type size in bytes.
133
     *
134
     * For a string, this will be size of a char* pointer.
135
     *
136
     * This is the same as the C function GDALExtendedDataTypeGetSize()
137
     */
138
    size_t GetSize() const
139
0
    {
140
0
        return m_nSize;
141
0
    }
142
143
    /** Return the maximum length of a string in bytes.
144
     *
145
     * 0 indicates unknown/unlimited string.
146
     */
147
    size_t GetMaxStringLength() const
148
0
    {
149
0
        return m_nMaxStringLength;
150
0
    }
151
152
    /** Return associated raster attribute table, when there is one.
153
     *
154
     * For the netCDF driver, the RAT will capture enumerated types, with
155
     * a "value" column with an integer value and a "name" column with the
156
     * associated name.
157
     *
158
     * This is the same as the C function GDALExtendedDataTypeGetRAT()
159
     *
160
     * @since 3.12
161
     */
162
    const GDALRasterAttributeTable *GetRAT() const
163
0
    {
164
0
        return m_poRAT.get();
165
0
    }
166
167
    bool CanConvertTo(const GDALExtendedDataType &other) const;
168
169
    bool NeedsFreeDynamicMemory() const;
170
171
    void FreeDynamicMemory(void *pBuffer) const;
172
173
    static bool CopyValue(const void *pSrc, const GDALExtendedDataType &srcType,
174
                          void *pDst, const GDALExtendedDataType &dstType);
175
176
    static bool CopyValues(const void *pSrc,
177
                           const GDALExtendedDataType &srcType,
178
                           GPtrDiff_t nSrcStrideInElts, void *pDst,
179
                           const GDALExtendedDataType &dstType,
180
                           GPtrDiff_t nDstStrideInElts, size_t nValues);
181
182
  private:
183
    GDALExtendedDataType(size_t nMaxStringLength,
184
                         GDALExtendedDataTypeSubType eSubType);
185
    explicit GDALExtendedDataType(GDALDataType eType);
186
    GDALExtendedDataType(const std::string &osName, GDALDataType eBaseType,
187
                         std::unique_ptr<GDALRasterAttributeTable>);
188
    GDALExtendedDataType(
189
        const std::string &osName, size_t nTotalSize,
190
        std::vector<std::unique_ptr<GDALEDTComponent>> &&components);
191
192
    std::string m_osName{};
193
    GDALExtendedDataTypeClass m_eClass = GEDTC_NUMERIC;
194
    GDALExtendedDataTypeSubType m_eSubType = GEDTST_NONE;
195
    GDALDataType m_eNumericDT = GDT_Unknown;
196
    std::vector<std::unique_ptr<GDALEDTComponent>> m_aoComponents{};
197
    size_t m_nSize = 0;
198
    size_t m_nMaxStringLength = 0;
199
    std::unique_ptr<GDALRasterAttributeTable> m_poRAT{};
200
};
201
202
/* ******************************************************************** */
203
/*                            GDALEDTComponent                          */
204
/* ******************************************************************** */
205
206
/**
207
 * Class for a component of a compound extended data type.
208
 *
209
 * @since GDAL 3.1
210
 */
211
class CPL_DLL GDALEDTComponent
212
{
213
  public:
214
    ~GDALEDTComponent();
215
    GDALEDTComponent(const std::string &name, size_t offset,
216
                     const GDALExtendedDataType &type);
217
    GDALEDTComponent(const GDALEDTComponent &);
218
219
    bool operator==(const GDALEDTComponent &) const;
220
221
    /** Return the name.
222
     *
223
     * This is the same as the C function GDALEDTComponentGetName().
224
     */
225
    const std::string &GetName() const
226
0
    {
227
0
        return m_osName;
228
0
    }
229
230
    /** Return the offset (in bytes) of the component in the compound data type.
231
     *
232
     * This is the same as the C function GDALEDTComponentGetOffset().
233
     */
234
    size_t GetOffset() const
235
0
    {
236
0
        return m_nOffset;
237
0
    }
238
239
    /** Return the data type of the component.
240
     *
241
     * This is the same as the C function GDALEDTComponentGetType().
242
     */
243
    const GDALExtendedDataType &GetType() const
244
0
    {
245
0
        return m_oType;
246
0
    }
247
248
  private:
249
    std::string m_osName;
250
    size_t m_nOffset;
251
    GDALExtendedDataType m_oType;
252
};
253
254
/* ******************************************************************** */
255
/*                            GDALIHasAttribute                         */
256
/* ******************************************************************** */
257
258
/**
259
 * Interface used to get a single GDALAttribute or a set of GDALAttribute
260
 *
261
 * @since GDAL 3.1
262
 */
263
class CPL_DLL GDALIHasAttribute
264
{
265
  protected:
266
    std::shared_ptr<GDALAttribute>
267
    GetAttributeFromAttributes(const std::string &osName) const;
268
269
  public:
270
    virtual ~GDALIHasAttribute();
271
272
    virtual std::shared_ptr<GDALAttribute>
273
    GetAttribute(const std::string &osName) const;
274
275
    virtual std::vector<std::shared_ptr<GDALAttribute>>
276
    GetAttributes(CSLConstList papszOptions = nullptr) const;
277
278
    virtual std::shared_ptr<GDALAttribute>
279
    CreateAttribute(const std::string &osName,
280
                    const std::vector<GUInt64> &anDimensions,
281
                    const GDALExtendedDataType &oDataType,
282
                    CSLConstList papszOptions = nullptr);
283
284
    virtual bool DeleteAttribute(const std::string &osName,
285
                                 CSLConstList papszOptions = nullptr);
286
};
287
288
/* ******************************************************************** */
289
/*                               GDALGroup                              */
290
/* ******************************************************************** */
291
292
/* clang-format off */
293
/**
294
 * Class modeling a named container of GDALAttribute, GDALMDArray, OGRLayer or
295
 * other GDALGroup. Hence GDALGroup can describe a hierarchy of objects.
296
 *
297
 * This is based on the <a href="https://portal.opengeospatial.org/files/81716#_hdf5_group">HDF5 group
298
 * concept</a>
299
 *
300
 * @since GDAL 3.1
301
 */
302
/* clang-format on */
303
304
class CPL_DLL GDALGroup : public GDALIHasAttribute
305
{
306
  protected:
307
    //! @cond Doxygen_Suppress
308
    std::string m_osName{};
309
310
    // This is actually a path of the form "/parent_path/{m_osName}"
311
    std::string m_osFullName{};
312
313
    // Used for example by GDALSubsetGroup to distinguish a derived group
314
    //from its original, without altering its name
315
    const std::string m_osContext{};
316
317
    // List of types owned by the group.
318
    std::vector<std::shared_ptr<GDALExtendedDataType>> m_apoTypes{};
319
320
    //! Weak pointer to this
321
    std::weak_ptr<GDALGroup> m_pSelf{};
322
323
    //! Can be set to false by the owing group, when deleting this object
324
    bool m_bValid = true;
325
326
    GDALGroup(const std::string &osParentName, const std::string &osName,
327
              const std::string &osContext = std::string());
328
329
    const GDALGroup *
330
    GetInnerMostGroup(const std::string &osPathOrArrayOrDim,
331
                      std::shared_ptr<GDALGroup> &curGroupHolder,
332
                      std::string &osLastPart) const;
333
334
    void BaseRename(const std::string &osNewName);
335
336
    bool CheckValidAndErrorOutIfNot() const;
337
338
    void SetSelf(const std::shared_ptr<GDALGroup> &self)
339
0
    {
340
0
        m_pSelf = self;
341
0
    }
342
343
    virtual void NotifyChildrenOfRenaming()
344
0
    {
345
0
    }
346
347
    virtual void NotifyChildrenOfDeletion()
348
0
    {
349
0
    }
350
351
    //! @endcond
352
353
  public:
354
    ~GDALGroup() override;
355
356
    /** Return the name of the group.
357
     *
358
     * This is the same as the C function GDALGroupGetName().
359
     */
360
    const std::string &GetName() const
361
0
    {
362
0
        return m_osName;
363
0
    }
364
365
    /** Return the full name of the group.
366
     *
367
     * This is the same as the C function GDALGroupGetFullName().
368
     */
369
    const std::string &GetFullName() const
370
0
    {
371
0
        return m_osFullName;
372
0
    }
373
374
    /** Return data types associated with the group (typically enumerations)
375
     *
376
     * This is the same as the C function GDALGroupGetDataTypeCount() and GDALGroupGetDataType()
377
     *
378
     * @since 3.12
379
     */
380
    const std::vector<std::shared_ptr<GDALExtendedDataType>> &
381
    GetDataTypes() const
382
0
    {
383
0
        return m_apoTypes;
384
0
    }
385
386
    virtual std::vector<std::string>
387
    GetMDArrayNames(CSLConstList papszOptions = nullptr) const;
388
    virtual std::shared_ptr<GDALMDArray>
389
    OpenMDArray(const std::string &osName,
390
                CSLConstList papszOptions = nullptr) const;
391
392
    std::vector<std::string> GetMDArrayFullNamesRecursive(
393
        CSLConstList papszGroupOptions = nullptr,
394
        CSLConstList papszArrayOptions = nullptr) const;
395
396
    virtual std::vector<std::string>
397
    GetGroupNames(CSLConstList papszOptions = nullptr) const;
398
    virtual std::shared_ptr<GDALGroup>
399
    OpenGroup(const std::string &osName,
400
              CSLConstList papszOptions = nullptr) const;
401
402
    virtual std::vector<std::string>
403
    GetVectorLayerNames(CSLConstList papszOptions = nullptr) const;
404
    virtual OGRLayer *
405
    OpenVectorLayer(const std::string &osName,
406
                    CSLConstList papszOptions = nullptr) const;
407
408
    virtual std::vector<std::shared_ptr<GDALDimension>>
409
    GetDimensions(CSLConstList papszOptions = nullptr) const;
410
411
    virtual std::shared_ptr<GDALGroup>
412
    CreateGroup(const std::string &osName, CSLConstList papszOptions = nullptr);
413
414
    virtual bool DeleteGroup(const std::string &osName,
415
                             CSLConstList papszOptions = nullptr);
416
417
    virtual std::shared_ptr<GDALDimension>
418
    CreateDimension(const std::string &osName, const std::string &osType,
419
                    const std::string &osDirection, GUInt64 nSize,
420
                    CSLConstList papszOptions = nullptr);
421
422
    virtual std::shared_ptr<GDALMDArray> CreateMDArray(
423
        const std::string &osName,
424
        const std::vector<std::shared_ptr<GDALDimension>> &aoDimensions,
425
        const GDALExtendedDataType &oDataType,
426
        CSLConstList papszOptions = nullptr);
427
428
    virtual bool DeleteMDArray(const std::string &osName,
429
                               CSLConstList papszOptions = nullptr);
430
431
    GUInt64 GetTotalCopyCost() const;
432
433
    virtual bool CopyFrom(const std::shared_ptr<GDALGroup> &poDstRootGroup,
434
                          GDALDataset *poSrcDS,
435
                          const std::shared_ptr<GDALGroup> &poSrcGroup,
436
                          bool bStrict, GUInt64 &nCurCost,
437
                          const GUInt64 nTotalCost,
438
                          GDALProgressFunc pfnProgress, void *pProgressData,
439
                          CSLConstList papszOptions = nullptr);
440
441
    virtual CSLConstList GetStructuralInfo() const;
442
443
    std::shared_ptr<GDALMDArray>
444
    OpenMDArrayFromFullname(const std::string &osFullName,
445
                            CSLConstList papszOptions = nullptr) const;
446
447
    std::shared_ptr<GDALAttribute>
448
    OpenAttributeFromFullname(const std::string &osFullName,
449
                              CSLConstList papszOptions = nullptr) const;
450
451
    std::shared_ptr<GDALMDArray>
452
    ResolveMDArray(const std::string &osName, const std::string &osStartingPath,
453
                   CSLConstList papszOptions = nullptr) const;
454
455
    std::shared_ptr<GDALGroup>
456
    OpenGroupFromFullname(const std::string &osFullName,
457
                          CSLConstList papszOptions = nullptr) const;
458
459
    std::shared_ptr<GDALDimension>
460
    OpenDimensionFromFullname(const std::string &osFullName) const;
461
462
    virtual void ClearStatistics();
463
464
    virtual bool Rename(const std::string &osNewName);
465
466
    std::shared_ptr<GDALGroup>
467
    SubsetDimensionFromSelection(const std::string &osSelection) const;
468
469
    //! @cond Doxygen_Suppress
470
    virtual void ParentRenamed(const std::string &osNewParentFullName);
471
472
    virtual void Deleted();
473
474
    virtual void ParentDeleted();
475
476
    const std::string &GetContext() const
477
0
    {
478
0
        return m_osContext;
479
0
    }
480
481
    //! @endcond
482
483
    //! @cond Doxygen_Suppress
484
    static constexpr GUInt64 COPY_COST = 1000;
485
    //! @endcond
486
};
487
488
/* ******************************************************************** */
489
/*                          GDALAbstractMDArray                         */
490
/* ******************************************************************** */
491
492
/**
493
 * Abstract class, implemented by GDALAttribute and GDALMDArray.
494
 *
495
 * @since GDAL 3.1
496
 */
497
class CPL_DLL GDALAbstractMDArray
498
{
499
  protected:
500
    //! @cond Doxygen_Suppress
501
    std::string m_osName{};
502
503
    // This is actually a path of the form "/parent_path/{m_osName}"
504
    std::string m_osFullName{};
505
    std::weak_ptr<GDALAbstractMDArray> m_pSelf{};
506
507
    //! Can be set to false by the owing object, when deleting this object
508
    bool m_bValid = true;
509
510
    GDALAbstractMDArray(const std::string &osParentName,
511
                        const std::string &osName);
512
513
    void SetSelf(const std::shared_ptr<GDALAbstractMDArray> &self)
514
0
    {
515
0
        m_pSelf = self;
516
0
    }
517
518
    bool CheckValidAndErrorOutIfNot() const;
519
520
    bool CheckReadWriteParams(const GUInt64 *arrayStartIdx, const size_t *count,
521
                              const GInt64 *&arrayStep,
522
                              const GPtrDiff_t *&bufferStride,
523
                              const GDALExtendedDataType &bufferDataType,
524
                              const void *buffer,
525
                              const void *buffer_alloc_start,
526
                              size_t buffer_alloc_size,
527
                              std::vector<GInt64> &tmp_arrayStep,
528
                              std::vector<GPtrDiff_t> &tmp_bufferStride) const;
529
530
    virtual bool
531
    IRead(const GUInt64 *arrayStartIdx,    // array of size GetDimensionCount()
532
          const size_t *count,             // array of size GetDimensionCount()
533
          const GInt64 *arrayStep,         // step in elements
534
          const GPtrDiff_t *bufferStride,  // stride in elements
535
          const GDALExtendedDataType &bufferDataType,
536
          void *pDstBuffer) const = 0;
537
538
    virtual bool
539
    IWrite(const GUInt64 *arrayStartIdx,    // array of size GetDimensionCount()
540
           const size_t *count,             // array of size GetDimensionCount()
541
           const GInt64 *arrayStep,         // step in elements
542
           const GPtrDiff_t *bufferStride,  // stride in elements
543
           const GDALExtendedDataType &bufferDataType, const void *pSrcBuffer);
544
545
    void BaseRename(const std::string &osNewName);
546
547
    virtual void NotifyChildrenOfRenaming()
548
0
    {
549
0
    }
550
551
    virtual void NotifyChildrenOfDeletion()
552
0
    {
553
0
    }
554
555
    //! @endcond
556
557
  public:
558
    virtual ~GDALAbstractMDArray();
559
560
    /** Return the name of an array or attribute.
561
     *
562
     * This is the same as the C function GDALMDArrayGetName() or
563
     * GDALAttributeGetName().
564
     */
565
    const std::string &GetName() const
566
0
    {
567
0
        return m_osName;
568
0
    }
569
570
    /** Return the name of an array or attribute.
571
     *
572
     * This is the same as the C function GDALMDArrayGetFullName() or
573
     * GDALAttributeGetFullName().
574
     */
575
    const std::string &GetFullName() const
576
0
    {
577
0
        return m_osFullName;
578
0
    }
579
580
    GUInt64 GetTotalElementsCount() const;
581
582
    virtual size_t GetDimensionCount() const;
583
584
    virtual const std::vector<std::shared_ptr<GDALDimension>> &
585
    GetDimensions() const = 0;
586
587
    virtual const GDALExtendedDataType &GetDataType() const = 0;
588
589
    virtual std::vector<GUInt64> GetBlockSize() const;
590
591
    virtual std::vector<size_t>
592
    GetProcessingChunkSize(size_t nMaxChunkMemory) const;
593
594
    /* clang-format off */
595
    /** Type of pfnFunc argument of ProcessPerChunk().
596
     * @param array Array on which ProcessPerChunk was called.
597
     * @param chunkArrayStartIdx Values representing the starting index to use
598
     *                           in each dimension (in [0, aoDims[i].GetSize()-1] range)
599
     *                           for the current chunk.
600
     *                           Will be nullptr for a zero-dimensional array.
601
     * @param chunkCount         Values representing the number of values to use in
602
     *                           each dimension for the current chunk.
603
     *                           Will be nullptr for a zero-dimensional array.
604
     * @param iCurChunk          Number of current chunk being processed.
605
     *                           In [1, nChunkCount] range.
606
     * @param nChunkCount        Total number of chunks to process.
607
     * @param pUserData          User data.
608
     * @return return true in case of success.
609
     */
610
    typedef bool (*FuncProcessPerChunkType)(
611
                        GDALAbstractMDArray *array,
612
                        const GUInt64 *chunkArrayStartIdx,
613
                        const size_t *chunkCount,
614
                        GUInt64 iCurChunk,
615
                        GUInt64 nChunkCount,
616
                        void *pUserData);
617
    /* clang-format on */
618
619
    virtual bool ProcessPerChunk(const GUInt64 *arrayStartIdx,
620
                                 const GUInt64 *count, const size_t *chunkSize,
621
                                 FuncProcessPerChunkType pfnFunc,
622
                                 void *pUserData);
623
624
    virtual bool
625
    Read(const GUInt64 *arrayStartIdx,    // array of size GetDimensionCount()
626
         const size_t *count,             // array of size GetDimensionCount()
627
         const GInt64 *arrayStep,         // step in elements
628
         const GPtrDiff_t *bufferStride,  // stride in elements
629
         const GDALExtendedDataType &bufferDataType, void *pDstBuffer,
630
         const void *pDstBufferAllocStart = nullptr,
631
         size_t nDstBufferAllocSize = 0) const;
632
633
    bool
634
    Write(const GUInt64 *arrayStartIdx,    // array of size GetDimensionCount()
635
          const size_t *count,             // array of size GetDimensionCount()
636
          const GInt64 *arrayStep,         // step in elements
637
          const GPtrDiff_t *bufferStride,  // stride in elements
638
          const GDALExtendedDataType &bufferDataType, const void *pSrcBuffer,
639
          const void *pSrcBufferAllocStart = nullptr,
640
          size_t nSrcBufferAllocSize = 0);
641
642
    virtual bool Rename(const std::string &osNewName);
643
644
    //! @cond Doxygen_Suppress
645
    virtual void Deleted();
646
647
    virtual void ParentDeleted();
648
649
    virtual void ParentRenamed(const std::string &osNewParentFullName);
650
    //! @endcond
651
};
652
653
/* ******************************************************************** */
654
/*                              GDALRawResult                           */
655
/* ******************************************************************** */
656
657
/**
658
 * Store the raw result of an attribute value, which might contain dynamically
659
 * allocated structures (like pointer to strings).
660
 *
661
 * @since GDAL 3.1
662
 */
663
class CPL_DLL GDALRawResult
664
{
665
  private:
666
    GDALExtendedDataType m_dt;
667
    size_t m_nEltCount;
668
    size_t m_nSize;
669
    GByte *m_raw;
670
671
    void FreeMe();
672
673
    GDALRawResult(const GDALRawResult &) = delete;
674
    GDALRawResult &operator=(const GDALRawResult &) = delete;
675
676
  protected:
677
    friend class GDALAttribute;
678
    //! @cond Doxygen_Suppress
679
    GDALRawResult(GByte *raw, const GDALExtendedDataType &dt, size_t nEltCount);
680
    //! @endcond
681
682
  public:
683
    ~GDALRawResult();
684
    GDALRawResult(GDALRawResult &&);
685
    GDALRawResult &operator=(GDALRawResult &&);
686
687
    /** Return byte at specified index. */
688
    const GByte &operator[](size_t idx) const
689
0
    {
690
0
        return m_raw[idx];
691
0
    }
692
693
    /** Return pointer to the start of data. */
694
    const GByte *data() const
695
0
    {
696
0
        return m_raw;
697
0
    }
698
699
    /** Return the size in bytes of the raw result. */
700
    size_t size() const
701
0
    {
702
0
        return m_nSize;
703
0
    }
704
705
    //! @cond Doxygen_Suppress
706
    GByte *StealData();
707
    //! @endcond
708
};
709
710
/* ******************************************************************** */
711
/*                              GDALAttribute                           */
712
/* ******************************************************************** */
713
714
/* clang-format off */
715
/**
716
 * Class modeling an attribute that has a name, a value and a type, and is
717
 * typically used to describe a metadata item. The value can be (for the
718
 * HDF5 format) in the general case a multidimensional array of "any" type
719
 * (in most cases, this will be a single value of string or numeric type)
720
 *
721
 * This is based on the <a href="https://portal.opengeospatial.org/files/81716#_hdf5_attribute">HDF5
722
 * attribute concept</a>
723
 *
724
 * @since GDAL 3.1
725
 */
726
/* clang-format on */
727
728
class CPL_DLL GDALAttribute : virtual public GDALAbstractMDArray
729
{
730
    mutable std::string m_osCachedVal{};
731
732
  protected:
733
    //! @cond Doxygen_Suppress
734
    GDALAttribute(const std::string &osParentName, const std::string &osName);
735
    //! @endcond
736
737
  public:
738
    //! @cond Doxygen_Suppress
739
    ~GDALAttribute() override;
740
    //! @endcond
741
742
    std::vector<GUInt64> GetDimensionsSize() const;
743
744
    GDALRawResult ReadAsRaw() const;
745
    const char *ReadAsString() const;
746
    int ReadAsInt() const;
747
    int64_t ReadAsInt64() const;
748
    double ReadAsDouble() const;
749
    CPLStringList ReadAsStringArray() const;
750
    std::vector<int> ReadAsIntArray() const;
751
    std::vector<int64_t> ReadAsInt64Array() const;
752
    std::vector<double> ReadAsDoubleArray() const;
753
754
    using GDALAbstractMDArray::Write;
755
    bool Write(const void *pabyValue, size_t nLen);
756
    bool Write(const char *);
757
    bool WriteInt(int);
758
    bool WriteInt64(int64_t);
759
    bool Write(double);
760
    bool Write(CSLConstList);
761
    bool Write(const int *, size_t);
762
    bool Write(const int64_t *, size_t);
763
    bool Write(const double *, size_t);
764
765
    //! @cond Doxygen_Suppress
766
    static constexpr GUInt64 COPY_COST = 100;
767
    //! @endcond
768
};
769
770
/************************************************************************/
771
/*                            GDALAttributeString                       */
772
/************************************************************************/
773
774
//! @cond Doxygen_Suppress
775
class CPL_DLL GDALAttributeString final : public GDALAttribute
776
{
777
    std::vector<std::shared_ptr<GDALDimension>> m_dims{};
778
    GDALExtendedDataType m_dt = GDALExtendedDataType::CreateString();
779
    std::string m_osValue;
780
781
  protected:
782
    bool IRead(const GUInt64 *, const size_t *, const GInt64 *,
783
               const GPtrDiff_t *, const GDALExtendedDataType &bufferDataType,
784
               void *pDstBuffer) const override;
785
786
  public:
787
    GDALAttributeString(const std::string &osParentName,
788
                        const std::string &osName, const std::string &osValue,
789
                        GDALExtendedDataTypeSubType eSubType = GEDTST_NONE);
790
791
    const std::vector<std::shared_ptr<GDALDimension>> &
792
    GetDimensions() const override;
793
794
    const GDALExtendedDataType &GetDataType() const override;
795
};
796
797
//! @endcond
798
799
/************************************************************************/
800
/*                           GDALAttributeNumeric                       */
801
/************************************************************************/
802
803
//! @cond Doxygen_Suppress
804
class CPL_DLL GDALAttributeNumeric final : public GDALAttribute
805
{
806
    std::vector<std::shared_ptr<GDALDimension>> m_dims{};
807
    GDALExtendedDataType m_dt;
808
    int m_nValue = 0;
809
    double m_dfValue = 0;
810
    std::vector<GUInt32> m_anValuesUInt32{};
811
812
  protected:
813
    bool IRead(const GUInt64 *, const size_t *, const GInt64 *,
814
               const GPtrDiff_t *, const GDALExtendedDataType &bufferDataType,
815
               void *pDstBuffer) const override;
816
817
  public:
818
    GDALAttributeNumeric(const std::string &osParentName,
819
                         const std::string &osName, double dfValue);
820
    GDALAttributeNumeric(const std::string &osParentName,
821
                         const std::string &osName, int nValue);
822
    GDALAttributeNumeric(const std::string &osParentName,
823
                         const std::string &osName,
824
                         const std::vector<GUInt32> &anValues);
825
826
    const std::vector<std::shared_ptr<GDALDimension>> &
827
    GetDimensions() const override;
828
829
    const GDALExtendedDataType &GetDataType() const override;
830
};
831
832
//! @endcond
833
834
/* ******************************************************************** */
835
/*                              GDALMDArray                             */
836
/* ******************************************************************** */
837
838
/* clang-format off */
839
/**
840
 * Class modeling a multi-dimensional array. It has a name, values organized
841
 * as an array and a list of GDALAttribute.
842
 *
843
 * This is based on the <a href="https://portal.opengeospatial.org/files/81716#_hdf5_dataset">HDF5
844
 * dataset concept</a>
845
 *
846
 * @since GDAL 3.1
847
 */
848
/* clang-format on */
849
850
class CPL_DLL GDALMDArray : virtual public GDALAbstractMDArray,
851
                            public GDALIHasAttribute
852
{
853
    friend class GDALMDArrayResampled;
854
    std::shared_ptr<GDALMDArray>
855
    GetView(const std::vector<GUInt64> &indices) const;
856
857
    inline std::shared_ptr<GDALMDArray>
858
    atInternal(const std::vector<GUInt64> &indices) const
859
0
    {
860
0
        return GetView(indices);
861
0
    }
862
863
    template <typename... GUInt64VarArg>
864
    // cppcheck-suppress functionStatic
865
    inline std::shared_ptr<GDALMDArray>
866
    atInternal(std::vector<GUInt64> &indices, GUInt64 idx,
867
               GUInt64VarArg... tail) const
868
    {
869
        indices.push_back(idx);
870
        return atInternal(indices, tail...);
871
    }
872
873
    // Used for example by GDALSubsetGroup to distinguish a derived group
874
    //from its original, without altering its name
875
    const std::string m_osContext{};
876
877
    mutable bool m_bHasTriedCachedArray = false;
878
    mutable std::shared_ptr<GDALMDArray> m_poCachedArray{};
879
880
  protected:
881
    //! @cond Doxygen_Suppress
882
    GDALMDArray(const std::string &osParentName, const std::string &osName,
883
                const std::string &osContext = std::string());
884
885
    virtual bool IAdviseRead(const GUInt64 *arrayStartIdx, const size_t *count,
886
                             CSLConstList papszOptions) const;
887
888
    virtual bool IsCacheable() const
889
0
    {
890
0
        return true;
891
0
    }
892
893
    virtual bool SetStatistics(bool bApproxStats, double dfMin, double dfMax,
894
                               double dfMean, double dfStdDev,
895
                               GUInt64 nValidCount, CSLConstList papszOptions);
896
897
    static std::string MassageName(const std::string &inputName);
898
899
    std::shared_ptr<GDALGroup>
900
    GetCacheRootGroup(bool bCanCreate, std::string &osCacheFilenameOut) const;
901
902
    // Returns if bufferStride values express a transposed view of the array
903
    bool IsTransposedRequest(const size_t *count,
904
                             const GPtrDiff_t *bufferStride) const;
905
906
    // Should only be called if IsTransposedRequest() returns true
907
    bool ReadForTransposedRequest(const GUInt64 *arrayStartIdx,
908
                                  const size_t *count, const GInt64 *arrayStep,
909
                                  const GPtrDiff_t *bufferStride,
910
                                  const GDALExtendedDataType &bufferDataType,
911
                                  void *pDstBuffer) const;
912
913
    bool IsStepOneContiguousRowMajorOrderedSameDataType(
914
        const size_t *count, const GInt64 *arrayStep,
915
        const GPtrDiff_t *bufferStride,
916
        const GDALExtendedDataType &bufferDataType) const;
917
918
    // Should only be called if IsStepOneContiguousRowMajorOrderedSameDataType()
919
    // returns false
920
    bool ReadUsingContiguousIRead(const GUInt64 *arrayStartIdx,
921
                                  const size_t *count, const GInt64 *arrayStep,
922
                                  const GPtrDiff_t *bufferStride,
923
                                  const GDALExtendedDataType &bufferDataType,
924
                                  void *pDstBuffer) const;
925
926
    static std::shared_ptr<GDALMDArray> CreateGLTOrthorectified(
927
        const std::shared_ptr<GDALMDArray> &poParent,
928
        const std::shared_ptr<GDALGroup> &poRootGroup,
929
        const std::shared_ptr<GDALMDArray> &poGLTX,
930
        const std::shared_ptr<GDALMDArray> &poGLTY, int nGLTIndexOffset,
931
        const std::vector<double> &adfGeoTransform, CSLConstList papszOptions);
932
933
    //! @endcond
934
935
  public:
936
    GUInt64 GetTotalCopyCost() const;
937
938
    virtual bool CopyFrom(GDALDataset *poSrcDS, const GDALMDArray *poSrcArray,
939
                          bool bStrict, GUInt64 &nCurCost,
940
                          const GUInt64 nTotalCost,
941
                          GDALProgressFunc pfnProgress, void *pProgressData);
942
943
    /** Return whether an array is writable. */
944
    virtual bool IsWritable() const = 0;
945
946
    /** Return the filename that contains that array.
947
     *
948
     * This is used in particular for caching.
949
     *
950
     * Might be empty if the array is not linked to a file.
951
     *
952
     * @since GDAL 3.4
953
     */
954
    virtual const std::string &GetFilename() const = 0;
955
956
    virtual CSLConstList GetStructuralInfo() const;
957
958
    virtual const std::string &GetUnit() const;
959
960
    virtual bool SetUnit(const std::string &osUnit);
961
962
    virtual bool SetSpatialRef(const OGRSpatialReference *poSRS);
963
964
    virtual std::shared_ptr<OGRSpatialReference> GetSpatialRef() const;
965
966
    virtual const void *GetRawNoDataValue() const;
967
968
    double GetNoDataValueAsDouble(bool *pbHasNoData = nullptr) const;
969
970
    int64_t GetNoDataValueAsInt64(bool *pbHasNoData = nullptr) const;
971
972
    uint64_t GetNoDataValueAsUInt64(bool *pbHasNoData = nullptr) const;
973
974
    virtual bool SetRawNoDataValue(const void *pRawNoData);
975
976
    //! @cond Doxygen_Suppress
977
    bool SetNoDataValue(int nNoData)
978
0
    {
979
0
        return SetNoDataValue(static_cast<int64_t>(nNoData));
980
0
    }
981
982
    //! @endcond
983
984
    bool SetNoDataValue(double dfNoData);
985
986
    bool SetNoDataValue(int64_t nNoData);
987
988
    bool SetNoDataValue(uint64_t nNoData);
989
990
    virtual bool Resize(const std::vector<GUInt64> &anNewDimSizes,
991
                        CSLConstList papszOptions);
992
993
    virtual double GetOffset(bool *pbHasOffset = nullptr,
994
                             GDALDataType *peStorageType = nullptr) const;
995
996
    virtual double GetScale(bool *pbHasScale = nullptr,
997
                            GDALDataType *peStorageType = nullptr) const;
998
999
    virtual bool SetOffset(double dfOffset,
1000
                           GDALDataType eStorageType = GDT_Unknown);
1001
1002
    virtual bool SetScale(double dfScale,
1003
                          GDALDataType eStorageType = GDT_Unknown);
1004
1005
    std::shared_ptr<GDALMDArray> GetView(const std::string &viewExpr) const;
1006
1007
    std::shared_ptr<GDALMDArray> operator[](const std::string &fieldName) const;
1008
1009
    /** Return a view of the array using integer indexing.
1010
     *
1011
     * Equivalent of GetView("[indices_0,indices_1,.....,indices_last]")
1012
     *
1013
     * Example:
1014
     * \code
1015
     * ar->at(0,3,2)
1016
     * \endcode
1017
     */
1018
    // sphinx 4.1.0 / breathe 4.30.0 don't like typename...
1019
    //! @cond Doxygen_Suppress
1020
    template <typename... GUInt64VarArg>
1021
    //! @endcond
1022
    // cppcheck-suppress functionStatic
1023
    std::shared_ptr<GDALMDArray> at(GUInt64 idx, GUInt64VarArg... tail) const
1024
    {
1025
        std::vector<GUInt64> indices;
1026
        indices.push_back(idx);
1027
        return atInternal(indices, tail...);
1028
    }
1029
1030
    virtual std::shared_ptr<GDALMDArray>
1031
    Transpose(const std::vector<int> &anMapNewAxisToOldAxis) const;
1032
1033
    std::shared_ptr<GDALMDArray> GetUnscaled(
1034
        double dfOverriddenScale = std::numeric_limits<double>::quiet_NaN(),
1035
        double dfOverriddenOffset = std::numeric_limits<double>::quiet_NaN(),
1036
        double dfOverriddenDstNodata =
1037
            std::numeric_limits<double>::quiet_NaN()) const;
1038
1039
    virtual std::shared_ptr<GDALMDArray>
1040
    GetMask(CSLConstList papszOptions) const;
1041
1042
    virtual std::shared_ptr<GDALMDArray>
1043
    GetResampled(const std::vector<std::shared_ptr<GDALDimension>> &apoNewDims,
1044
                 GDALRIOResampleAlg resampleAlg,
1045
                 const OGRSpatialReference *poTargetSRS,
1046
                 CSLConstList papszOptions) const;
1047
1048
    std::shared_ptr<GDALMDArray>
1049
    GetGridded(const std::string &osGridOptions,
1050
               const std::shared_ptr<GDALMDArray> &poXArray = nullptr,
1051
               const std::shared_ptr<GDALMDArray> &poYArray = nullptr,
1052
               CSLConstList papszOptions = nullptr) const;
1053
1054
    static std::vector<std::shared_ptr<GDALMDArray>>
1055
    GetMeshGrid(const std::vector<std::shared_ptr<GDALMDArray>> &apoArrays,
1056
                CSLConstList papszOptions = nullptr);
1057
1058
    virtual GDALDataset *
1059
    AsClassicDataset(size_t iXDim, size_t iYDim,
1060
                     const std::shared_ptr<GDALGroup> &poRootGroup = nullptr,
1061
                     CSLConstList papszOptions = nullptr) const;
1062
1063
    virtual CPLErr GetStatistics(bool bApproxOK, bool bForce, double *pdfMin,
1064
                                 double *pdfMax, double *pdfMean,
1065
                                 double *padfStdDev, GUInt64 *pnValidCount,
1066
                                 GDALProgressFunc pfnProgress,
1067
                                 void *pProgressData);
1068
1069
    virtual bool ComputeStatistics(bool bApproxOK, double *pdfMin,
1070
                                   double *pdfMax, double *pdfMean,
1071
                                   double *pdfStdDev, GUInt64 *pnValidCount,
1072
                                   GDALProgressFunc, void *pProgressData,
1073
                                   CSLConstList papszOptions);
1074
1075
    virtual void ClearStatistics();
1076
1077
    virtual std::vector<std::shared_ptr<GDALMDArray>>
1078
    GetCoordinateVariables() const;
1079
1080
    bool AdviseRead(const GUInt64 *arrayStartIdx, const size_t *count,
1081
                    CSLConstList papszOptions = nullptr) const;
1082
1083
    bool IsRegularlySpaced(double &dfStart, double &dfIncrement) const;
1084
1085
    bool GuessGeoTransform(size_t nDimX, size_t nDimY, bool bPixelIsPoint,
1086
                           GDALGeoTransform &gt) const;
1087
1088
    bool GuessGeoTransform(size_t nDimX, size_t nDimY, bool bPixelIsPoint,
1089
                           double adfGeoTransform[6]) const;
1090
1091
    bool Cache(CSLConstList papszOptions = nullptr) const;
1092
1093
    bool
1094
    Read(const GUInt64 *arrayStartIdx,    // array of size GetDimensionCount()
1095
         const size_t *count,             // array of size GetDimensionCount()
1096
         const GInt64 *arrayStep,         // step in elements
1097
         const GPtrDiff_t *bufferStride,  // stride in elements
1098
         const GDALExtendedDataType &bufferDataType, void *pDstBuffer,
1099
         const void *pDstBufferAllocStart = nullptr,
1100
         size_t nDstBufferAllocSize = 0) const override final;
1101
1102
    virtual std::shared_ptr<GDALGroup> GetRootGroup() const;
1103
1104
    virtual bool GetRawBlockInfo(const uint64_t *panBlockCoordinates,
1105
                                 GDALMDArrayRawBlockInfo &info) const;
1106
1107
    //! @cond Doxygen_Suppress
1108
    static constexpr GUInt64 COPY_COST = 1000;
1109
1110
    bool CopyFromAllExceptValues(const GDALMDArray *poSrcArray, bool bStrict,
1111
                                 GUInt64 &nCurCost, const GUInt64 nTotalCost,
1112
                                 GDALProgressFunc pfnProgress,
1113
                                 void *pProgressData);
1114
1115
    struct Range
1116
    {
1117
        GUInt64 m_nStartIdx;
1118
        GInt64 m_nIncr;
1119
1120
        explicit Range(GUInt64 nStartIdx = 0, GInt64 nIncr = 0)
1121
0
            : m_nStartIdx(nStartIdx), m_nIncr(nIncr)
1122
0
        {
1123
0
        }
1124
    };
1125
1126
    struct ViewSpec
1127
    {
1128
        std::string m_osFieldName{};
1129
1130
        // or
1131
1132
        std::vector<size_t>
1133
            m_mapDimIdxToParentDimIdx{};  // of size m_dims.size()
1134
        std::vector<Range>
1135
            m_parentRanges{};  // of size m_poParent->GetDimensionCount()
1136
    };
1137
1138
    virtual std::shared_ptr<GDALMDArray>
1139
    GetView(const std::string &viewExpr, bool bRenameDimensions,
1140
            std::vector<ViewSpec> &viewSpecs) const;
1141
1142
    const std::string &GetContext() const
1143
0
    {
1144
0
        return m_osContext;
1145
0
    }
1146
1147
    //! @endcond
1148
};
1149
1150
//! @cond Doxygen_Suppress
1151
bool GDALMDRasterIOFromBand(GDALRasterBand *poBand, GDALRWFlag eRWFlag,
1152
                            size_t iDimX, size_t iDimY,
1153
                            const GUInt64 *arrayStartIdx, const size_t *count,
1154
                            const GInt64 *arrayStep,
1155
                            const GPtrDiff_t *bufferStride,
1156
                            const GDALExtendedDataType &bufferDataType,
1157
                            void *pBuffer);
1158
1159
//! @endcond
1160
1161
/************************************************************************/
1162
/*                     GDALMDArrayRegularlySpaced                       */
1163
/************************************************************************/
1164
1165
//! @cond Doxygen_Suppress
1166
class CPL_DLL GDALMDArrayRegularlySpaced final : public GDALMDArray
1167
{
1168
    double m_dfStart = 0;
1169
    double m_dfIncrement = 0;
1170
    double m_dfOffsetInIncrement = 0;
1171
    const GDALExtendedDataType m_dt = GDALExtendedDataType::Create(GDT_Float64);
1172
    const std::vector<std::shared_ptr<GDALDimension>> m_dims;
1173
    std::vector<std::shared_ptr<GDALAttribute>> m_attributes{};
1174
    const std::string m_osEmptyFilename{};
1175
1176
  protected:
1177
    bool IRead(const GUInt64 *, const size_t *, const GInt64 *,
1178
               const GPtrDiff_t *, const GDALExtendedDataType &bufferDataType,
1179
               void *pDstBuffer) const override;
1180
1181
  public:
1182
    GDALMDArrayRegularlySpaced(const std::string &osParentName,
1183
                               const std::string &osName,
1184
                               const std::shared_ptr<GDALDimension> &poDim,
1185
                               double dfStart, double dfIncrement,
1186
                               double dfOffsetInIncrement);
1187
1188
    static std::shared_ptr<GDALMDArrayRegularlySpaced>
1189
    Create(const std::string &osParentName, const std::string &osName,
1190
           const std::shared_ptr<GDALDimension> &poDim, double dfStart,
1191
           double dfIncrement, double dfOffsetInIncrement);
1192
1193
    bool IsWritable() const override
1194
0
    {
1195
0
        return false;
1196
0
    }
1197
1198
    const std::string &GetFilename() const override
1199
0
    {
1200
0
        return m_osEmptyFilename;
1201
0
    }
1202
1203
    const std::vector<std::shared_ptr<GDALDimension>> &
1204
    GetDimensions() const override;
1205
1206
    const GDALExtendedDataType &GetDataType() const override;
1207
1208
    std::vector<std::shared_ptr<GDALAttribute>>
1209
        GetAttributes(CSLConstList) const override;
1210
1211
    void AddAttribute(const std::shared_ptr<GDALAttribute> &poAttr);
1212
};
1213
1214
//! @endcond
1215
1216
/* ******************************************************************** */
1217
/*                            GDALDimension                             */
1218
/* ******************************************************************** */
1219
1220
/**
1221
 * Class modeling a a dimension / axis used to index multidimensional arrays.
1222
 * It has a name, a size (that is the number of values that can be indexed along
1223
 * the dimension), a type (see GDALDimension::GetType()), a direction
1224
 * (see GDALDimension::GetDirection()), a unit and can optionally point to a
1225
 * GDALMDArray variable, typically one-dimensional, describing the values taken
1226
 * by the dimension. For a georeferenced GDALMDArray and its X dimension, this
1227
 * will be typically the values of the easting/longitude for each grid point.
1228
 *
1229
 * @since GDAL 3.1
1230
 */
1231
class CPL_DLL GDALDimension
1232
{
1233
  public:
1234
    //! @cond Doxygen_Suppress
1235
    GDALDimension(const std::string &osParentName, const std::string &osName,
1236
                  const std::string &osType, const std::string &osDirection,
1237
                  GUInt64 nSize);
1238
    //! @endcond
1239
1240
    virtual ~GDALDimension();
1241
1242
    /** Return the name.
1243
     *
1244
     * This is the same as the C function GDALDimensionGetName()
1245
     */
1246
    const std::string &GetName() const
1247
0
    {
1248
0
        return m_osName;
1249
0
    }
1250
1251
    /** Return the full name.
1252
     *
1253
     * This is the same as the C function GDALDimensionGetFullName()
1254
     */
1255
    const std::string &GetFullName() const
1256
0
    {
1257
0
        return m_osFullName;
1258
0
    }
1259
1260
    /** Return the axis type.
1261
     *
1262
     * Predefined values are:
1263
     * HORIZONTAL_X, HORIZONTAL_Y, VERTICAL, TEMPORAL, PARAMETRIC
1264
     * Other values might be returned. Empty value means unknown.
1265
     *
1266
     * This is the same as the C function GDALDimensionGetType()
1267
     */
1268
    const std::string &GetType() const
1269
0
    {
1270
0
        return m_osType;
1271
0
    }
1272
1273
    /** Return the axis direction.
1274
     *
1275
     * Predefined values are:
1276
     * EAST, WEST, SOUTH, NORTH, UP, DOWN, FUTURE, PAST
1277
     * Other values might be returned. Empty value means unknown.
1278
     *
1279
     * This is the same as the C function GDALDimensionGetDirection()
1280
     */
1281
    const std::string &GetDirection() const
1282
0
    {
1283
0
        return m_osDirection;
1284
0
    }
1285
1286
    /** Return the size, that is the number of values along the dimension.
1287
     *
1288
     * This is the same as the C function GDALDimensionGetSize()
1289
     */
1290
    GUInt64 GetSize() const
1291
0
    {
1292
0
        return m_nSize;
1293
0
    }
1294
1295
    virtual std::shared_ptr<GDALMDArray> GetIndexingVariable() const;
1296
1297
    virtual bool
1298
    SetIndexingVariable(std::shared_ptr<GDALMDArray> poIndexingVariable);
1299
1300
    virtual bool Rename(const std::string &osNewName);
1301
1302
    //! @cond Doxygen_Suppress
1303
    virtual void ParentRenamed(const std::string &osNewParentFullName);
1304
1305
    virtual void ParentDeleted();
1306
    //! @endcond
1307
1308
  protected:
1309
    //! @cond Doxygen_Suppress
1310
    std::string m_osName;
1311
    std::string m_osFullName;
1312
    std::string m_osType;
1313
    std::string m_osDirection;
1314
    GUInt64 m_nSize;
1315
1316
    void BaseRename(const std::string &osNewName);
1317
1318
    //! @endcond
1319
};
1320
1321
/************************************************************************/
1322
/*                   GDALDimensionWeakIndexingVar()                     */
1323
/************************************************************************/
1324
1325
//! @cond Doxygen_Suppress
1326
class CPL_DLL GDALDimensionWeakIndexingVar : public GDALDimension
1327
{
1328
    std::weak_ptr<GDALMDArray> m_poIndexingVariable{};
1329
1330
  public:
1331
    GDALDimensionWeakIndexingVar(const std::string &osParentName,
1332
                                 const std::string &osName,
1333
                                 const std::string &osType,
1334
                                 const std::string &osDirection, GUInt64 nSize);
1335
1336
    std::shared_ptr<GDALMDArray> GetIndexingVariable() const override;
1337
1338
    bool SetIndexingVariable(
1339
        std::shared_ptr<GDALMDArray> poIndexingVariable) override;
1340
1341
    void SetSize(GUInt64 nNewSize);
1342
};
1343
1344
//! @endcond
1345
1346
#endif