/src/gdal/apps/gdalalg_pipeline.h
Line | Count | Source |
1 | | /****************************************************************************** |
2 | | * |
3 | | * Project: GDAL |
4 | | * Purpose: gdal "pipeline" subcommand |
5 | | * Author: Even Rouault <even dot rouault at spatialys.com> |
6 | | * |
7 | | ****************************************************************************** |
8 | | * Copyright (c) 2024, Even Rouault <even dot rouault at spatialys.com> |
9 | | * |
10 | | * SPDX-License-Identifier: MIT |
11 | | ****************************************************************************/ |
12 | | |
13 | | #ifndef GDALALG_PIPELINE_INCLUDED |
14 | | #define GDALALG_PIPELINE_INCLUDED |
15 | | |
16 | | //! @cond Doxygen_Suppress |
17 | | |
18 | | #include "gdalalg_abstract_pipeline.h" |
19 | | #include "gdalalg_raster_pipeline.h" |
20 | | #include "gdalalg_vector_pipeline.h" |
21 | | |
22 | | /************************************************************************/ |
23 | | /* GDALAlgorithmStepRegistry */ |
24 | | /************************************************************************/ |
25 | | |
26 | | class GDALAlgorithmStepRegistry final : public GDALRasterAlgorithmStepRegistry, |
27 | | public GDALVectorAlgorithmStepRegistry |
28 | | { |
29 | | public: |
30 | 0 | GDALAlgorithmStepRegistry() = default; |
31 | | ~GDALAlgorithmStepRegistry() override; |
32 | | |
33 | | /** Register the algorithm of type MyAlgorithm. |
34 | | */ |
35 | | template <class MyAlgorithm> |
36 | | bool Register(const std::string &name = std::string()) |
37 | 0 | { |
38 | 0 | static_assert(std::is_base_of_v<GDALPipelineStepAlgorithm, MyAlgorithm>, |
39 | 0 | "Algorithm is not a GDALPipelineStepAlgorithm"); |
40 | |
|
41 | 0 | AlgInfo info; |
42 | 0 | info.m_name = name.empty() ? MyAlgorithm::NAME : name; |
43 | 0 | info.m_aliases = MyAlgorithm::GetAliasesStatic(); |
44 | 0 | info.m_creationFunc = []() -> std::unique_ptr<GDALAlgorithm> |
45 | 0 | { return std::make_unique<MyAlgorithm>(); };Unexecuted instantiation: GDALAlgorithmStepRegistry::Register<GDALRasterAsFeaturesAlgorithm>(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)::{lambda()#1}::operator()() constUnexecuted instantiation: GDALAlgorithmStepRegistry::Register<GDALRasterContourAlgorithm>(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)::{lambda()#1}::operator()() constUnexecuted instantiation: GDALAlgorithmStepRegistry::Register<GDALRasterFootprintAlgorithm>(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)::{lambda()#1}::operator()() constUnexecuted instantiation: GDALAlgorithmStepRegistry::Register<GDALRasterPixelInfoAlgorithm>(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)::{lambda()#1}::operator()() constUnexecuted instantiation: GDALAlgorithmStepRegistry::Register<GDALRasterPolygonizeAlgorithm>(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)::{lambda()#1}::operator()() constUnexecuted instantiation: GDALAlgorithmStepRegistry::Register<GDALRasterZonalStatsAlgorithm>(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)::{lambda()#1}::operator()() constUnexecuted instantiation: GDALAlgorithmStepRegistry::Register<GDALVectorGridAlgorithm>(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)::{lambda()#1}::operator()() constUnexecuted instantiation: GDALAlgorithmStepRegistry::Register<GDALVectorRasterizeAlgorithm>(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)::{lambda()#1}::operator()() const |
46 | 0 | return GDALAlgorithmRegistry::Register(info); |
47 | 0 | } Unexecuted instantiation: bool GDALAlgorithmStepRegistry::Register<GDALRasterAsFeaturesAlgorithm>(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) Unexecuted instantiation: bool GDALAlgorithmStepRegistry::Register<GDALRasterContourAlgorithm>(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) Unexecuted instantiation: bool GDALAlgorithmStepRegistry::Register<GDALRasterFootprintAlgorithm>(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) Unexecuted instantiation: bool GDALAlgorithmStepRegistry::Register<GDALRasterPixelInfoAlgorithm>(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) Unexecuted instantiation: bool GDALAlgorithmStepRegistry::Register<GDALRasterPolygonizeAlgorithm>(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) Unexecuted instantiation: bool GDALAlgorithmStepRegistry::Register<GDALRasterZonalStatsAlgorithm>(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) Unexecuted instantiation: bool GDALAlgorithmStepRegistry::Register<GDALVectorGridAlgorithm>(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) Unexecuted instantiation: bool GDALAlgorithmStepRegistry::Register<GDALVectorRasterizeAlgorithm>(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) |
48 | | }; |
49 | | |
50 | | /************************************************************************/ |
51 | | /* GDALPipelineAlgorithm */ |
52 | | /************************************************************************/ |
53 | | |
54 | | class GDALPipelineAlgorithm final : public GDALAbstractPipelineAlgorithm |
55 | | |
56 | | { |
57 | | public: |
58 | | static constexpr const char *NAME = "pipeline"; |
59 | | static constexpr const char *DESCRIPTION = |
60 | | "Process a dataset applying several steps."; |
61 | | static constexpr const char *HELP_URL = "/programs/gdal_pipeline.html"; |
62 | | |
63 | | static std::vector<std::string> GetAliasesStatic() |
64 | 0 | { |
65 | 0 | return { |
66 | 0 | #ifdef GDAL_PIPELINE_PROJ_NOSTALGIA |
67 | 0 | GDALAlgorithmRegistry::HIDDEN_ALIAS_SEPARATOR, |
68 | 0 | "+pipeline", |
69 | 0 | "+gdal=pipeline", |
70 | 0 | #endif |
71 | 0 | }; |
72 | 0 | } |
73 | | |
74 | | GDALPipelineAlgorithm(); |
75 | | |
76 | | int GetInputType() const override |
77 | 0 | { |
78 | 0 | return GDAL_OF_RASTER | GDAL_OF_VECTOR; |
79 | 0 | } |
80 | | |
81 | | int GetOutputType() const override |
82 | 0 | { |
83 | 0 | return GDAL_OF_RASTER | GDAL_OF_VECTOR; |
84 | 0 | } |
85 | | |
86 | | protected: |
87 | | GDALAlgorithmStepRegistry m_stepRegistry{}; |
88 | | |
89 | | GDALAlgorithmRegistry &GetStepRegistry() override |
90 | 0 | { |
91 | 0 | return m_stepRegistry; |
92 | 0 | } |
93 | | |
94 | | const GDALAlgorithmRegistry &GetStepRegistry() const override |
95 | 0 | { |
96 | 0 | return m_stepRegistry; |
97 | 0 | } |
98 | | |
99 | | std::string GetUsageForCLI(bool shortUsage, |
100 | | const UsageOptions &usageOptions) const override; |
101 | | |
102 | | private: |
103 | | std::unique_ptr<GDALAbstractPipelineAlgorithm> |
104 | | CreateNestedPipeline() const override |
105 | 0 | { |
106 | 0 | auto pipeline = std::make_unique<GDALPipelineAlgorithm>(); |
107 | 0 | pipeline->m_bInnerPipeline = true; |
108 | 0 | return pipeline; |
109 | 0 | } |
110 | | }; |
111 | | |
112 | | //! @endcond |
113 | | |
114 | | #endif |