Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-03-30 07:57:06

0001 // AUTOMATICALLY GENERATED FILE - DO NOT EDIT
0002 
0003 #ifndef ACTSPODIOEDM_MeasurementCollection_H
0004 #define ACTSPODIOEDM_MeasurementCollection_H
0005 
0006 // datamodel specific includes
0007 #include "ActsPodioEdm/Measurement.h"
0008 #include "ActsPodioEdm/MeasurementCollectionData.h"
0009 #include "ActsPodioEdm/MeasurementObj.h"
0010 #include "ActsPodioEdm/MutableMeasurement.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 MeasurementCollectionIterator {
0036  public:
0037   using value_type = Measurement;
0038   using difference_type = ptrdiff_t;
0039   using reference = Measurement;
0040   using pointer = Measurement*;
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   MeasurementCollectionIterator(
0048       size_t index, const MeasurementObjPointerContainer* collection)
0049       : m_index(index),
0050         m_object(podio::utils::MaybeSharedPtr<MeasurementObj>{nullptr}),
0051         m_collection(collection) {}
0052   MeasurementCollectionIterator() = default;
0053 
0054   MeasurementCollectionIterator(const MeasurementCollectionIterator&) = default;
0055   MeasurementCollectionIterator(MeasurementCollectionIterator&&) = default;
0056   MeasurementCollectionIterator& operator=(
0057       const MeasurementCollectionIterator&) = default;
0058   MeasurementCollectionIterator& operator=(MeasurementCollectionIterator&&) =
0059       default;
0060   ~MeasurementCollectionIterator() = default;
0061 
0062   auto operator<=>(const MeasurementCollectionIterator& other) const {
0063     return m_index <=> other.m_index;
0064   }
0065 
0066   bool operator==(const MeasurementCollectionIterator& x) const {
0067     return m_index == x.m_index;
0068   }
0069 
0070   reference operator*() const;
0071   pointer operator->();
0072   MeasurementCollectionIterator& operator++();
0073   MeasurementCollectionIterator operator++(int);
0074   MeasurementCollectionIterator& operator--();
0075   MeasurementCollectionIterator operator--(int);
0076   MeasurementCollectionIterator& operator+=(difference_type n);
0077   MeasurementCollectionIterator operator+(difference_type n) const;
0078   friend MeasurementCollectionIterator operator+(
0079       difference_type n, const MeasurementCollectionIterator& it);
0080   MeasurementCollectionIterator& operator-=(difference_type n);
0081   MeasurementCollectionIterator operator-(difference_type n) const;
0082   reference operator[](difference_type n) const;
0083   difference_type operator-(const MeasurementCollectionIterator& other) const;
0084 
0085  private:
0086   size_t m_index{0};
0087   Measurement m_object{podio::utils::MaybeSharedPtr<MeasurementObj>{nullptr}};
0088   const MeasurementObjPointerContainer* m_collection{nullptr};
0089 };
0090 
0091 class MeasurementMutableCollectionIterator {
0092  public:
0093   using value_type = Measurement;
0094   using difference_type = ptrdiff_t;
0095   using reference = MutableMeasurement;
0096   using pointer = MutableMeasurement*;
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   MeasurementMutableCollectionIterator(
0104       size_t index, const MeasurementObjPointerContainer* collection)
0105       : m_index(index),
0106         m_object(podio::utils::MaybeSharedPtr<MeasurementObj>{nullptr}),
0107         m_collection(collection) {}
0108   MeasurementMutableCollectionIterator() = default;
0109 
0110   MeasurementMutableCollectionIterator(
0111       const MeasurementMutableCollectionIterator&) = default;
0112   MeasurementMutableCollectionIterator(MeasurementMutableCollectionIterator&&) =
0113       default;
0114   MeasurementMutableCollectionIterator& operator=(
0115       const MeasurementMutableCollectionIterator&) = default;
0116   MeasurementMutableCollectionIterator& operator=(
0117       MeasurementMutableCollectionIterator&&) = default;
0118   ~MeasurementMutableCollectionIterator() = default;
0119 
0120   auto operator<=>(const MeasurementMutableCollectionIterator& other) const {
0121     return m_index <=> other.m_index;
0122   }
0123 
0124   bool operator==(const MeasurementMutableCollectionIterator& x) const {
0125     return m_index == x.m_index;
0126   }
0127 
0128   reference operator*() const;
0129   pointer operator->();
0130   MeasurementMutableCollectionIterator& operator++();
0131   MeasurementMutableCollectionIterator operator++(int);
0132   MeasurementMutableCollectionIterator& operator--();
0133   MeasurementMutableCollectionIterator operator--(int);
0134   MeasurementMutableCollectionIterator& operator+=(difference_type n);
0135   MeasurementMutableCollectionIterator operator+(difference_type n) const;
0136   friend MeasurementMutableCollectionIterator operator+(
0137       difference_type n, const MeasurementMutableCollectionIterator& it);
0138   MeasurementMutableCollectionIterator& operator-=(difference_type n);
0139   MeasurementMutableCollectionIterator operator-(difference_type n) const;
0140   reference operator[](difference_type n) const;
0141   difference_type operator-(
0142       const MeasurementMutableCollectionIterator& other) const;
0143 
0144  private:
0145   size_t m_index{0};
0146   MutableMeasurement m_object{
0147       podio::utils::MaybeSharedPtr<MeasurementObj>{nullptr}};
0148   const MeasurementObjPointerContainer* m_collection{nullptr};
0149 };
0150 
0151 /**
0152 A Collection is identified by an ID.
0153 */
0154 class MeasurementCollection : public podio::CollectionBase {
0155  public:
0156   using value_type = Measurement;
0157   using mutable_type = MutableMeasurement;
0158   using const_iterator = MeasurementCollectionIterator;
0159   using iterator = MeasurementMutableCollectionIterator;
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   MeasurementCollection() = default;
0166   MeasurementCollection(MeasurementCollectionData&& data, bool isSubsetColl);
0167   // This is a move-only type
0168   MeasurementCollection(const MeasurementCollection&) = delete;
0169   MeasurementCollection& operator=(const MeasurementCollection&) = delete;
0170   MeasurementCollection(MeasurementCollection&&) = default;
0171   MeasurementCollection& operator=(MeasurementCollection&&) = default;
0172 
0173   //  MeasurementCollection(MeasurementVector* data, uint32_t collectionID);
0174   ~MeasurementCollection() override;
0175 
0176   constexpr static std::string_view typeName =
0177       "ActsPodioEdm::MeasurementCollection";
0178   constexpr static std::string_view valueTypeName = "ActsPodioEdm::Measurement";
0179   constexpr static std::string_view dataTypeName =
0180       "ActsPodioEdm::MeasurementData";
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   MutableMeasurement 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   MutableMeasurement 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   Measurement operator[](std::size_t index) const;
0227   /// Returns the object of a given index
0228   MutableMeasurement operator[](std::size_t index);
0229   /// Returns the const object of given index
0230   Measurement at(std::size_t index) const;
0231   /// Returns the object of given index
0232   MutableMeasurement at(std::size_t index);
0233 
0234   /// Append object to the collection
0235   void push_back(const MutableMeasurement& object);
0236   /// Append an object to the (subset) collection
0237   void push_back(const Measurement& 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](MeasurementObj* 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<std::uint64_t> geometryId(const size_t nElem = 0) const;
0299 
0300  private:
0301   // For setReferences, we need to give our own CollectionData access to our
0302   // private entries. Otherwise we would need to expose a public member function
0303   // that gives access to the Obj* which is definitely not what we want
0304   friend class MeasurementCollectionData;
0305 
0306   mutable bool m_isPrepared{false};
0307   bool m_isSubsetColl{false};
0308   uint32_t m_collectionID{static_cast<uint32_t>(podio::ObjectID::untracked)};
0309   mutable std::unique_ptr<std::mutex> m_storageMtx{
0310       std::make_unique<std::mutex>()};
0311   mutable MeasurementCollectionData m_storage{};
0312 };
0313 
0314 std::ostream& operator<<(std::ostream& o, const MeasurementCollection& v);
0315 
0316 template <typename... Args>
0317 MutableMeasurement MeasurementCollection::create(Args&&... args) {
0318   if (m_isSubsetColl) {
0319     throw std::logic_error("Cannot create new elements on a subset collection");
0320   }
0321   auto obj = new MeasurementObj(
0322       {static_cast<int>(m_storage.entries.size()), m_collectionID},
0323       {std::forward<Args>(args)...});
0324   m_storage.entries.push_back(obj);
0325 
0326   // Need to initialize the relation vectors manually for the {ObjectID,
0327   // MeasurementData} constructor
0328   obj->m_indices = new std::vector<std::uint16_t>();
0329   obj->m_parameterValues = new std::vector<double>();
0330   obj->m_covarianceValues = new std::vector<double>();
0331   m_storage.createRelations(obj);
0332   return MutableMeasurement(podio::utils::MaybeSharedPtr(obj));
0333 }
0334 
0335 #if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
0336 void to_json(nlohmann::json& j, const MeasurementCollection& collection);
0337 #endif
0338 
0339 }  // namespace ActsPodioEdm
0340 
0341 // This is needed to avoid triggering opening every library in LD_LIBRARY_PATH
0342 // until it's fixed in ROOT. See
0343 // https://github.com/root-project/root/issues/18489 and
0344 // https://github.com/AIDASoft/podio/issues/770
0345 #if defined(__clang__)
0346 #pragma clang diagnostic push
0347 #pragma clang diagnostic ignored "-Wunknown-warning-option"
0348 #pragma clang diagnostic ignored "-Wdeprecated-redundant-constexpr-static-def"
0349 #pragma clang diagnostic ignored "-Wdeprecated"
0350 constexpr std::string_view ActsPodioEdm::MeasurementCollection::typeName;
0351 constexpr std::string_view ActsPodioEdm::MeasurementCollection::valueTypeName;
0352 constexpr std::string_view ActsPodioEdm::MeasurementCollection::dataTypeName;
0353 #pragma clang diagnostic pop
0354 #elif defined(__GNUC__)
0355 #pragma GCC diagnostic push
0356 #pragma GCC diagnostic ignored "-Wdeprecated"
0357 constexpr std::string_view ActsPodioEdm::MeasurementCollection::typeName;
0358 constexpr std::string_view ActsPodioEdm::MeasurementCollection::valueTypeName;
0359 constexpr std::string_view ActsPodioEdm::MeasurementCollection::dataTypeName;
0360 #pragma GCC diagnostic pop
0361 #endif
0362 
0363 #endif