File: gdalalg_tee.cpp

package info (click to toggle)
gdal 3.12.2%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 92,396 kB
  • sloc: cpp: 1,224,305; ansic: 206,456; python: 26,284; java: 6,001; xml: 4,769; sh: 3,869; cs: 2,513; yacc: 1,306; makefile: 214
file content (92 lines) | stat: -rw-r--r-- 3,454 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
/******************************************************************************
 *
 * Project:  GDAL
 * Purpose:  gdal "tee" pipeline step
 * Author:   Even Rouault <even dot rouault at spatialys.com>
 *
 ******************************************************************************
 * Copyright (c) 2025, Even Rouault <even dot rouault at spatialys.com>
 *
 * SPDX-License-Identifier: MIT
 ****************************************************************************/

#include "gdalalg_tee.h"

//! @cond Doxygen_Suppress

/************************************************************************/
/*      GDALTeeStepAlgorithmAbstract::~GDALTeeStepAlgorithmAbstract()   */
/************************************************************************/

GDALTeeStepAlgorithmAbstract::~GDALTeeStepAlgorithmAbstract() = default;

/************************************************************************/
/*        GDALTeeStepAlgorithmAbstract::CopyFilenameBindingsFrom()      */
/************************************************************************/

void GDALTeeStepAlgorithmAbstract::CopyFilenameBindingsFrom(
    const GDALTeeStepAlgorithmAbstract *other)
{
    m_oMapNameToAlg = other->m_oMapNameToAlg;
}

/************************************************************************/
/*              GDALTeeStepAlgorithmAbstract::BindFilename()            */
/************************************************************************/

bool GDALTeeStepAlgorithmAbstract::BindFilename(
    const std::string &filename, GDALAbstractPipelineAlgorithm *alg,
    const std::vector<std::string> &args)
{
    if (cpl::contains(m_oMapNameToAlg, filename))
        return false;
    m_oMapNameToAlg[filename] = std::make_pair(alg, args);
    return true;
}

/************************************************************************/
/*             GDALTeeStepAlgorithmAbstract::HasOutputString()          */
/************************************************************************/

bool GDALTeeStepAlgorithmAbstract::HasOutputString() const
{
    for (const auto &oIter : m_oMapNameToAlg)
    {
        const auto &pipelineAlg = oIter.second.first;
        if (pipelineAlg->HasSteps())
        {
            if (pipelineAlg->HasOutputString())
                return true;
        }
        else
        {
            // Before the tee pipeline has been constructed by
            // GDALTeeStepAlgorithmBase::RunStep(), there is no clean way
            // of knowing if a (future) inner step will have an output string
            // argument, so try to instantiate a step alg from each pipeline
            // token and call HasOutputString() on it.
            const auto &pipelineArgs = oIter.second.second;
            for (const auto &arg : pipelineArgs)
            {
                auto alg = pipelineAlg->GetStepAlg(arg);
                if (!alg)
                {
                    alg = pipelineAlg->GetStepAlg(
                        arg + GDALAbstractPipelineAlgorithm::RASTER_SUFFIX);
                    if (!alg)
                        alg = pipelineAlg->GetStepAlg(
                            arg + GDALAbstractPipelineAlgorithm::VECTOR_SUFFIX);
                }
                if (alg && alg->HasOutputString())
                    return true;
            }
        }
    }
    return false;
}

GDALTeeRasterAlgorithm::~GDALTeeRasterAlgorithm() = default;

GDALTeeVectorAlgorithm::~GDALTeeVectorAlgorithm() = default;

//! @endcond