Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-03-31 07:56:37

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