Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-07-01 08:08:14

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