Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-07 08:40:40

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