Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:28:05

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