|
|
|||
File indexing completed on 2026-09-07 08:27:59
0001 // SPDX-License-Identifier: LGPL-3.0-or-later 0002 // Copyright (C) 2026 Wouter Deconinck 0003 0004 #pragma once 0005 0006 #include <algorithms/algorithm.h> 0007 #include <string> 0008 0009 namespace eicrecon { 0010 0011 /** 0012 * Clone collection elements to create a new standalone collection. 0013 * 0014 * This algorithm takes an input collection and creates an output collection 0015 * containing cloned copies of those elements. This is primarily useful for 0016 * subset collections (where elements point to objects in another collection) 0017 * to create an owning (non-subset) collection. 0018 * 0019 * \note Any relations carried by the elements are cloned as-is; if you write 0020 * the output without also writing the referenced collections, you may create 0021 * dangling references in the output file. 0022 * 0023 * \note While this works on any collection, cloning non-subset collections 0024 * creates unnecessary duplicates and is generally not recommended. 0025 * 0026 * Template parameter T is the PODIO object type (e.g., edm4eic::Cluster) 0027 */ 0028 template <typename T> 0029 class Cloner : public algorithms::Algorithm<algorithms::Input<typename T::collection_type>, 0030 algorithms::Output<typename T::collection_type>> { 0031 0032 public: 0033 Cloner(std::string name) 0034 : algorithms::Algorithm<algorithms::Input<typename T::collection_type>, 0035 algorithms::Output<typename T::collection_type>>( 0036 std::move(name), {"inputCollection"}, {"outputCollection"}, 0037 "Clone collection elements to create standalone collection") {} 0038 0039 void process(const typename Cloner::Input& input, 0040 const typename Cloner::Output& output) const final { 0041 const auto [in_coll] = input; 0042 auto [out_coll] = output; 0043 0044 // Clone each element from input to output 0045 for (const auto& obj : *in_coll) { 0046 out_coll->push_back(obj.clone()); 0047 } 0048 } 0049 }; 0050 0051 } // namespace eicrecon
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|