Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-06 09:14:02

0001 // AUTOMATICALLY GENERATED FILE - DO NOT EDIT
0002 
0003 #ifndef ACTSPODIOEDM_TrackCollection_H
0004 #define ACTSPODIOEDM_TrackCollection_H
0005 
0006 // datamodel specific includes
0007 #include "ActsPodioEdm/MutableTrack.h"
0008 #include "ActsPodioEdm/Track.h"
0009 #include "ActsPodioEdm/TrackCollectionData.h"
0010 #include "ActsPodioEdm/TrackObj.h"
0011 
0012 // podio specific includes
0013 #include "podio/CollectionBase.h"
0014 #include "podio/ICollectionProvider.h"
0015 #include "podio/detail/Pythonizations.h"
0016 
0017 #if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
0018 #include "nlohmann/json_fwd.hpp"
0019 #endif
0020 
0021 #include <algorithm>
0022 #include <cstddef>
0023 #include <memory>
0024 #include <mutex>
0025 #include <ostream>
0026 #include <string_view>
0027 #include <vector>
0028 
0029 namespace podio {
0030 struct RelationNames;
0031 }
0032 
0033 namespace ActsPodioEdm {
0034 
0035 class TrackCollectionIterator {
0036  public:
0037   using value_type = Track;
0038   using difference_type = ptrdiff_t;
0039   using reference = Track;
0040   using pointer = Track*;
0041   using iterator_category = std::input_iterator_tag;
0042   // `std::forward_iterator` is supported except that the pointers obtained with
0043   // `operator->()` remain valid as long as the iterator is valid, not as long
0044   // as the range is valid.
0045   using iterator_concept = std::random_access_iterator_tag;
0046 
0047   TrackCollectionIterator(size_t index,
0048                           const TrackObjPointerContainer* collection)
0049       : m_index(index),
0050         m_object(podio::utils::MaybeSharedPtr<TrackObj>{nullptr}),
0051         m_collection(collection) {}
0052   TrackCollectionIterator() = default;
0053 
0054   TrackCollectionIterator(const TrackCollectionIterator&) = default;
0055   TrackCollectionIterator(TrackCollectionIterator&&) = default;
0056   TrackCollectionIterator& operator=(const TrackCollectionIterator&) = default;
0057   TrackCollectionIterator& operator=(TrackCollectionIterator&&) = default;
0058   ~TrackCollectionIterator() = default;
0059 
0060   auto operator<=>(const TrackCollectionIterator& other) const {
0061     return m_index <=> other.m_index;
0062   }
0063 
0064   bool operator==(const TrackCollectionIterator& x) const {
0065     return m_index == x.m_index;
0066   }
0067 
0068   reference operator*() const;
0069   pointer operator->();
0070   TrackCollectionIterator& operator++();
0071   TrackCollectionIterator operator++(int);
0072   TrackCollectionIterator& operator--();
0073   TrackCollectionIterator operator--(int);
0074   TrackCollectionIterator& operator+=(difference_type n);
0075   TrackCollectionIterator operator+(difference_type n) const;
0076   friend TrackCollectionIterator operator+(difference_type n,
0077                                            const TrackCollectionIterator& it);
0078   TrackCollectionIterator& operator-=(difference_type n);
0079   TrackCollectionIterator operator-(difference_type n) const;
0080   reference operator[](difference_type n) const;
0081   difference_type operator-(const TrackCollectionIterator& other) const;
0082 
0083  private:
0084   size_t m_index{0};
0085   Track m_object{podio::utils::MaybeSharedPtr<TrackObj>{nullptr}};
0086   const TrackObjPointerContainer* m_collection{nullptr};
0087 };
0088 
0089 class TrackMutableCollectionIterator {
0090  public:
0091   using value_type = Track;
0092   using difference_type = ptrdiff_t;
0093   using reference = MutableTrack;
0094   using pointer = MutableTrack*;
0095   using iterator_category = std::input_iterator_tag;
0096   // `std::forward_iterator` is supported except that the pointers obtained with
0097   // `operator->()` remain valid as long as the iterator is valid, not as long
0098   // as the range is valid.
0099   using iterator_concept = std::random_access_iterator_tag;
0100 
0101   TrackMutableCollectionIterator(size_t index,
0102                                  const TrackObjPointerContainer* collection)
0103       : m_index(index),
0104         m_object(podio::utils::MaybeSharedPtr<TrackObj>{nullptr}),
0105         m_collection(collection) {}
0106   TrackMutableCollectionIterator() = default;
0107 
0108   TrackMutableCollectionIterator(const TrackMutableCollectionIterator&) =
0109       default;
0110   TrackMutableCollectionIterator(TrackMutableCollectionIterator&&) = default;
0111   TrackMutableCollectionIterator& operator=(
0112       const TrackMutableCollectionIterator&) = default;
0113   TrackMutableCollectionIterator& operator=(TrackMutableCollectionIterator&&) =
0114       default;
0115   ~TrackMutableCollectionIterator() = default;
0116 
0117   auto operator<=>(const TrackMutableCollectionIterator& other) const {
0118     return m_index <=> other.m_index;
0119   }
0120 
0121   bool operator==(const TrackMutableCollectionIterator& x) const {
0122     return m_index == x.m_index;
0123   }
0124 
0125   reference operator*() const;
0126   pointer operator->();
0127   TrackMutableCollectionIterator& operator++();
0128   TrackMutableCollectionIterator operator++(int);
0129   TrackMutableCollectionIterator& operator--();
0130   TrackMutableCollectionIterator operator--(int);
0131   TrackMutableCollectionIterator& operator+=(difference_type n);
0132   TrackMutableCollectionIterator operator+(difference_type n) const;
0133   friend TrackMutableCollectionIterator operator+(
0134       difference_type n, const TrackMutableCollectionIterator& it);
0135   TrackMutableCollectionIterator& operator-=(difference_type n);
0136   TrackMutableCollectionIterator operator-(difference_type n) const;
0137   reference operator[](difference_type n) const;
0138   difference_type operator-(const TrackMutableCollectionIterator& other) const;
0139 
0140  private:
0141   size_t m_index{0};
0142   MutableTrack m_object{podio::utils::MaybeSharedPtr<TrackObj>{nullptr}};
0143   const TrackObjPointerContainer* m_collection{nullptr};
0144 };
0145 
0146 /**
0147 A Collection is identified by an ID.
0148 */
0149 class TrackCollection : public podio::CollectionBase {
0150  public:
0151   using value_type = Track;
0152   using mutable_type = MutableTrack;
0153   using const_iterator = TrackCollectionIterator;
0154   using iterator = TrackMutableCollectionIterator;
0155   using difference_type = ptrdiff_t;
0156   using size_type = size_t;
0157   using const_reverse_iterator = std::reverse_iterator<const_iterator>;
0158   using reverse_iterator = std::reverse_iterator<iterator>;
0159 
0160   TrackCollection() = default;
0161   TrackCollection(TrackCollectionData&& data, bool isSubsetColl);
0162   // This is a move-only type
0163   TrackCollection(const TrackCollection&) = delete;
0164   TrackCollection& operator=(const TrackCollection&) = delete;
0165   TrackCollection(TrackCollection&&) = default;
0166   TrackCollection& operator=(TrackCollection&&) = default;
0167 
0168   //  TrackCollection(TrackVector* data, uint32_t collectionID);
0169   ~TrackCollection() override;
0170 
0171   constexpr static std::string_view typeName = "ActsPodioEdm::TrackCollection";
0172   constexpr static std::string_view valueTypeName = "ActsPodioEdm::Track";
0173   constexpr static std::string_view dataTypeName = "ActsPodioEdm::TrackData";
0174 
0175   void clear() final;
0176 
0177   /// Cppyy protocol to setup the pythonizations for this class. Not to be
0178   /// called directly.
0179   static void __cppyy_pythonize__(PyObject* klass, const std::string& name) {
0180     podio::detail::pythonizations::pythonize_subscript(klass, name);
0181   }
0182 
0183   /// Print this collection to the passed stream
0184   void print(std::ostream& os = std::cout, bool flush = true) const final;
0185 
0186   /// Append a new object to the collection, and return this object.
0187   MutableTrack create();
0188 
0189   /// Append a new object to the collection, and return this object.
0190   /// Initialized with the parameters given
0191   template <typename... Args>
0192   MutableTrack create(Args&&... args);
0193 
0194   /// number of elements in the collection
0195   std::size_t size() const final;
0196 
0197   /// maximal number of elements in the collection
0198   std::size_t max_size() const final;
0199 
0200   /// Is the collection empty
0201   bool empty() const final;
0202 
0203   /// fully qualified type name
0204   const std::string_view getTypeName() const final { return typeName; }
0205   /// fully qualified type name of elements - with namespace
0206   const std::string_view getValueTypeName() const final {
0207     return valueTypeName;
0208   }
0209   /// fully qualified type name of stored POD elements - with namespace
0210   const std::string_view getDataTypeName() const final { return dataTypeName; }
0211   /// schema version
0212   podio::SchemaVersionT getSchemaVersion() const final;
0213 
0214   bool isSubsetCollection() const final { return m_isSubsetColl; }
0215 
0216   void setSubsetCollection(bool setSubset = true) final;
0217 
0218   /// Returns the const object of given index
0219   Track operator[](std::size_t index) const;
0220   /// Returns the object of a given index
0221   MutableTrack operator[](std::size_t index);
0222   /// Returns the const object of given index
0223   Track at(std::size_t index) const;
0224   /// Returns the object of given index
0225   MutableTrack at(std::size_t index);
0226 
0227   /// Append object to the collection
0228   void push_back(const MutableTrack& object);
0229   /// Append an object to the (subset) collection
0230   void push_back(const Track& object);
0231 
0232   void prepareForWrite() const final;
0233   void prepareAfterRead() final;
0234   bool setReferences(
0235       const podio::ICollectionProvider* collectionProvider) final;
0236 
0237   /// Get the collection buffers for this collection
0238   podio::CollectionWriteBuffers getBuffers() final;
0239 
0240   void setID(uint32_t ID) final {
0241     m_collectionID = ID;
0242     if (!m_isSubsetColl) {
0243       std::for_each(m_storage.entries.begin(), m_storage.entries.end(),
0244                     [ID](TrackObj* obj) {
0245                       obj->id = {obj->id.index, static_cast<uint32_t>(ID)};
0246                     });
0247     }
0248   }
0249 
0250   uint32_t getID() const final { return m_collectionID; }
0251 
0252   /// check if the collection has a valid ID
0253   bool hasID() const final {
0254     return getID() != static_cast<uint32_t>(podio::ObjectID::untracked) &&
0255            getID() != static_cast<uint32_t>(podio::ObjectID::invalid);
0256   }
0257 
0258   [[deprecated(
0259       "isValid will be removed, use hasID() if you want to check if it has an "
0260       "ID, otherwise assume the "
0261       "collection is valid")]]
0262   bool isValid() const final {
0263     return hasID();
0264   }
0265 
0266   size_t getDatamodelRegistryIndex() const final;
0267 
0268   // support for the iterator protocol
0269   iterator begin() { return iterator(0, &m_storage.entries); }
0270   const_iterator begin() const { return const_iterator(0, &m_storage.entries); }
0271   const_iterator cbegin() const { return begin(); }
0272   iterator end() {
0273     return iterator(m_storage.entries.size(), &m_storage.entries);
0274   }
0275   const_iterator end() const {
0276     return const_iterator(m_storage.entries.size(), &m_storage.entries);
0277   }
0278   const_iterator cend() const { return end(); }
0279   // reverse iterators
0280   reverse_iterator rbegin() { return reverse_iterator(end()); }
0281   const_reverse_iterator rbegin() const {
0282     return const_reverse_iterator(end());
0283   }
0284   const_reverse_iterator crbegin() const { return rbegin(); }
0285   reverse_iterator rend() { return reverse_iterator(begin()); }
0286   const_reverse_iterator rend() const {
0287     return const_reverse_iterator(begin());
0288   }
0289   const_reverse_iterator crend() const { return rend(); }
0290 
0291   std::vector<ActsPodioEdm::TrackInfo> data(const size_t nElem = 0) const;
0292   std::vector<ActsPodioEdm::Surface> referenceSurface(
0293       const size_t nElem = 0) const;
0294   std::vector<ActsPodioEdm::ParticleHypothesis> particleHypothesis(
0295       const size_t nElem = 0) const;
0296 
0297  private:
0298   // For setReferences, we need to give our own CollectionData access to our
0299   // private entries. Otherwise we would need to expose a public member function
0300   // that gives access to the Obj* which is definitely not what we want
0301   friend class TrackCollectionData;
0302 
0303   mutable bool m_isPrepared{false};
0304   bool m_isSubsetColl{false};
0305   uint32_t m_collectionID{static_cast<uint32_t>(podio::ObjectID::untracked)};
0306   mutable std::unique_ptr<std::mutex> m_storageMtx{
0307       std::make_unique<std::mutex>()};
0308   mutable TrackCollectionData m_storage{};
0309 };
0310 
0311 std::ostream& operator<<(std::ostream& o, const TrackCollection& v);
0312 
0313 template <typename... Args>
0314 MutableTrack TrackCollection::create(Args&&... args) {
0315   if (m_isSubsetColl) {
0316     throw std::logic_error("Cannot create new elements on a subset collection");
0317   }
0318   auto obj =
0319       new TrackObj({static_cast<int>(m_storage.entries.size()), m_collectionID},
0320                    {std::forward<Args>(args)...});
0321   m_storage.entries.push_back(obj);
0322 
0323   return MutableTrack(podio::utils::MaybeSharedPtr(obj));
0324 }
0325 
0326 #if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
0327 void to_json(nlohmann::json& j, const TrackCollection& collection);
0328 #endif
0329 
0330 }  // namespace ActsPodioEdm
0331 
0332 // This is needed to avoid triggering opening every library in LD_LIBRARY_PATH
0333 // until it's fixed in ROOT. See
0334 // https://github.com/root-project/root/issues/18489 and
0335 // https://github.com/AIDASoft/podio/issues/770
0336 #if defined(__clang__)
0337 #pragma clang diagnostic push
0338 #pragma clang diagnostic ignored "-Wunknown-warning-option"
0339 #pragma clang diagnostic ignored "-Wdeprecated-redundant-constexpr-static-def"
0340 #pragma clang diagnostic ignored "-Wdeprecated"
0341 constexpr std::string_view ActsPodioEdm::TrackCollection::typeName;
0342 constexpr std::string_view ActsPodioEdm::TrackCollection::valueTypeName;
0343 constexpr std::string_view ActsPodioEdm::TrackCollection::dataTypeName;
0344 #pragma clang diagnostic pop
0345 #elif defined(__GNUC__)
0346 #pragma GCC diagnostic push
0347 #pragma GCC diagnostic ignored "-Wdeprecated"
0348 constexpr std::string_view ActsPodioEdm::TrackCollection::typeName;
0349 constexpr std::string_view ActsPodioEdm::TrackCollection::valueTypeName;
0350 constexpr std::string_view ActsPodioEdm::TrackCollection::dataTypeName;
0351 #pragma GCC diagnostic pop
0352 #endif
0353 
0354 #endif