Line data Source code
1 : /****************************************************************************** 2 : * Name: gdalmultidim_priv.h 3 : * Project: GDAL Core 4 : * Purpose: GDAL private header for multidimensional support 5 : * Author: Even Rouault <even.rouault at spatialys.com> 6 : * 7 : ****************************************************************************** 8 : * Copyright (c) 2023, Even Rouault <even.rouault at spatialys.com> 9 : * 10 : * SPDX-License-Identifier: MIT 11 : ****************************************************************************/ 12 : 13 : #ifndef GDALMULTIDIM_PRIV_INCLUDED 14 : #define GDALMULTIDIM_PRIV_INCLUDED 15 : 16 : #include "gdal_priv.h" 17 : 18 : //! @cond Doxygen_Suppress 19 : 20 : // For C API 21 : 22 : struct GDALExtendedDataTypeHS 23 : { 24 : std::unique_ptr<GDALExtendedDataType> m_poImpl; 25 : 26 6705 : explicit GDALExtendedDataTypeHS(GDALExtendedDataType *dt) : m_poImpl(dt) 27 : { 28 6705 : } 29 : }; 30 : 31 : struct GDALEDTComponentHS 32 : { 33 : std::unique_ptr<GDALEDTComponent> m_poImpl; 34 : 35 107 : explicit GDALEDTComponentHS(const GDALEDTComponent &component) 36 107 : : m_poImpl(new GDALEDTComponent(component)) 37 : { 38 107 : } 39 : }; 40 : 41 : struct GDALGroupHS 42 : { 43 : std::shared_ptr<GDALGroup> m_poImpl; 44 : 45 1459 : explicit GDALGroupHS(const std::shared_ptr<GDALGroup> &poGroup) 46 1459 : : m_poImpl(poGroup) 47 : { 48 1459 : } 49 : }; 50 : 51 : struct GDALMDArrayHS 52 : { 53 : std::shared_ptr<GDALMDArray> m_poImpl; 54 : 55 2060 : explicit GDALMDArrayHS(const std::shared_ptr<GDALMDArray> &poArray) 56 2060 : : m_poImpl(poArray) 57 : { 58 2061 : } 59 : }; 60 : 61 : struct GDALAttributeHS 62 : { 63 : std::shared_ptr<GDALAttribute> m_poImpl; 64 : 65 739 : explicit GDALAttributeHS(const std::shared_ptr<GDALAttribute> &poAttr) 66 739 : : m_poImpl(poAttr) 67 : { 68 739 : } 69 : }; 70 : 71 : struct GDALDimensionHS 72 : { 73 : std::shared_ptr<GDALDimension> m_poImpl; 74 : 75 5065 : explicit GDALDimensionHS(const std::shared_ptr<GDALDimension> &poDim) 76 5065 : : m_poImpl(poDim) 77 : { 78 5065 : } 79 : }; 80 : 81 : class GDALMDIAsAttribute final : public GDALAttribute 82 : { 83 : std::vector<std::shared_ptr<GDALDimension>> m_dims{}; 84 : const GDALExtendedDataType m_dt = GDALExtendedDataType::CreateString(); 85 : std::string m_osValue; 86 : 87 : public: 88 9 : GDALMDIAsAttribute(const std::string &name, const std::string &value) 89 9 : : GDALAbstractMDArray(std::string(), name), 90 18 : GDALAttribute(std::string(), name), m_osValue(value) 91 : { 92 9 : } 93 : 94 : const std::vector<std::shared_ptr<GDALDimension>> & 95 : GetDimensions() const override; 96 : 97 15 : const GDALExtendedDataType &GetDataType() const override 98 : { 99 15 : return m_dt; 100 : } 101 : 102 7 : bool IRead(const GUInt64 *, const size_t *, const GInt64 *, 103 : const GPtrDiff_t *, const GDALExtendedDataType &bufferDataType, 104 : void *pDstBuffer) const override 105 : { 106 7 : const char *pszStr = m_osValue.c_str(); 107 7 : GDALExtendedDataType::CopyValue(&pszStr, m_dt, pDstBuffer, 108 : bufferDataType); 109 7 : return true; 110 : } 111 : }; 112 : 113 : //! @endcond 114 : 115 : #endif // GDALMULTIDIM_PRIV_INCLUDED