LCOV - code coverage report
Current view: top level - gcore/multidim - gdalmultidim_dimension.cpp (source / functions) Hit Total Coverage
Test: gdal_filtered.info Lines: 35 38 92.1 %
Date: 2026-04-15 22:10:00 Functions: 10 11 90.9 %

          Line data    Source code
       1             : /******************************************************************************
       2             :  *
       3             :  * Name:     gdalmultidim.cpp
       4             :  * Project:  GDAL Core
       5             :  * Purpose:  GDAL Core C++/Private implementation 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             : #include "gdal_multidim.h"
      15             : 
      16             : /************************************************************************/
      17             : /*                           ~GDALDimension()                           */
      18             : /************************************************************************/
      19             : 
      20             : GDALDimension::~GDALDimension() = default;
      21             : 
      22             : /************************************************************************/
      23             : /*                           GDALDimension()                            */
      24             : /************************************************************************/
      25             : 
      26             : //! @cond Doxygen_Suppress
      27             : /** Constructor.
      28             :  *
      29             :  * @param osParentName Parent name
      30             :  * @param osName name
      31             :  * @param osType type. See GetType().
      32             :  * @param osDirection direction. See GetDirection().
      33             :  * @param nSize size.
      34             :  */
      35       13348 : GDALDimension::GDALDimension(const std::string &osParentName,
      36             :                              const std::string &osName,
      37             :                              const std::string &osType,
      38       13348 :                              const std::string &osDirection, GUInt64 nSize)
      39             :     : m_osName(osName),
      40             :       m_osFullName(
      41       13348 :           !osParentName.empty()
      42       18621 :               ? ((osParentName == "/" ? "/" : osParentName + "/") + osName)
      43             :               : osName),
      44       45317 :       m_osType(osType), m_osDirection(osDirection), m_nSize(nSize)
      45             : {
      46       13348 : }
      47             : 
      48             : //! @endcond
      49             : 
      50             : /************************************************************************/
      51             : /*                        GetIndexingVariable()                         */
      52             : /************************************************************************/
      53             : 
      54             : /** Return the variable that is used to index the dimension (if there is one).
      55             :  *
      56             :  * This is the array, typically one-dimensional, describing the values taken
      57             :  * by the dimension.
      58             :  */
      59         117 : std::shared_ptr<GDALMDArray> GDALDimension::GetIndexingVariable() const
      60             : {
      61         117 :     return nullptr;
      62             : }
      63             : 
      64             : /************************************************************************/
      65             : /*                        SetIndexingVariable()                         */
      66             : /************************************************************************/
      67             : 
      68             : /** Set the variable that is used to index the dimension.
      69             :  *
      70             :  * This is the array, typically one-dimensional, describing the values taken
      71             :  * by the dimension.
      72             :  *
      73             :  * Optionally implemented by drivers.
      74             :  *
      75             :  * Drivers known to implement it: MEM.
      76             :  *
      77             :  * @param poArray Variable to use to index the dimension.
      78             :  * @return true in case of success.
      79             :  */
      80          11 : bool GDALDimension::SetIndexingVariable(
      81             :     CPL_UNUSED std::shared_ptr<GDALMDArray> poArray)
      82             : {
      83          11 :     CPLError(CE_Failure, CPLE_NotSupported,
      84             :              "SetIndexingVariable() not implemented");
      85          11 :     return false;
      86             : }
      87             : 
      88             : /************************************************************************/
      89             : /*                               Rename()                               */
      90             : /************************************************************************/
      91             : 
      92             : /** Rename the dimension.
      93             :  *
      94             :  * This is not implemented by all drivers.
      95             :  *
      96             :  * Drivers known to implement it: MEM, netCDF, ZARR.
      97             :  *
      98             :  * This is the same as the C function GDALDimensionRename().
      99             :  *
     100             :  * @param osNewName New name.
     101             :  *
     102             :  * @return true in case of success
     103             :  * @since GDAL 3.8
     104             :  */
     105           0 : bool GDALDimension::Rename(CPL_UNUSED const std::string &osNewName)
     106             : {
     107           0 :     CPLError(CE_Failure, CPLE_NotSupported, "Rename() not implemented");
     108           0 :     return false;
     109             : }
     110             : 
     111             : /************************************************************************/
     112             : /*                             BaseRename()                             */
     113             : /************************************************************************/
     114             : 
     115             : //! @cond Doxygen_Suppress
     116           8 : void GDALDimension::BaseRename(const std::string &osNewName)
     117             : {
     118           8 :     m_osFullName.resize(m_osFullName.size() - m_osName.size());
     119           8 :     m_osFullName += osNewName;
     120           8 :     m_osName = osNewName;
     121           8 : }
     122             : 
     123             : /************************************************************************/
     124             : /*                           ParentDeleted()                            */
     125             : /************************************************************************/
     126             : 
     127           8 : void GDALDimension::ParentDeleted()
     128             : {
     129           8 : }
     130             : 
     131             : /************************************************************************/
     132             : /*                           ParentRenamed()                            */
     133             : /************************************************************************/
     134             : 
     135           8 : void GDALDimension::ParentRenamed(const std::string &osNewParentFullName)
     136             : {
     137           8 :     m_osFullName = osNewParentFullName;
     138           8 :     m_osFullName += "/";
     139           8 :     m_osFullName += m_osName;
     140           8 : }
     141             : 
     142          33 : void GDALDimensionWeakIndexingVar::SetSize(GUInt64 nNewSize)
     143             : {
     144          33 :     m_nSize = nNewSize;
     145          33 : }
     146             : 
     147        6929 : GDALDimensionWeakIndexingVar::GDALDimensionWeakIndexingVar(
     148             :     const std::string &osParentName, const std::string &osName,
     149        6929 :     const std::string &osType, const std::string &osDirection, GUInt64 nSize)
     150        6929 :     : GDALDimension(osParentName, osName, osType, osDirection, nSize)
     151             : {
     152        6929 : }
     153             : 
     154             : std::shared_ptr<GDALMDArray>
     155        2286 : GDALDimensionWeakIndexingVar::GetIndexingVariable() const
     156             : {
     157        2286 :     return m_poIndexingVariable.lock();
     158             : }
     159             : 
     160             : // cppcheck-suppress passedByValue
     161         984 : bool GDALDimensionWeakIndexingVar::SetIndexingVariable(
     162             :     std::shared_ptr<GDALMDArray> poIndexingVariable)
     163             : {
     164         984 :     m_poIndexingVariable = poIndexingVariable;
     165         984 :     return true;
     166             : }
     167             : 
     168             : //! @endcond

Generated by: LCOV version 1.14