Coverage Report

Created: 2026-02-14 09:00

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/gdal/apps/gdalalg_tee.cpp
Line
Count
Source
1
/******************************************************************************
2
 *
3
 * Project:  GDAL
4
 * Purpose:  gdal "tee" pipeline step
5
 * Author:   Even Rouault <even dot rouault at spatialys.com>
6
 *
7
 ******************************************************************************
8
 * Copyright (c) 2025, Even Rouault <even dot rouault at spatialys.com>
9
 *
10
 * SPDX-License-Identifier: MIT
11
 ****************************************************************************/
12
13
#include "gdalalg_tee.h"
14
15
//! @cond Doxygen_Suppress
16
17
/************************************************************************/
18
/*    GDALTeeStepAlgorithmAbstract::~GDALTeeStepAlgorithmAbstract()     */
19
/************************************************************************/
20
21
0
GDALTeeStepAlgorithmAbstract::~GDALTeeStepAlgorithmAbstract() = default;
22
23
/************************************************************************/
24
/*       GDALTeeStepAlgorithmAbstract::CopyFilenameBindingsFrom()       */
25
/************************************************************************/
26
27
void GDALTeeStepAlgorithmAbstract::CopyFilenameBindingsFrom(
28
    const GDALTeeStepAlgorithmAbstract *other)
29
0
{
30
0
    m_oMapNameToAlg = other->m_oMapNameToAlg;
31
0
}
32
33
/************************************************************************/
34
/*             GDALTeeStepAlgorithmAbstract::BindFilename()             */
35
/************************************************************************/
36
37
bool GDALTeeStepAlgorithmAbstract::BindFilename(
38
    const std::string &filename, GDALAbstractPipelineAlgorithm *alg,
39
    const std::vector<std::string> &args)
40
0
{
41
0
    if (cpl::contains(m_oMapNameToAlg, filename))
42
0
        return false;
43
0
    m_oMapNameToAlg[filename] = std::make_pair(alg, args);
44
0
    return true;
45
0
}
46
47
/************************************************************************/
48
/*           GDALTeeStepAlgorithmAbstract::HasOutputString()            */
49
/************************************************************************/
50
51
bool GDALTeeStepAlgorithmAbstract::HasOutputString() const
52
0
{
53
0
    for (const auto &oIter : m_oMapNameToAlg)
54
0
    {
55
0
        const auto &pipelineAlg = oIter.second.first;
56
0
        if (pipelineAlg->HasSteps())
57
0
        {
58
0
            if (pipelineAlg->HasOutputString())
59
0
                return true;
60
0
        }
61
0
        else
62
0
        {
63
            // Before the tee pipeline has been constructed by
64
            // GDALTeeStepAlgorithmBase::RunStep(), there is no clean way
65
            // of knowing if a (future) inner step will have an output string
66
            // argument, so try to instantiate a step alg from each pipeline
67
            // token and call HasOutputString() on it.
68
0
            const auto &pipelineArgs = oIter.second.second;
69
0
            for (const auto &arg : pipelineArgs)
70
0
            {
71
0
                auto alg = pipelineAlg->GetStepAlg(arg);
72
0
                if (!alg)
73
0
                {
74
0
                    alg = pipelineAlg->GetStepAlg(
75
0
                        arg + GDALAbstractPipelineAlgorithm::RASTER_SUFFIX);
76
0
                    if (!alg)
77
0
                        alg = pipelineAlg->GetStepAlg(
78
0
                            arg + GDALAbstractPipelineAlgorithm::VECTOR_SUFFIX);
79
0
                }
80
0
                if (alg && alg->HasOutputString())
81
0
                    return true;
82
0
            }
83
0
        }
84
0
    }
85
0
    return false;
86
0
}
87
88
0
GDALTeeRasterAlgorithm::~GDALTeeRasterAlgorithm() = default;
89
90
0
GDALTeeVectorAlgorithm::~GDALTeeVectorAlgorithm() = default;
91
92
//! @endcond