Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-06-03 08:33:28

0001 // AUTOMATICALLY GENERATED FILE - DO NOT EDIT
0002 
0003 #ifndef EDM4HEP_TrackerHitSimTrackerHitLinkCollection_H
0004 #define EDM4HEP_TrackerHitSimTrackerHitLinkCollection_H
0005 
0006 // datamodel specific includes
0007 #include "edm4hep/MutableTrackerHitSimTrackerHitLink.h"
0008 #include "edm4hep/TrackerHitSimTrackerHitLink.h"
0009 #include "edm4hep/TrackerHitSimTrackerHitLinkCollectionData.h"
0010 #include "edm4hep/TrackerHitSimTrackerHitLinkObj.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 edm4hep {
0033 
0034 class TrackerHitSimTrackerHitLinkCollectionIterator {
0035 public:
0036   TrackerHitSimTrackerHitLinkCollectionIterator(size_t index,
0037                                                 const TrackerHitSimTrackerHitLinkObjPointerContainer* collection) :
0038       m_index(index),
0039       m_object(podio::utils::MaybeSharedPtr<TrackerHitSimTrackerHitLinkObj>{nullptr}),
0040       m_collection(collection) {
0041   }
0042 
0043   TrackerHitSimTrackerHitLinkCollectionIterator(const TrackerHitSimTrackerHitLinkCollectionIterator&) = delete;
0044   TrackerHitSimTrackerHitLinkCollectionIterator&
0045   operator=(const TrackerHitSimTrackerHitLinkCollectionIterator&) = delete;
0046 
0047   bool operator!=(const TrackerHitSimTrackerHitLinkCollectionIterator& x) const {
0048     return m_index != x.m_index; // TODO: may not be complete
0049   }
0050 
0051   bool operator==(const TrackerHitSimTrackerHitLinkCollectionIterator& x) const {
0052     return m_index == x.m_index; // TODO: may not be complete
0053   }
0054 
0055   TrackerHitSimTrackerHitLink operator*();
0056   TrackerHitSimTrackerHitLink* operator->();
0057   TrackerHitSimTrackerHitLinkCollectionIterator& operator++();
0058 
0059 private:
0060   size_t m_index;
0061   TrackerHitSimTrackerHitLink m_object;
0062   const TrackerHitSimTrackerHitLinkObjPointerContainer* m_collection;
0063 };
0064 
0065 class TrackerHitSimTrackerHitLinkMutableCollectionIterator {
0066 public:
0067   TrackerHitSimTrackerHitLinkMutableCollectionIterator(
0068       size_t index, const TrackerHitSimTrackerHitLinkObjPointerContainer* collection) :
0069       m_index(index),
0070       m_object(podio::utils::MaybeSharedPtr<TrackerHitSimTrackerHitLinkObj>{nullptr}),
0071       m_collection(collection) {
0072   }
0073 
0074   TrackerHitSimTrackerHitLinkMutableCollectionIterator(const TrackerHitSimTrackerHitLinkMutableCollectionIterator&) =
0075       delete;
0076   TrackerHitSimTrackerHitLinkMutableCollectionIterator&
0077   operator=(const TrackerHitSimTrackerHitLinkMutableCollectionIterator&) = delete;
0078 
0079   bool operator!=(const TrackerHitSimTrackerHitLinkMutableCollectionIterator& x) const {
0080     return m_index != x.m_index; // TODO: may not be complete
0081   }
0082 
0083   bool operator==(const TrackerHitSimTrackerHitLinkMutableCollectionIterator& x) const {
0084     return m_index == x.m_index; // TODO: may not be complete
0085   }
0086 
0087   MutableTrackerHitSimTrackerHitLink operator*();
0088   MutableTrackerHitSimTrackerHitLink* operator->();
0089   TrackerHitSimTrackerHitLinkMutableCollectionIterator& operator++();
0090 
0091 private:
0092   size_t m_index;
0093   MutableTrackerHitSimTrackerHitLink m_object;
0094   const TrackerHitSimTrackerHitLinkObjPointerContainer* m_collection;
0095 };
0096 
0097 /**
0098 A Collection is identified by an ID.
0099 */
0100 class TrackerHitSimTrackerHitLinkCollection : public podio::CollectionBase {
0101 public:
0102   using value_type = TrackerHitSimTrackerHitLink;
0103   using const_iterator = TrackerHitSimTrackerHitLinkCollectionIterator;
0104   using iterator = TrackerHitSimTrackerHitLinkMutableCollectionIterator;
0105   using difference_type = ptrdiff_t;
0106   using size_type = size_t;
0107 
0108   TrackerHitSimTrackerHitLinkCollection();
0109   TrackerHitSimTrackerHitLinkCollection(TrackerHitSimTrackerHitLinkCollectionData&& data, bool isSubsetColl);
0110   // This is a move-only type
0111   TrackerHitSimTrackerHitLinkCollection(const TrackerHitSimTrackerHitLinkCollection&) = delete;
0112   TrackerHitSimTrackerHitLinkCollection& operator=(const TrackerHitSimTrackerHitLinkCollection&) = delete;
0113   TrackerHitSimTrackerHitLinkCollection(TrackerHitSimTrackerHitLinkCollection&&) = default;
0114   TrackerHitSimTrackerHitLinkCollection& operator=(TrackerHitSimTrackerHitLinkCollection&&) = default;
0115 
0116   //  TrackerHitSimTrackerHitLinkCollection(TrackerHitSimTrackerHitLinkVector* data, uint32_t collectionID);
0117   ~TrackerHitSimTrackerHitLinkCollection() override;
0118 
0119   constexpr static auto typeName = "edm4hep::TrackerHitSimTrackerHitLinkCollection";
0120   constexpr static auto valueTypeName = "edm4hep::TrackerHitSimTrackerHitLink";
0121   constexpr static auto dataTypeName = "edm4hep::TrackerHitSimTrackerHitLinkData";
0122 
0123   void clear() final;
0124 
0125   /// Print this collection to the passed stream
0126   void print(std::ostream& os = std::cout, bool flush = true) const final;
0127 
0128   /// operator to allow pointer like calling of members a la LCIO
0129   TrackerHitSimTrackerHitLinkCollection* operator->() {
0130     return static_cast<TrackerHitSimTrackerHitLinkCollection*>(this);
0131   }
0132 
0133   /// Append a new object to the collection, and return this object.
0134   MutableTrackerHitSimTrackerHitLink create();
0135 
0136   /// Append a new object to the collection, and return this object.
0137   /// Initialized with the parameters given
0138   template <typename... Args>
0139   MutableTrackerHitSimTrackerHitLink create(Args&&... args);
0140 
0141   /// number of elements in the collection
0142   std::size_t size() const final;
0143 
0144   /// maximal number of elements in the collection
0145   std::size_t max_size() const final;
0146 
0147   /// Is the collection empty
0148   bool empty() const final;
0149 
0150   /// fully qualified type name
0151   const std::string_view getTypeName() const final {
0152     return typeName;
0153   }
0154   /// fully qualified type name of elements - with namespace
0155   const std::string_view getValueTypeName() const final {
0156     return valueTypeName;
0157   }
0158   /// fully qualified type name of stored POD elements - with namespace
0159   const std::string_view getDataTypeName() const final {
0160     return dataTypeName;
0161   }
0162   /// schema version
0163   podio::SchemaVersionT getSchemaVersion() const final;
0164 
0165   bool isSubsetCollection() const final {
0166     return m_isSubsetColl;
0167   }
0168 
0169   void setSubsetCollection(bool setSubset = true) final;
0170 
0171   /// Returns the const object of given index
0172   TrackerHitSimTrackerHitLink operator[](std::size_t index) const;
0173   /// Returns the object of a given index
0174   MutableTrackerHitSimTrackerHitLink operator[](std::size_t index);
0175   /// Returns the const object of given index
0176   TrackerHitSimTrackerHitLink at(std::size_t index) const;
0177   /// Returns the object of given index
0178   MutableTrackerHitSimTrackerHitLink at(std::size_t index);
0179 
0180   /// Append object to the collection
0181   void push_back(const MutableTrackerHitSimTrackerHitLink& object);
0182   /// Append an object to the (subset) collection
0183   void push_back(const TrackerHitSimTrackerHitLink& object);
0184 
0185   void prepareForWrite() const final;
0186   void prepareAfterRead() final;
0187   bool setReferences(const podio::ICollectionProvider* collectionProvider) final;
0188 
0189   /// Get the collection buffers for this collection
0190   podio::CollectionWriteBuffers getBuffers() final;
0191 
0192   void setID(uint32_t ID) final {
0193     m_collectionID = ID;
0194     if (!m_isSubsetColl) {
0195       std::for_each(m_storage.entries.begin(), m_storage.entries.end(), [ID](TrackerHitSimTrackerHitLinkObj* obj) {
0196         obj->id = {obj->id.index, static_cast<uint32_t>(ID)};
0197       });
0198     }
0199     m_isValid = true;
0200   }
0201 
0202   uint32_t getID() const final {
0203     return m_collectionID;
0204   }
0205 
0206   bool isValid() const final {
0207     return m_isValid;
0208   }
0209 
0210   size_t getDatamodelRegistryIndex() const final;
0211 
0212   // support for the iterator protocol
0213   iterator begin() {
0214     return iterator(0, &m_storage.entries);
0215   }
0216   const_iterator begin() const {
0217     return const_iterator(0, &m_storage.entries);
0218   }
0219   const_iterator cbegin() const {
0220     return begin();
0221   }
0222   iterator end() {
0223     return iterator(m_storage.entries.size(), &m_storage.entries);
0224   }
0225   const_iterator end() const {
0226     return const_iterator(m_storage.entries.size(), &m_storage.entries);
0227   }
0228   const_iterator cend() const {
0229     return end();
0230   }
0231 
0232   std::vector<float> weight(const size_t nElem = 0) const;
0233 
0234 private:
0235   // For setReferences, we need to give our own CollectionData access to our
0236   // private entries. Otherwise we would need to expose a public member function
0237   // that gives access to the Obj* which is definitely not what we want
0238   friend class TrackerHitSimTrackerHitLinkCollectionData;
0239 
0240   bool m_isValid{false};
0241   mutable bool m_isPrepared{false};
0242   bool m_isSubsetColl{false};
0243   uint32_t m_collectionID{0};
0244   mutable std::unique_ptr<std::mutex> m_storageMtx{nullptr};
0245   mutable TrackerHitSimTrackerHitLinkCollectionData m_storage{};
0246 };
0247 
0248 std::ostream& operator<<(std::ostream& o, const TrackerHitSimTrackerHitLinkCollection& v);
0249 
0250 template <typename... Args>
0251 MutableTrackerHitSimTrackerHitLink TrackerHitSimTrackerHitLinkCollection::create(Args&&... args) {
0252   if (m_isSubsetColl) {
0253     throw std::logic_error("Cannot create new elements on a subset collection");
0254   }
0255   const int size = m_storage.entries.size();
0256   auto obj = new TrackerHitSimTrackerHitLinkObj({size, m_collectionID}, {std::forward<Args>(args)...});
0257   m_storage.entries.push_back(obj);
0258 
0259   return MutableTrackerHitSimTrackerHitLink(podio::utils::MaybeSharedPtr(obj));
0260 }
0261 
0262 #if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
0263 void to_json(nlohmann::json& j, const TrackerHitSimTrackerHitLinkCollection& collection);
0264 #endif
0265 
0266 } // namespace edm4hep
0267 
0268 #endif