Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-17 08:21:54

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