Copy arguments and other parameters from \a src to \a dst, typically * when turning a raster algorithm to the vector one of the same name, or * vice-versa. */
| 311 | * vice-versa. |
| 312 | */ |
| 313 | bool GDALAbstractPipelineAlgorithm::CopyStepAlgorithmFromAnother( |
| 314 | GDALPipelineStepAlgorithm *dst, const GDALPipelineStepAlgorithm *src, |
| 315 | bool maybeWriteStep) const |
| 316 | { |
| 317 | if (src->GetName() == GDALTeeStepAlgorithmAbstract::NAME) |
| 318 | { |
| 319 | const auto poSrcTeeAlg = |
| 320 | dynamic_cast<const GDALTeeStepAlgorithmAbstract *>(src); |
| 321 | auto poDstTeeAlg = dynamic_cast<GDALTeeStepAlgorithmAbstract *>(dst); |
| 322 | CPLAssert(poSrcTeeAlg); |
| 323 | CPLAssert(poDstTeeAlg); |
| 324 | poDstTeeAlg->CopyFilenameBindingsFrom(poSrcTeeAlg); |
| 325 | } |
| 326 | |
| 327 | if (maybeWriteStep) |
| 328 | { |
| 329 | // Propagate output parameters set at the pipeline level to the |
| 330 | // "write" step |
| 331 | for (auto &arg : dst->GetArgs()) |
| 332 | { |
| 333 | if (!arg->IsHidden()) |
| 334 | { |
| 335 | const auto pipelineArg = GetArg(arg->GetName()); |
| 336 | if (pipelineArg && pipelineArg->IsExplicitlySet() && |
| 337 | pipelineArg->GetType() == arg->GetType()) |
| 338 | { |
| 339 | arg->SetSkipIfAlreadySet(true); |
| 340 | [[maybe_unused]] bool ret = arg->SetFrom(*pipelineArg); |
| 341 | CPLAssert(ret); |
| 342 | } |
| 343 | } |
| 344 | } |
| 345 | } |
| 346 | |
| 347 | // Propagate parameters set on the old algorithm to the new one |
| 348 | for (const auto &srcArg : src->GetArgs()) |
| 349 | { |
| 350 | if (srcArg->IsExplicitlySet()) |
| 351 | { |
| 352 | auto dstArg = dst->GetArg(srcArg->GetName()); |
| 353 | if (!dstArg) |
| 354 | { |
| 355 | dst->ReportError(CE_Failure, CPLE_IllegalArg, |
| 356 | "Option '--%s' is unknown", |
| 357 | srcArg->GetName().c_str()); |
| 358 | return false; |
| 359 | } |
| 360 | else |
| 361 | { |
| 362 | dstArg->SetSkipIfAlreadySet(true); |
| 363 | if (!dstArg->SetFrom(*srcArg)) |
| 364 | return false; |
| 365 | } |
| 366 | } |
| 367 | } |
| 368 | |
| 369 | dst->m_oMapDatasetNameToDataset = |
| 370 | std::move(src->m_oMapDatasetNameToDataset); |
nothing calls this directly
no test coverage detected