Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-16 08:58:59

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