LCOV - code coverage report
Current view: top level - apps - gdalalg_mdim_pipeline.h (source / functions) Hit Total Coverage
Test: gdal_filtered.info Lines: 13 21 61.9 %
Date: 2026-06-23 16:35:19 Functions: 16 21 76.2 %

          Line data    Source code
       1             : /******************************************************************************
       2             :  *
       3             :  * Project:  GDAL
       4             :  * Purpose:  gdal "mdim pipeline" subcommand
       5             :  * Author:   Even Rouault <even dot rouault at spatialys.com>
       6             :  *
       7             :  ******************************************************************************
       8             :  * Copyright (c) 2026, Even Rouault <even dot rouault at spatialys.com>
       9             :  *
      10             :  * SPDX-License-Identifier: MIT
      11             :  ****************************************************************************/
      12             : 
      13             : #ifndef GDALALG_MDIM_PIPELINE_INCLUDED
      14             : #define GDALALG_MDIM_PIPELINE_INCLUDED
      15             : 
      16             : #include "gdalalgorithm.h"
      17             : #include "gdalalg_abstract_pipeline.h"
      18             : #include "gdalmdimpipelinestepalgorithm.h"
      19             : 
      20             : //! @cond Doxygen_Suppress
      21             : 
      22             : /************************************************************************/
      23             : /*                    GDALMdimAlgorithmStepRegistry                     */
      24             : /************************************************************************/
      25             : 
      26          53 : class GDALMdimAlgorithmStepRegistry : public virtual GDALAlgorithmRegistry
      27             : {
      28             :   public:
      29          53 :     GDALMdimAlgorithmStepRegistry() = default;
      30             :     ~GDALMdimAlgorithmStepRegistry() override;
      31             : 
      32             :     /** Register the algorithm of type MyAlgorithm.
      33             :      */
      34             :     template <class MyAlgorithm>
      35         318 :     bool Register(const std::string &name = std::string())
      36             :     {
      37             :         static_assert(
      38             :             std::is_base_of_v<GDALMdimPipelineStepAlgorithm, MyAlgorithm>,
      39             :             "Algorithm is not a GDALMdimPipelineStepAlgorithm");
      40             : 
      41         636 :         AlgInfo info;
      42         318 :         info.m_name = name.empty() ? MyAlgorithm::NAME : name;
      43         318 :         info.m_aliases = MyAlgorithm::GetAliasesStatic();
      44         340 :         info.m_creationFunc = []() -> std::unique_ptr<GDALAlgorithm>
      45          22 :         { return std::make_unique<MyAlgorithm>(); };
      46         636 :         return GDALAlgorithmRegistry::Register(info);
      47             :     }
      48             : };
      49             : 
      50             : /************************************************************************/
      51             : /*                      GDALMdimPipelineAlgorithm                       */
      52             : /************************************************************************/
      53             : 
      54             : class GDALMdimPipelineAlgorithm final : public GDALAbstractPipelineAlgorithm
      55             : {
      56             :   public:
      57             :     static constexpr const char *NAME = "pipeline";
      58             :     static constexpr const char *DESCRIPTION =
      59             :         "Process a multidimensional dataset applying several steps.";
      60             :     static constexpr const char *HELP_URL = "/programs/gdal_mdim_pipeline.html";
      61             : 
      62             :     explicit GDALMdimPipelineAlgorithm(bool openForMixedMdimVector = false);
      63             : 
      64             :     std::string GetUsageForCLI(bool shortUsage,
      65             :                                const UsageOptions &usageOptions) const override;
      66             : 
      67             :     static void RegisterAlgorithms(GDALMdimAlgorithmStepRegistry &registry,
      68             :                                    bool forMixedPipeline);
      69             : 
      70          16 :     int GetInputType() const override
      71             :     {
      72          16 :         return GDAL_OF_MULTIDIM_RASTER;
      73             :     }
      74             : 
      75           0 :     int GetOutputType() const override
      76             :     {
      77           0 :         return GDAL_OF_MULTIDIM_RASTER;
      78             :     }
      79             : 
      80             :   protected:
      81             :     GDALMdimAlgorithmStepRegistry m_stepRegistry{};
      82             : 
      83           0 :     GDALAlgorithmRegistry &GetStepRegistry() override
      84             :     {
      85           0 :         return m_stepRegistry;
      86             :     }
      87             : 
      88          24 :     const GDALAlgorithmRegistry &GetStepRegistry() const override
      89             :     {
      90          24 :         return m_stepRegistry;
      91             :     }
      92             : 
      93             :   private:
      94             :     std::unique_ptr<GDALAbstractPipelineAlgorithm>
      95           0 :     CreateNestedPipeline() const override
      96             :     {
      97           0 :         auto pipeline = std::make_unique<GDALMdimPipelineAlgorithm>();
      98           0 :         pipeline->m_bInnerPipeline = true;
      99           0 :         return pipeline;
     100             :     }
     101             : };
     102             : 
     103             : //! @endcond
     104             : 
     105             : #endif

Generated by: LCOV version 1.14