EDM4eic
EIC data model
Loading...
Searching...
No Matches
TrackProtoClusterMatchCollection.h
Go to the documentation of this file.
1// AUTOMATICALLY GENERATED FILE - DO NOT EDIT
2
3#ifndef EDM4EIC_TrackProtoClusterMatchCollection_H
4#define EDM4EIC_TrackProtoClusterMatchCollection_H
5
6// datamodel specific includes
11
12// podio specific includes
13#include "podio/ICollectionProvider.h"
14#include "podio/CollectionBase.h"
15
16#if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
17#include "nlohmann/json_fwd.hpp"
18#endif
19
20#include <string_view>
21#include <vector>
22#include <algorithm>
23#include <ostream>
24#include <mutex>
25#include <memory>
26#include <cstddef>
27
28namespace podio {
29 struct RelationNames;
30}
31
32namespace edm4eic {
33
34
35
37public:
39 using difference_type = ptrdiff_t;
42 using iterator_category = std::input_iterator_tag;
43 // `std::forward_iterator` is supported except that the pointers obtained with `operator->()`
44 // remain valid as long as the iterator is valid, not as long as the range is valid.
45 using iterator_concept = std::random_access_iterator_tag;
46
47 TrackProtoClusterMatchCollectionIterator(size_t index, const TrackProtoClusterMatchObjPointerContainer* collection) : m_index(index), m_object(podio::utils::MaybeSharedPtr<TrackProtoClusterMatchObj>{nullptr}), m_collection(collection) {}
49
55
57 return m_index <=> other.m_index;
58 }
59
61 return m_index == x.m_index;
62 }
63
64 reference operator*() const;
77
78private:
79 size_t m_index{0};
80 TrackProtoClusterMatch m_object { podio::utils::MaybeSharedPtr<TrackProtoClusterMatchObj>{nullptr} };
81 const TrackProtoClusterMatchObjPointerContainer* m_collection{nullptr};
82};
83
84
86public:
88 using difference_type = ptrdiff_t;
91 using iterator_category = std::input_iterator_tag;
92 // `std::forward_iterator` is supported except that the pointers obtained with `operator->()`
93 // remain valid as long as the iterator is valid, not as long as the range is valid.
94 using iterator_concept = std::random_access_iterator_tag;
95
96 TrackProtoClusterMatchMutableCollectionIterator(size_t index, const TrackProtoClusterMatchObjPointerContainer* collection) : m_index(index), m_object(podio::utils::MaybeSharedPtr<TrackProtoClusterMatchObj>{nullptr}), m_collection(collection) {}
98
104
106 return m_index <=> other.m_index;
107 }
108
110 return m_index == x.m_index;
111 }
112
113 reference operator*() const;
126
127private:
128 size_t m_index{0};
129 MutableTrackProtoClusterMatch m_object { podio::utils::MaybeSharedPtr<TrackProtoClusterMatchObj>{nullptr} };
130 const TrackProtoClusterMatchObjPointerContainer* m_collection{nullptr};
131};
132
133
134/**
135A Collection is identified by an ID.
136*/
137class TrackProtoClusterMatchCollection : public podio::CollectionBase {
138public:
143 using difference_type = ptrdiff_t;
144 using size_type = size_t;
145 using const_reverse_iterator = std::reverse_iterator<const_iterator>;
146 using reverse_iterator = std::reverse_iterator<iterator>;
147
150 // This is a move-only type
155
156// TrackProtoClusterMatchCollection(TrackProtoClusterMatchVector* data, uint32_t collectionID);
158
159 constexpr static std::string_view typeName = "edm4eic::TrackProtoClusterMatchCollection";
160 constexpr static std::string_view valueTypeName = "edm4eic::TrackProtoClusterMatch";
161 constexpr static std::string_view dataTypeName = "edm4eic::TrackProtoClusterMatchData";
162
163 void clear() final;
164
165 /// Print this collection to the passed stream
166 void print(std::ostream& os=std::cout, bool flush=true) const final;
167
168 /// operator to allow pointer like calling of members a la LCIO
169 TrackProtoClusterMatchCollection* operator->() { return static_cast<TrackProtoClusterMatchCollection*>(this); }
170
171 /// Append a new object to the collection, and return this object.
173
174 /// Append a new object to the collection, and return this object.
175 /// Initialized with the parameters given
176 template<typename... Args>
178
179 /// number of elements in the collection
180 std::size_t size() const final;
181
182 /// maximal number of elements in the collection
183 std::size_t max_size() const final;
184
185 /// Is the collection empty
186 bool empty() const final;
187
188 /// fully qualified type name
189 const std::string_view getTypeName() const final { return typeName; }
190 /// fully qualified type name of elements - with namespace
191 const std::string_view getValueTypeName() const final { return valueTypeName; }
192 /// fully qualified type name of stored POD elements - with namespace
193 const std::string_view getDataTypeName() const final { return dataTypeName; }
194 /// schema version
195 podio::SchemaVersionT getSchemaVersion() const final;
196
197 bool isSubsetCollection() const final {
198 return m_isSubsetColl;
199 }
200
201 void setSubsetCollection(bool setSubset=true) final;
202
203 /// Returns the const object of given index
204 TrackProtoClusterMatch operator[](std::size_t index) const;
205 /// Returns the object of a given index
206 MutableTrackProtoClusterMatch operator[](std::size_t index);
207 /// Returns the const object of given index
208 TrackProtoClusterMatch at(std::size_t index) const;
209 /// Returns the object of given index
210 MutableTrackProtoClusterMatch at(std::size_t index);
211
212
213 /// Append object to the collection
214 void push_back(const MutableTrackProtoClusterMatch& object);
215 /// Append an object to the (subset) collection
216 void push_back(const TrackProtoClusterMatch& object);
217
218 void prepareForWrite() const final;
219 void prepareAfterRead() final;
220 bool setReferences(const podio::ICollectionProvider* collectionProvider) final;
221
222 /// Get the collection buffers for this collection
223 podio::CollectionWriteBuffers getBuffers() final;
224
225 void setID(uint32_t ID) final {
226 m_collectionID = ID;
227 if (!m_isSubsetColl) {
228 std::for_each(m_storage.entries.begin(), m_storage.entries.end(),
229 [ID] (TrackProtoClusterMatchObj* obj) { obj->id = {obj->id.index, static_cast<uint32_t>(ID)}; }
230 );
231 }
232 m_isValid = true;
233 }
234
235 uint32_t getID() const final {
236 return m_collectionID;
237 }
238
239 bool isValid() const final {
240 return m_isValid;
241 }
242
243 size_t getDatamodelRegistryIndex() const final;
244
245 // support for the iterator protocol
247 return iterator(0, &m_storage.entries);
248 }
250 return const_iterator(0, &m_storage.entries);
251 }
253 return begin();
254 }
256 return iterator(m_storage.entries.size(), &m_storage.entries);
257 }
259 return const_iterator(m_storage.entries.size(), &m_storage.entries);
260 }
262 return end();
263 }
264 // reverse iterators
266 return reverse_iterator(end());
267 }
272 return rbegin();
273 }
275 return reverse_iterator(begin());
276 }
281 return rend();
282 }
283
284
285 std::vector<float> weight(const size_t nElem = 0) const;
286
287private:
288 // For setReferences, we need to give our own CollectionData access to our
289 // private entries. Otherwise we would need to expose a public member function
290 // that gives access to the Obj* which is definitely not what we want
292
293 bool m_isValid{false};
294 mutable bool m_isPrepared{false};
295 bool m_isSubsetColl{false};
296 uint32_t m_collectionID{0};
297 mutable std::unique_ptr<std::mutex> m_storageMtx{nullptr};
298 mutable TrackProtoClusterMatchCollectionData m_storage{};
299};
300
301std::ostream& operator<<(std::ostream& o, const TrackProtoClusterMatchCollection& v);
302
303template<typename... Args>
305 if (m_isSubsetColl) {
306 throw std::logic_error("Cannot create new elements on a subset collection");
307 }
308 const int size = m_storage.entries.size();
309 auto obj = new TrackProtoClusterMatchObj({size, m_collectionID}, {std::forward<Args>(args)...});
310 m_storage.entries.push_back(obj);
311
312 return MutableTrackProtoClusterMatch(podio::utils::MaybeSharedPtr(obj));
313}
314
315#if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
316void to_json(nlohmann::json& j, const TrackProtoClusterMatchCollection& collection);
317#endif
318
319} // namespace edm4eic
320
321
322#endif
Definition MutableTrackProtoClusterMatch.h:36
Definition TrackProtoClusterMatchCollectionData.h:32
Definition TrackProtoClusterMatchCollection.h:137
TrackProtoClusterMatchMutableCollectionIterator iterator
Definition TrackProtoClusterMatchCollection.h:142
iterator end()
Definition TrackProtoClusterMatchCollection.h:255
const std::string_view getTypeName() const final
fully qualified type name
Definition TrackProtoClusterMatchCollection.h:189
std::size_t size() const final
number of elements in the collection
Definition TrackProtoClusterMatchCollection.cc:52
std::size_t max_size() const final
maximal number of elements in the collection
Definition TrackProtoClusterMatchCollection.cc:56
void print(std::ostream &os=std::cout, bool flush=true) const final
Print this collection to the passed stream.
Definition TrackProtoClusterMatchCollection.cc:435
MutableTrackProtoClusterMatch create()
Append a new object to the collection, and return this object.
Definition TrackProtoClusterMatchCollection.cc:81
void prepareAfterRead() final
Definition TrackProtoClusterMatchCollection.cc:106
ptrdiff_t difference_type
Definition TrackProtoClusterMatchCollection.h:143
podio::SchemaVersionT getSchemaVersion() const final
schema version
Definition TrackProtoClusterMatchCollection.cc:176
TrackProtoClusterMatch at(std::size_t index) const
Returns the const object of given index.
Definition TrackProtoClusterMatchCollection.cc:40
const std::string_view getValueTypeName() const final
fully qualified type name of elements - with namespace
Definition TrackProtoClusterMatchCollection.h:191
const_iterator cbegin() const
Definition TrackProtoClusterMatchCollection.h:252
TrackProtoClusterMatchCollection(const TrackProtoClusterMatchCollection &)=delete
void prepareForWrite() const final
Definition TrackProtoClusterMatchCollection.cc:97
reverse_iterator rbegin()
Definition TrackProtoClusterMatchCollection.h:265
void push_back(const MutableTrackProtoClusterMatch &object)
Append object to the collection.
Definition TrackProtoClusterMatchCollection.cc:125
const_reverse_iterator rbegin() const
Definition TrackProtoClusterMatchCollection.h:268
std::reverse_iterator< const_iterator > const_reverse_iterator
Definition TrackProtoClusterMatchCollection.h:145
bool setReferences(const podio::ICollectionProvider *collectionProvider) final
Definition TrackProtoClusterMatchCollection.cc:121
size_t size_type
Definition TrackProtoClusterMatchCollection.h:144
const_reverse_iterator rend() const
Definition TrackProtoClusterMatchCollection.h:277
TrackProtoClusterMatchCollectionIterator const_iterator
Definition TrackProtoClusterMatchCollection.h:141
const_reverse_iterator crbegin() const
Definition TrackProtoClusterMatchCollection.h:271
const_iterator begin() const
Definition TrackProtoClusterMatchCollection.h:249
static constexpr std::string_view typeName
Definition TrackProtoClusterMatchCollection.h:159
iterator begin()
Definition TrackProtoClusterMatchCollection.h:246
reverse_iterator rend()
Definition TrackProtoClusterMatchCollection.h:274
TrackProtoClusterMatchCollection & operator=(TrackProtoClusterMatchCollection &&)=default
TrackProtoClusterMatchCollection(TrackProtoClusterMatchCollection &&)=default
MutableTrackProtoClusterMatch mutable_type
Definition TrackProtoClusterMatchCollection.h:140
TrackProtoClusterMatchCollection()
Definition TrackProtoClusterMatchCollection.cc:25
TrackProtoClusterMatchCollection & operator=(const TrackProtoClusterMatchCollection &)=delete
const_iterator cend() const
Definition TrackProtoClusterMatchCollection.h:261
void setID(uint32_t ID) final
Definition TrackProtoClusterMatchCollection.h:225
uint32_t getID() const final
Definition TrackProtoClusterMatchCollection.h:235
bool isValid() const final
Definition TrackProtoClusterMatchCollection.h:239
bool isSubsetCollection() const final
Definition TrackProtoClusterMatchCollection.h:197
static constexpr std::string_view dataTypeName
Definition TrackProtoClusterMatchCollection.h:161
bool empty() const final
Is the collection empty.
Definition TrackProtoClusterMatchCollection.cc:66
~TrackProtoClusterMatchCollection() override
Definition TrackProtoClusterMatchCollection.cc:31
const_reverse_iterator crend() const
Definition TrackProtoClusterMatchCollection.h:280
void clear() final
Definition TrackProtoClusterMatchCollection.cc:92
void setSubsetCollection(bool setSubset=true) final
Definition TrackProtoClusterMatchCollection.cc:70
TrackProtoClusterMatch value_type
Definition TrackProtoClusterMatchCollection.h:139
podio::CollectionWriteBuffers getBuffers() final
Get the collection buffers for this collection.
Definition TrackProtoClusterMatchCollection.cc:157
const std::string_view getDataTypeName() const final
fully qualified type name of stored POD elements - with namespace
Definition TrackProtoClusterMatchCollection.h:193
friend class TrackProtoClusterMatchCollectionData
Definition TrackProtoClusterMatchCollection.h:291
static constexpr std::string_view valueTypeName
Definition TrackProtoClusterMatchCollection.h:160
std::reverse_iterator< iterator > reverse_iterator
Definition TrackProtoClusterMatchCollection.h:146
const_iterator end() const
Definition TrackProtoClusterMatchCollection.h:258
Definition TrackProtoClusterMatchCollection.h:36
TrackProtoClusterMatchCollectionIterator & operator--()
Definition TrackProtoClusterMatchCollection.cc:299
reference operator[](difference_type n) const
Definition TrackProtoClusterMatchCollection.cc:336
TrackProtoClusterMatchCollectionIterator & operator=(const TrackProtoClusterMatchCollectionIterator &)=default
TrackProtoClusterMatchCollectionIterator operator-(difference_type n) const
Definition TrackProtoClusterMatchCollection.cc:330
reference operator*() const
Definition TrackProtoClusterMatchCollection.cc:279
TrackProtoClusterMatchCollectionIterator(size_t index, const TrackProtoClusterMatchObjPointerContainer *collection)
Definition TrackProtoClusterMatchCollection.h:47
pointer operator->()
Definition TrackProtoClusterMatchCollection.cc:283
TrackProtoClusterMatchCollectionIterator(TrackProtoClusterMatchCollectionIterator &&)=default
bool operator==(const TrackProtoClusterMatchCollectionIterator &x) const
Definition TrackProtoClusterMatchCollection.h:60
ptrdiff_t difference_type
Definition TrackProtoClusterMatchCollection.h:39
TrackProtoClusterMatchCollectionIterator & operator++()
Definition TrackProtoClusterMatchCollection.cc:288
std::random_access_iterator_tag iterator_concept
Definition TrackProtoClusterMatchCollection.h:45
TrackProtoClusterMatch value_type
Definition TrackProtoClusterMatchCollection.h:38
std::input_iterator_tag iterator_category
Definition TrackProtoClusterMatchCollection.h:42
TrackProtoClusterMatchCollectionIterator & operator-=(difference_type n)
Definition TrackProtoClusterMatchCollection.cc:325
TrackProtoClusterMatchCollectionIterator & operator+=(difference_type n)
Definition TrackProtoClusterMatchCollection.cc:310
TrackProtoClusterMatch reference
Definition TrackProtoClusterMatchCollection.h:40
TrackProtoClusterMatchCollectionIterator(const TrackProtoClusterMatchCollectionIterator &)=default
auto operator<=>(const TrackProtoClusterMatchCollectionIterator &other) const
Definition TrackProtoClusterMatchCollection.h:56
TrackProtoClusterMatch * pointer
Definition TrackProtoClusterMatchCollection.h:41
TrackProtoClusterMatchCollectionIterator operator+(difference_type n) const
Definition TrackProtoClusterMatchCollection.cc:315
TrackProtoClusterMatchCollectionIterator & operator=(TrackProtoClusterMatchCollectionIterator &&)=default
Definition TrackProtoClusterMatch.h:44
Definition TrackProtoClusterMatchCollection.h:85
reference operator[](difference_type n) const
Definition TrackProtoClusterMatchCollection.cc:403
MutableTrackProtoClusterMatch reference
Definition TrackProtoClusterMatchCollection.h:89
std::input_iterator_tag iterator_category
Definition TrackProtoClusterMatchCollection.h:91
TrackProtoClusterMatchMutableCollectionIterator operator+(difference_type n) const
Definition TrackProtoClusterMatchCollection.cc:382
pointer operator->()
Definition TrackProtoClusterMatchCollection.cc:350
ptrdiff_t difference_type
Definition TrackProtoClusterMatchCollection.h:88
TrackProtoClusterMatchMutableCollectionIterator & operator+=(difference_type n)
Definition TrackProtoClusterMatchCollection.cc:377
TrackProtoClusterMatchMutableCollectionIterator operator-(difference_type n) const
Definition TrackProtoClusterMatchCollection.cc:397
TrackProtoClusterMatchMutableCollectionIterator & operator++()
Definition TrackProtoClusterMatchCollection.cc:355
TrackProtoClusterMatch value_type
Definition TrackProtoClusterMatchCollection.h:87
TrackProtoClusterMatchMutableCollectionIterator(size_t index, const TrackProtoClusterMatchObjPointerContainer *collection)
Definition TrackProtoClusterMatchCollection.h:96
MutableTrackProtoClusterMatch * pointer
Definition TrackProtoClusterMatchCollection.h:90
TrackProtoClusterMatchMutableCollectionIterator & operator--()
Definition TrackProtoClusterMatchCollection.cc:366
reference operator*() const
Definition TrackProtoClusterMatchCollection.cc:346
TrackProtoClusterMatchMutableCollectionIterator(const TrackProtoClusterMatchMutableCollectionIterator &)=default
TrackProtoClusterMatchMutableCollectionIterator & operator=(const TrackProtoClusterMatchMutableCollectionIterator &)=default
std::random_access_iterator_tag iterator_concept
Definition TrackProtoClusterMatchCollection.h:94
bool operator==(const TrackProtoClusterMatchMutableCollectionIterator &x) const
Definition TrackProtoClusterMatchCollection.h:109
auto operator<=>(const TrackProtoClusterMatchMutableCollectionIterator &other) const
Definition TrackProtoClusterMatchCollection.h:105
TrackProtoClusterMatchMutableCollectionIterator(TrackProtoClusterMatchMutableCollectionIterator &&)=default
TrackProtoClusterMatchMutableCollectionIterator & operator=(TrackProtoClusterMatchMutableCollectionIterator &&)=default
TrackProtoClusterMatchMutableCollectionIterator & operator-=(difference_type n)
Definition TrackProtoClusterMatchCollection.cc:392
Definition TrackProtoClusterMatchObj.h:22
Definition CalorimeterHit.cc:17
std::deque< TrackProtoClusterMatchObj * > TrackProtoClusterMatchObjPointerContainer
Definition TrackProtoClusterMatchCollectionData.h:24
std::ostream & operator<<(std::ostream &o, const CalorimeterHit &value)
Definition CalorimeterHit.cc:103
Definition CalorimeterHit.h:31