Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-07-05 08:26:43

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