Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-08 10:22:59

0001 // AUTOMATICALLY GENERATED FILE - DO NOT EDIT
0002 
0003 #ifndef PODIODATAMODEL_ExampleHitCollection_H
0004 #define PODIODATAMODEL_ExampleHitCollection_H
0005 
0006 // datamodel specific includes
0007 #include "PodioDatamodel/ExampleHit.h"
0008 #include "PodioDatamodel/MutableExampleHit.h"
0009 #include "PodioDatamodel/ExampleHitObj.h"
0010 #include "PodioDatamodel/ExampleHitCollectionData.h"
0011 
0012 // podio specific includes
0013 #include "podio/ICollectionProvider.h"
0014 #include "podio/CollectionBase.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 <string_view>
0022 #include <vector>
0023 #include <algorithm>
0024 #include <ostream>
0025 #include <mutex>
0026 #include <memory>
0027 #include <cstddef>
0028 
0029 namespace podio {
0030   struct RelationNames;
0031 }
0032 
0033 
0034 
0035 
0036 class ExampleHitCollectionIterator {
0037 public:
0038   using value_type = ExampleHit;
0039   using difference_type = ptrdiff_t;
0040   using reference = ExampleHit;
0041   using pointer = ExampleHit*;
0042   using iterator_category = std::input_iterator_tag;
0043   // `std::forward_iterator` is supported except that the pointers obtained with `operator->()`
0044   // remain valid as long as the iterator is valid, not as long as the range is valid.
0045   using iterator_concept = std::random_access_iterator_tag;
0046 
0047   ExampleHitCollectionIterator(size_t index, const ExampleHitObjPointerContainer* collection) : m_index(index), m_object(podio::utils::MaybeSharedPtr<ExampleHitObj>{nullptr}), m_collection(collection) {}
0048   ExampleHitCollectionIterator() = default;
0049 
0050   ExampleHitCollectionIterator(const ExampleHitCollectionIterator&) = default;
0051   ExampleHitCollectionIterator(ExampleHitCollectionIterator&&) = default;
0052   ExampleHitCollectionIterator& operator=(const ExampleHitCollectionIterator&) = default;
0053   ExampleHitCollectionIterator& operator=(ExampleHitCollectionIterator&&) = default;
0054   ~ExampleHitCollectionIterator() = default;
0055 
0056   auto operator<=>(const ExampleHitCollectionIterator& other) const {
0057     return m_index <=> other.m_index;
0058   }
0059 
0060   bool operator==(const ExampleHitCollectionIterator& x) const {
0061     return m_index ==  x.m_index;
0062   }
0063 
0064   reference operator*() const;
0065   pointer operator->();
0066   ExampleHitCollectionIterator& operator++();
0067   ExampleHitCollectionIterator operator++(int);
0068   ExampleHitCollectionIterator& operator--();
0069   ExampleHitCollectionIterator operator--(int);
0070   ExampleHitCollectionIterator& operator+=(difference_type n);
0071   ExampleHitCollectionIterator operator+(difference_type n) const;
0072   friend ExampleHitCollectionIterator operator+(difference_type n, const ExampleHitCollectionIterator& it);
0073   ExampleHitCollectionIterator& operator-=(difference_type n);
0074   ExampleHitCollectionIterator operator-(difference_type n) const;
0075   reference operator[](difference_type n) const;
0076   difference_type operator-(const ExampleHitCollectionIterator& other) const;
0077 
0078 private:
0079   size_t m_index{0};
0080   ExampleHit m_object { podio::utils::MaybeSharedPtr<ExampleHitObj>{nullptr} };
0081   const ExampleHitObjPointerContainer* m_collection{nullptr};
0082 };
0083 
0084 
0085 class ExampleHitMutableCollectionIterator {
0086 public:
0087   using value_type = ExampleHit;
0088   using difference_type = ptrdiff_t;
0089   using reference = MutableExampleHit;
0090   using pointer = MutableExampleHit*;
0091   using iterator_category = std::input_iterator_tag;
0092   // `std::forward_iterator` is supported except that the pointers obtained with `operator->()`
0093   // remain valid as long as the iterator is valid, not as long as the range is valid.
0094   using iterator_concept = std::random_access_iterator_tag;
0095 
0096   ExampleHitMutableCollectionIterator(size_t index, const ExampleHitObjPointerContainer* collection) : m_index(index), m_object(podio::utils::MaybeSharedPtr<ExampleHitObj>{nullptr}), m_collection(collection) {}
0097   ExampleHitMutableCollectionIterator() = default;
0098 
0099   ExampleHitMutableCollectionIterator(const ExampleHitMutableCollectionIterator&) = default;
0100   ExampleHitMutableCollectionIterator(ExampleHitMutableCollectionIterator&&) = default;
0101   ExampleHitMutableCollectionIterator& operator=(const ExampleHitMutableCollectionIterator&) = default;
0102   ExampleHitMutableCollectionIterator& operator=(ExampleHitMutableCollectionIterator&&) = default;
0103   ~ExampleHitMutableCollectionIterator() = default;
0104 
0105   auto operator<=>(const ExampleHitMutableCollectionIterator& other) const {
0106     return m_index <=> other.m_index;
0107   }
0108 
0109   bool operator==(const ExampleHitMutableCollectionIterator& x) const {
0110     return m_index ==  x.m_index;
0111   }
0112 
0113   reference operator*() const;
0114   pointer operator->();
0115   ExampleHitMutableCollectionIterator& operator++();
0116   ExampleHitMutableCollectionIterator operator++(int);
0117   ExampleHitMutableCollectionIterator& operator--();
0118   ExampleHitMutableCollectionIterator operator--(int);
0119   ExampleHitMutableCollectionIterator& operator+=(difference_type n);
0120   ExampleHitMutableCollectionIterator operator+(difference_type n) const;
0121   friend ExampleHitMutableCollectionIterator operator+(difference_type n, const ExampleHitMutableCollectionIterator& it);
0122   ExampleHitMutableCollectionIterator& operator-=(difference_type n);
0123   ExampleHitMutableCollectionIterator operator-(difference_type n) const;
0124   reference operator[](difference_type n) const;
0125   difference_type operator-(const ExampleHitMutableCollectionIterator& other) const;
0126 
0127 private:
0128   size_t m_index{0};
0129   MutableExampleHit m_object { podio::utils::MaybeSharedPtr<ExampleHitObj>{nullptr} };
0130   const ExampleHitObjPointerContainer* m_collection{nullptr};
0131 };
0132 
0133 
0134 /**
0135 A Collection is identified by an ID.
0136 */
0137 class ExampleHitCollection : public podio::CollectionBase {
0138 public:
0139   using value_type = ExampleHit;
0140   using mutable_type = MutableExampleHit;
0141   using const_iterator = ExampleHitCollectionIterator;
0142   using iterator = ExampleHitMutableCollectionIterator;
0143   using difference_type = ptrdiff_t;
0144   using size_type = size_t;
0145   using const_reverse_iterator = std::reverse_iterator<const_iterator>;
0146   using reverse_iterator = std::reverse_iterator<iterator>;
0147 
0148   ExampleHitCollection() = default;
0149   ExampleHitCollection(ExampleHitCollectionData&& data, bool isSubsetColl);
0150   // This is a move-only type
0151   ExampleHitCollection(const ExampleHitCollection& ) = delete;
0152   ExampleHitCollection& operator=(const ExampleHitCollection& ) = delete;
0153   ExampleHitCollection(ExampleHitCollection&&) = default;
0154   ExampleHitCollection& operator=(ExampleHitCollection&&) = default;
0155 
0156 //  ExampleHitCollection(ExampleHitVector* data, uint32_t collectionID);
0157   ~ExampleHitCollection() override;
0158 
0159   constexpr static std::string_view typeName = "ExampleHitCollection";
0160   constexpr static std::string_view valueTypeName = "ExampleHit";
0161   constexpr static std::string_view dataTypeName = "ExampleHitData";
0162 
0163   void clear() final;
0164 
0165   /// Cppyy protocol to setup the pythonizations for this class. Not to be called directly.
0166   static void __cppyy_pythonize__(PyObject* klass, const std::string& name){
0167         podio::detail::pythonizations::pythonize_subscript(klass, name);
0168   }
0169 
0170   /// Print this collection to the passed stream
0171   void print(std::ostream& os=std::cout, bool flush=true) const final;
0172 
0173   /// Append a new object to the collection, and return this object.
0174   MutableExampleHit create();
0175 
0176   /// Append a new object to the collection, and return this object.
0177   /// Initialized with the parameters given
0178   template<typename... Args>
0179   MutableExampleHit create(Args&&... args);
0180 
0181   /// number of elements in the collection
0182   std::size_t size() const final;
0183 
0184   /// maximal number of elements in the collection
0185   std::size_t max_size() const final;
0186 
0187   /// Is the collection empty
0188   bool empty() const final;
0189 
0190   /// fully qualified type name
0191   const std::string_view getTypeName() const final { return typeName; }
0192   /// fully qualified type name of elements - with namespace
0193   const std::string_view getValueTypeName() const final { return valueTypeName; }
0194   /// fully qualified type name of stored POD elements - with namespace
0195   const std::string_view getDataTypeName() const final { return dataTypeName; }
0196   /// schema version
0197   podio::SchemaVersionT getSchemaVersion() const final;
0198 
0199   bool isSubsetCollection() const final {
0200     return m_isSubsetColl;
0201   }
0202 
0203   void setSubsetCollection(bool setSubset=true) final;
0204 
0205   /// Returns the const object of given index
0206   ExampleHit operator[](std::size_t index) const;
0207   /// Returns the object of a given index
0208   MutableExampleHit operator[](std::size_t index);
0209   /// Returns the const object of given index
0210   ExampleHit at(std::size_t index) const;
0211   /// Returns the object of given index
0212   MutableExampleHit at(std::size_t index);
0213 
0214 
0215   /// Append object to the collection
0216   void push_back(const MutableExampleHit& object);
0217   /// Append an object to the (subset) collection
0218   void push_back(const ExampleHit& object);
0219 
0220   void prepareForWrite() const final;
0221   void prepareAfterRead() final;
0222   bool setReferences(const podio::ICollectionProvider* collectionProvider) final;
0223 
0224   /// Get the collection buffers for this collection
0225   podio::CollectionWriteBuffers getBuffers() final;
0226 
0227   void setID(uint32_t ID) final {
0228     m_collectionID = ID;
0229     if (!m_isSubsetColl) {
0230       std::for_each(m_storage.entries.begin(), m_storage.entries.end(),
0231                   [ID] (ExampleHitObj* obj) { obj->id = {obj->id.index, static_cast<uint32_t>(ID)}; }
0232       );
0233     }
0234   }
0235 
0236   uint32_t getID() const final {
0237     return m_collectionID;
0238   }
0239 
0240   /// check if the collection has a valid ID
0241   bool hasID() const final {
0242     return getID() != static_cast<uint32_t>(podio::ObjectID::untracked) &&
0243         getID() != static_cast<uint32_t>(podio::ObjectID::invalid);
0244   }
0245 
0246   [[deprecated("isValid will be removed, use hasID() if you want to check if it has an ID, otherwise assume the "
0247                "collection is valid")]]
0248   bool isValid() const final {
0249     return hasID();
0250   }
0251 
0252   size_t getDatamodelRegistryIndex() const final;
0253 
0254   // support for the iterator protocol
0255   iterator begin() {
0256     return iterator(0, &m_storage.entries);
0257   }
0258   const_iterator begin() const {
0259     return const_iterator(0, &m_storage.entries);
0260   }
0261   const_iterator cbegin() const {
0262     return begin();
0263   }
0264   iterator end() {
0265     return iterator(m_storage.entries.size(), &m_storage.entries);
0266   }
0267   const_iterator end() const {
0268     return const_iterator(m_storage.entries.size(), &m_storage.entries);
0269   }
0270   const_iterator cend() const {
0271     return end();
0272   }
0273   // reverse iterators
0274   reverse_iterator rbegin() {
0275     return reverse_iterator(end());
0276   }
0277   const_reverse_iterator rbegin() const {
0278     return const_reverse_iterator(end());
0279   }
0280   const_reverse_iterator crbegin() const {
0281     return rbegin();
0282   }
0283   reverse_iterator rend() {
0284     return reverse_iterator(begin());
0285   }
0286   const_reverse_iterator rend() const {
0287     return const_reverse_iterator(begin());
0288   }
0289   const_reverse_iterator crend() const {
0290     return rend();
0291   }
0292 
0293 
0294   std::vector<std::uint64_t> cellID(const size_t nElem = 0) const;
0295   std::vector<double> x(const size_t nElem = 0) const;
0296   std::vector<double> y(const size_t nElem = 0) const;
0297   std::vector<double> z(const size_t nElem = 0) const;
0298   std::vector<double> energy(const size_t nElem = 0) const;
0299   std::vector<std::uint64_t> time(const size_t nElem = 0) const;
0300 
0301 private:
0302   // For setReferences, we need to give our own CollectionData access to our
0303   // private entries. Otherwise we would need to expose a public member function
0304   // that gives access to the Obj* which is definitely not what we want
0305   friend class ExampleHitCollectionData;
0306 
0307   mutable bool m_isPrepared{false};
0308   bool m_isSubsetColl{false};
0309   uint32_t m_collectionID{static_cast<uint32_t>(podio::ObjectID::untracked)};
0310   mutable std::unique_ptr<std::mutex> m_storageMtx{std::make_unique<std::mutex>()};
0311   mutable ExampleHitCollectionData m_storage{};
0312 };
0313 
0314 std::ostream& operator<<(std::ostream& o, const ExampleHitCollection& v);
0315 
0316 template<typename... Args>
0317 MutableExampleHit ExampleHitCollection::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 ExampleHitObj({static_cast<int>(m_storage.entries.size()), m_collectionID}, {std::forward<Args>(args)...});
0322   m_storage.entries.push_back(obj);
0323 
0324   return MutableExampleHit(podio::utils::MaybeSharedPtr(obj));
0325 }
0326 
0327 #if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
0328 void to_json(nlohmann::json& j, const ExampleHitCollection& collection);
0329 #endif
0330 
0331 
0332 
0333 // This is needed to avoid triggering opening every library in LD_LIBRARY_PATH
0334 // until it's fixed in ROOT. See https://github.com/root-project/root/issues/18489
0335 // and https://github.com/AIDASoft/podio/issues/770
0336 #if defined(__clang__)
0337   #pragma clang diagnostic push
0338   #pragma clang diagnostic ignored "-Wunknown-warning-option"
0339   #pragma clang diagnostic ignored "-Wdeprecated-redundant-constexpr-static-def"
0340   #pragma clang diagnostic ignored "-Wdeprecated"
0341 constexpr std::string_view ExampleHitCollection::typeName;
0342 constexpr std::string_view ExampleHitCollection::valueTypeName;
0343 constexpr std::string_view ExampleHitCollection::dataTypeName;
0344   #pragma clang diagnostic pop
0345 #elif defined(__GNUC__)
0346   #pragma GCC diagnostic push
0347   #pragma GCC diagnostic ignored "-Wdeprecated"
0348 constexpr std::string_view ExampleHitCollection::typeName;
0349 constexpr std::string_view ExampleHitCollection::valueTypeName;
0350 constexpr std::string_view ExampleHitCollection::dataTypeName;
0351   #pragma GCC diagnostic pop
0352 #endif
0353 
0354 
0355 #endif