Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-03 09:31:39

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 
0016 #if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
0017 #include "nlohmann/json_fwd.hpp"
0018 #endif
0019 
0020 #include <algorithm>
0021 #include <cstddef>
0022 #include <memory>
0023 #include <mutex>
0024 #include <ostream>
0025 #include <string_view>
0026 #include <vector>
0027 
0028 namespace podio {
0029 struct RelationNames;
0030 }
0031 
0032 namespace ActsPodioEdm {
0033 
0034 class TrackStateCollectionIterator {
0035  public:
0036   using value_type = TrackState;
0037   using difference_type = ptrdiff_t;
0038   using reference = TrackState;
0039   using pointer = TrackState*;
0040   using iterator_category = std::input_iterator_tag;
0041   // `std::forward_iterator` is supported except that the pointers obtained with
0042   // `operator->()` remain valid as long as the iterator is valid, not as long
0043   // as the range is valid.
0044   using iterator_concept = std::random_access_iterator_tag;
0045 
0046   TrackStateCollectionIterator(size_t index,
0047                                const TrackStateObjPointerContainer* collection)
0048       : m_index(index),
0049         m_object(podio::utils::MaybeSharedPtr<TrackStateObj>{nullptr}),
0050         m_collection(collection) {}
0051   TrackStateCollectionIterator() = default;
0052 
0053   TrackStateCollectionIterator(const TrackStateCollectionIterator&) = default;
0054   TrackStateCollectionIterator(TrackStateCollectionIterator&&) = default;
0055   TrackStateCollectionIterator& operator=(const TrackStateCollectionIterator&) =
0056       default;
0057   TrackStateCollectionIterator& operator=(TrackStateCollectionIterator&&) =
0058       default;
0059   ~TrackStateCollectionIterator() = default;
0060 
0061   auto operator<=>(const TrackStateCollectionIterator& other) const {
0062     return m_index <=> other.m_index;
0063   }
0064 
0065   bool operator==(const TrackStateCollectionIterator& x) const {
0066     return m_index == x.m_index;
0067   }
0068 
0069   reference operator*() const;
0070   pointer operator->();
0071   TrackStateCollectionIterator& operator++();
0072   TrackStateCollectionIterator operator++(int);
0073   TrackStateCollectionIterator& operator--();
0074   TrackStateCollectionIterator operator--(int);
0075   TrackStateCollectionIterator& operator+=(difference_type n);
0076   TrackStateCollectionIterator operator+(difference_type n) const;
0077   friend TrackStateCollectionIterator operator+(
0078       difference_type n, const TrackStateCollectionIterator& it);
0079   TrackStateCollectionIterator& operator-=(difference_type n);
0080   TrackStateCollectionIterator operator-(difference_type n) const;
0081   reference operator[](difference_type n) const;
0082   difference_type operator-(const TrackStateCollectionIterator& other) const;
0083 
0084  private:
0085   size_t m_index{0};
0086   TrackState m_object{podio::utils::MaybeSharedPtr<TrackStateObj>{nullptr}};
0087   const TrackStateObjPointerContainer* m_collection{nullptr};
0088 };
0089 
0090 class TrackStateMutableCollectionIterator {
0091  public:
0092   using value_type = TrackState;
0093   using difference_type = ptrdiff_t;
0094   using reference = MutableTrackState;
0095   using pointer = MutableTrackState*;
0096   using iterator_category = std::input_iterator_tag;
0097   // `std::forward_iterator` is supported except that the pointers obtained with
0098   // `operator->()` remain valid as long as the iterator is valid, not as long
0099   // as the range is valid.
0100   using iterator_concept = std::random_access_iterator_tag;
0101 
0102   TrackStateMutableCollectionIterator(
0103       size_t index, const TrackStateObjPointerContainer* collection)
0104       : m_index(index),
0105         m_object(podio::utils::MaybeSharedPtr<TrackStateObj>{nullptr}),
0106         m_collection(collection) {}
0107   TrackStateMutableCollectionIterator() = default;
0108 
0109   TrackStateMutableCollectionIterator(
0110       const TrackStateMutableCollectionIterator&) = default;
0111   TrackStateMutableCollectionIterator(TrackStateMutableCollectionIterator&&) =
0112       default;
0113   TrackStateMutableCollectionIterator& operator=(
0114       const TrackStateMutableCollectionIterator&) = default;
0115   TrackStateMutableCollectionIterator& operator=(
0116       TrackStateMutableCollectionIterator&&) = default;
0117   ~TrackStateMutableCollectionIterator() = default;
0118 
0119   auto operator<=>(const TrackStateMutableCollectionIterator& other) const {
0120     return m_index <=> other.m_index;
0121   }
0122 
0123   bool operator==(const TrackStateMutableCollectionIterator& x) const {
0124     return m_index == x.m_index;
0125   }
0126 
0127   reference operator*() const;
0128   pointer operator->();
0129   TrackStateMutableCollectionIterator& operator++();
0130   TrackStateMutableCollectionIterator operator++(int);
0131   TrackStateMutableCollectionIterator& operator--();
0132   TrackStateMutableCollectionIterator operator--(int);
0133   TrackStateMutableCollectionIterator& operator+=(difference_type n);
0134   TrackStateMutableCollectionIterator operator+(difference_type n) const;
0135   friend TrackStateMutableCollectionIterator operator+(
0136       difference_type n, const TrackStateMutableCollectionIterator& it);
0137   TrackStateMutableCollectionIterator& operator-=(difference_type n);
0138   TrackStateMutableCollectionIterator operator-(difference_type n) const;
0139   reference operator[](difference_type n) const;
0140   difference_type operator-(
0141       const TrackStateMutableCollectionIterator& other) const;
0142 
0143  private:
0144   size_t m_index{0};
0145   MutableTrackState m_object{
0146       podio::utils::MaybeSharedPtr<TrackStateObj>{nullptr}};
0147   const TrackStateObjPointerContainer* m_collection{nullptr};
0148 };
0149 
0150 /**
0151 A Collection is identified by an ID.
0152 */
0153 class TrackStateCollection : public podio::CollectionBase {
0154  public:
0155   using value_type = TrackState;
0156   using mutable_type = MutableTrackState;
0157   using const_iterator = TrackStateCollectionIterator;
0158   using iterator = TrackStateMutableCollectionIterator;
0159   using difference_type = ptrdiff_t;
0160   using size_type = size_t;
0161   using const_reverse_iterator = std::reverse_iterator<const_iterator>;
0162   using reverse_iterator = std::reverse_iterator<iterator>;
0163 
0164   TrackStateCollection();
0165   TrackStateCollection(TrackStateCollectionData&& data, bool isSubsetColl);
0166   // This is a move-only type
0167   TrackStateCollection(const TrackStateCollection&) = delete;
0168   TrackStateCollection& operator=(const TrackStateCollection&) = delete;
0169   TrackStateCollection(TrackStateCollection&&) = default;
0170   TrackStateCollection& operator=(TrackStateCollection&&) = default;
0171 
0172   //  TrackStateCollection(TrackStateVector* data, uint32_t collectionID);
0173   ~TrackStateCollection() override;
0174 
0175   constexpr static std::string_view typeName =
0176       "ActsPodioEdm::TrackStateCollection";
0177   constexpr static std::string_view valueTypeName = "ActsPodioEdm::TrackState";
0178   constexpr static std::string_view dataTypeName =
0179       "ActsPodioEdm::TrackStateData";
0180 
0181   void clear() final;
0182 
0183   /// Print this collection to the passed stream
0184   void print(std::ostream& os = std::cout, bool flush = true) const final;
0185 
0186   /// operator to allow pointer like calling of members a la LCIO
0187   TrackStateCollection* operator->() {
0188     return static_cast<TrackStateCollection*>(this);
0189   }
0190 
0191   /// Append a new object to the collection, and return this object.
0192   MutableTrackState create();
0193 
0194   /// Append a new object to the collection, and return this object.
0195   /// Initialized with the parameters given
0196   template <typename... Args>
0197   MutableTrackState create(Args&&... args);
0198 
0199   /// number of elements in the collection
0200   std::size_t size() const final;
0201 
0202   /// maximal number of elements in the collection
0203   std::size_t max_size() const final;
0204 
0205   /// Is the collection empty
0206   bool empty() const final;
0207 
0208   /// fully qualified type name
0209   const std::string_view getTypeName() const final { return typeName; }
0210   /// fully qualified type name of elements - with namespace
0211   const std::string_view getValueTypeName() const final {
0212     return valueTypeName;
0213   }
0214   /// fully qualified type name of stored POD elements - with namespace
0215   const std::string_view getDataTypeName() const final { return dataTypeName; }
0216   /// schema version
0217   podio::SchemaVersionT getSchemaVersion() const final;
0218 
0219   bool isSubsetCollection() const final { return m_isSubsetColl; }
0220 
0221   void setSubsetCollection(bool setSubset = true) final;
0222 
0223   /// Returns the const object of given index
0224   TrackState operator[](std::size_t index) const;
0225   /// Returns the object of a given index
0226   MutableTrackState operator[](std::size_t index);
0227   /// Returns the const object of given index
0228   TrackState at(std::size_t index) const;
0229   /// Returns the object of given index
0230   MutableTrackState at(std::size_t index);
0231 
0232   /// Append object to the collection
0233   void push_back(const MutableTrackState& object);
0234   /// Append an object to the (subset) collection
0235   void push_back(const TrackState& object);
0236 
0237   void prepareForWrite() const final;
0238   void prepareAfterRead() final;
0239   bool setReferences(
0240       const podio::ICollectionProvider* collectionProvider) final;
0241 
0242   /// Get the collection buffers for this collection
0243   podio::CollectionWriteBuffers getBuffers() final;
0244 
0245   void setID(uint32_t ID) final {
0246     m_collectionID = ID;
0247     if (!m_isSubsetColl) {
0248       std::for_each(m_storage.entries.begin(), m_storage.entries.end(),
0249                     [ID](TrackStateObj* obj) {
0250                       obj->id = {obj->id.index, static_cast<uint32_t>(ID)};
0251                     });
0252     }
0253     m_isValid = true;
0254   }
0255 
0256   uint32_t getID() const final { return m_collectionID; }
0257 
0258   bool isValid() const final { return m_isValid; }
0259 
0260   size_t getDatamodelRegistryIndex() const final;
0261 
0262   // support for the iterator protocol
0263   iterator begin() { return iterator(0, &m_storage.entries); }
0264   const_iterator begin() const { return const_iterator(0, &m_storage.entries); }
0265   const_iterator cbegin() const { return begin(); }
0266   iterator end() {
0267     return iterator(m_storage.entries.size(), &m_storage.entries);
0268   }
0269   const_iterator end() const {
0270     return const_iterator(m_storage.entries.size(), &m_storage.entries);
0271   }
0272   const_iterator cend() const { return end(); }
0273   // reverse iterators
0274   reverse_iterator rbegin() { return reverse_iterator(end()); }
0275   const_reverse_iterator rbegin() const {
0276     return const_reverse_iterator(end());
0277   }
0278   const_reverse_iterator crbegin() const { return rbegin(); }
0279   reverse_iterator rend() { return reverse_iterator(begin()); }
0280   const_reverse_iterator rend() const {
0281     return const_reverse_iterator(begin());
0282   }
0283   const_reverse_iterator crend() const { return rend(); }
0284 
0285   std::vector<ActsPodioEdm::TrackStateInfo> data(const size_t nElem = 0) const;
0286   std::vector<ActsPodioEdm::Surface> referenceSurface(
0287       const size_t nElem = 0) const;
0288 
0289  private:
0290   // For setReferences, we need to give our own CollectionData access to our
0291   // private entries. Otherwise we would need to expose a public member function
0292   // that gives access to the Obj* which is definitely not what we want
0293   friend class TrackStateCollectionData;
0294 
0295   bool m_isValid{false};
0296   mutable bool m_isPrepared{false};
0297   bool m_isSubsetColl{false};
0298   uint32_t m_collectionID{0};
0299   mutable std::unique_ptr<std::mutex> m_storageMtx{nullptr};
0300   mutable TrackStateCollectionData m_storage{};
0301 };
0302 
0303 std::ostream& operator<<(std::ostream& o, const TrackStateCollection& v);
0304 
0305 template <typename... Args>
0306 MutableTrackState TrackStateCollection::create(Args&&... args) {
0307   if (m_isSubsetColl) {
0308     throw std::logic_error("Cannot create new elements on a subset collection");
0309   }
0310   const int size = m_storage.entries.size();
0311   auto obj =
0312       new TrackStateObj({size, m_collectionID}, {std::forward<Args>(args)...});
0313   m_storage.entries.push_back(obj);
0314 
0315   return MutableTrackState(podio::utils::MaybeSharedPtr(obj));
0316 }
0317 
0318 #if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
0319 void to_json(nlohmann::json& j, const TrackStateCollection& collection);
0320 #endif
0321 
0322 }  // namespace ActsPodioEdm
0323 
0324 #endif