3#ifndef EDM4EIC_ProtoClusterCollection_H
4#define EDM4EIC_ProtoClusterCollection_H
13#include "podio/ICollectionProvider.h"
14#include "podio/CollectionBase.h"
16#if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
17#include "nlohmann/json_fwd.hpp"
57 return m_index <=> other.m_index;
61 return m_index == x.m_index;
80 ProtoCluster m_object { podio::utils::MaybeSharedPtr<ProtoClusterObj>{
nullptr} };
106 return m_index <=> other.m_index;
110 return m_index == x.m_index;
129 MutableProtoCluster m_object { podio::utils::MaybeSharedPtr<ProtoClusterObj>{
nullptr} };
159 constexpr static std::string_view
typeName =
"edm4eic::ProtoClusterCollection";
161 constexpr static std::string_view
dataTypeName =
"edm4eic::ProtoClusterData";
166 void print(std::ostream& os=std::cout,
bool flush=true) const final;
176 template<
typename... Args>
180 std::size_t
size() const final;
186 bool empty() const final;
198 return m_isSubsetColl;
227 if (!m_isSubsetColl) {
228 std::for_each(m_storage.entries.begin(), m_storage.entries.end(),
229 [ID] (
ProtoClusterObj* obj) { obj->id = {obj->id.index, static_cast<uint32_t>(ID)}; }
236 return m_collectionID;
243 size_t getDatamodelRegistryIndex() const final;
247 return iterator(0, &m_storage.entries);
256 return iterator(m_storage.entries.size(), &m_storage.entries);
259 return const_iterator(m_storage.entries.size(), &m_storage.entries);
292 bool m_isValid{
false};
293 mutable bool m_isPrepared{
false};
294 bool m_isSubsetColl{
false};
295 uint32_t m_collectionID{0};
296 mutable std::unique_ptr<std::mutex> m_storageMtx{
nullptr};
300std::ostream&
operator<<(std::ostream& o,
const ProtoClusterCollection& v);
302template<
typename... Args>
304 if (m_isSubsetColl) {
305 throw std::logic_error(
"Cannot create new elements on a subset collection");
307 const int size = m_storage.entries.size();
309 m_storage.entries.push_back(obj);
312 obj->
m_hits =
new std::vector<edm4eic::CalorimeterHit>();
313 obj->m_weights =
new std::vector<float>();
314 m_storage.createRelations(obj);
318#if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
Definition MutableProtoCluster.h:35
Definition ProtoClusterCollectionData.h:31
Definition ProtoClusterCollection.h:137
const_reverse_iterator crend() const
Definition ProtoClusterCollection.h:280
ProtoClusterCollection(ProtoClusterCollection &&)=default
std::size_t max_size() const final
maximal number of elements in the collection
Definition ProtoClusterCollection.cc:56
ProtoClusterMutableCollectionIterator iterator
Definition ProtoClusterCollection.h:142
std::reverse_iterator< iterator > reverse_iterator
Definition ProtoClusterCollection.h:146
bool isValid() const final
Definition ProtoClusterCollection.h:239
void push_back(const MutableProtoCluster &object)
Append object to the collection.
Definition ProtoClusterCollection.cc:126
const_iterator end() const
Definition ProtoClusterCollection.h:258
podio::SchemaVersionT getSchemaVersion() const final
schema version
Definition ProtoClusterCollection.cc:168
bool setReferences(const podio::ICollectionProvider *collectionProvider) final
Definition ProtoClusterCollection.cc:122
uint32_t getID() const final
Definition ProtoClusterCollection.h:235
friend class ProtoClusterCollectionData
Definition ProtoClusterCollection.h:290
reverse_iterator rend()
Definition ProtoClusterCollection.h:274
bool isSubsetCollection() const final
Definition ProtoClusterCollection.h:197
ProtoClusterCollection()
Definition ProtoClusterCollection.cc:25
static constexpr std::string_view dataTypeName
Definition ProtoClusterCollection.h:161
void prepareAfterRead() final
Definition ProtoClusterCollection.cc:107
const std::string_view getValueTypeName() const final
fully qualified type name of elements - with namespace
Definition ProtoClusterCollection.h:191
iterator begin()
Definition ProtoClusterCollection.h:246
void prepareForWrite() const final
Definition ProtoClusterCollection.cc:98
const_reverse_iterator crbegin() const
Definition ProtoClusterCollection.h:271
MutableProtoCluster mutable_type
Definition ProtoClusterCollection.h:140
MutableProtoCluster create()
Append a new object to the collection, and return this object.
Definition ProtoClusterCollection.cc:81
const std::string_view getTypeName() const final
fully qualified type name
Definition ProtoClusterCollection.h:189
~ProtoClusterCollection() override
Definition ProtoClusterCollection.cc:31
const_iterator begin() const
Definition ProtoClusterCollection.h:249
const_reverse_iterator rbegin() const
Definition ProtoClusterCollection.h:268
size_t size_type
Definition ProtoClusterCollection.h:144
std::reverse_iterator< const_iterator > const_reverse_iterator
Definition ProtoClusterCollection.h:145
ProtoClusterCollection(const ProtoClusterCollection &)=delete
std::size_t size() const final
number of elements in the collection
Definition ProtoClusterCollection.cc:52
void setID(uint32_t ID) final
Definition ProtoClusterCollection.h:225
void setSubsetCollection(bool setSubset=true) final
Definition ProtoClusterCollection.cc:70
static constexpr std::string_view typeName
Definition ProtoClusterCollection.h:159
reverse_iterator rbegin()
Definition ProtoClusterCollection.h:265
static constexpr std::string_view valueTypeName
Definition ProtoClusterCollection.h:160
ProtoClusterCollection & operator=(const ProtoClusterCollection &)=delete
ProtoCluster at(std::size_t index) const
Returns the const object of given index.
Definition ProtoClusterCollection.cc:40
ProtoCluster value_type
Definition ProtoClusterCollection.h:139
const std::string_view getDataTypeName() const final
fully qualified type name of stored POD elements - with namespace
Definition ProtoClusterCollection.h:193
iterator end()
Definition ProtoClusterCollection.h:255
void print(std::ostream &os=std::cout, bool flush=true) const final
Print this collection to the passed stream.
Definition ProtoClusterCollection.cc:435
ptrdiff_t difference_type
Definition ProtoClusterCollection.h:143
podio::CollectionWriteBuffers getBuffers() final
Get the collection buffers for this collection.
Definition ProtoClusterCollection.cc:159
ProtoClusterCollectionIterator const_iterator
Definition ProtoClusterCollection.h:141
void clear() final
Definition ProtoClusterCollection.cc:93
const_reverse_iterator rend() const
Definition ProtoClusterCollection.h:277
ProtoClusterCollection & operator=(ProtoClusterCollection &&)=default
const_iterator cend() const
Definition ProtoClusterCollection.h:261
const_iterator cbegin() const
Definition ProtoClusterCollection.h:252
bool empty() const final
Is the collection empty.
Definition ProtoClusterCollection.cc:66
Definition ProtoClusterCollection.h:36
auto operator<=>(const ProtoClusterCollectionIterator &other) const
Definition ProtoClusterCollection.h:56
ProtoClusterCollectionIterator(size_t index, const ProtoClusterObjPointerContainer *collection)
Definition ProtoClusterCollection.h:47
pointer operator->()
Definition ProtoClusterCollection.cc:278
ProtoClusterCollectionIterator(ProtoClusterCollectionIterator &&)=default
ProtoCluster reference
Definition ProtoClusterCollection.h:40
std::random_access_iterator_tag iterator_concept
Definition ProtoClusterCollection.h:45
ProtoClusterCollectionIterator & operator-=(difference_type n)
Definition ProtoClusterCollection.cc:320
ProtoClusterCollectionIterator()=default
ProtoClusterCollectionIterator & operator++()
Definition ProtoClusterCollection.cc:283
ProtoClusterCollectionIterator & operator=(const ProtoClusterCollectionIterator &)=default
ProtoClusterCollectionIterator & operator=(ProtoClusterCollectionIterator &&)=default
ProtoClusterCollectionIterator & operator--()
Definition ProtoClusterCollection.cc:294
ProtoClusterCollectionIterator operator-(difference_type n) const
Definition ProtoClusterCollection.cc:325
bool operator==(const ProtoClusterCollectionIterator &x) const
Definition ProtoClusterCollection.h:60
ProtoCluster * pointer
Definition ProtoClusterCollection.h:41
ProtoClusterCollectionIterator & operator+=(difference_type n)
Definition ProtoClusterCollection.cc:305
~ProtoClusterCollectionIterator()=default
ProtoClusterCollectionIterator operator+(difference_type n) const
Definition ProtoClusterCollection.cc:310
reference operator[](difference_type n) const
Definition ProtoClusterCollection.cc:331
ProtoClusterCollectionIterator(const ProtoClusterCollectionIterator &)=default
std::input_iterator_tag iterator_category
Definition ProtoClusterCollection.h:42
reference operator*() const
Definition ProtoClusterCollection.cc:274
ptrdiff_t difference_type
Definition ProtoClusterCollection.h:39
ProtoCluster value_type
Definition ProtoClusterCollection.h:38
Definition ProtoCluster.h:43
Definition ProtoClusterCollection.h:85
bool operator==(const ProtoClusterMutableCollectionIterator &x) const
Definition ProtoClusterCollection.h:109
MutableProtoCluster * pointer
Definition ProtoClusterCollection.h:90
ProtoClusterMutableCollectionIterator & operator-=(difference_type n)
Definition ProtoClusterCollection.cc:387
MutableProtoCluster reference
Definition ProtoClusterCollection.h:89
ProtoClusterMutableCollectionIterator operator-(difference_type n) const
Definition ProtoClusterCollection.cc:392
ProtoClusterMutableCollectionIterator(const ProtoClusterMutableCollectionIterator &)=default
reference operator*() const
Definition ProtoClusterCollection.cc:341
~ProtoClusterMutableCollectionIterator()=default
std::random_access_iterator_tag iterator_concept
Definition ProtoClusterCollection.h:94
ProtoClusterMutableCollectionIterator operator+(difference_type n) const
Definition ProtoClusterCollection.cc:377
ProtoClusterMutableCollectionIterator & operator=(const ProtoClusterMutableCollectionIterator &)=default
ProtoCluster value_type
Definition ProtoClusterCollection.h:87
reference operator[](difference_type n) const
Definition ProtoClusterCollection.cc:398
ProtoClusterMutableCollectionIterator(size_t index, const ProtoClusterObjPointerContainer *collection)
Definition ProtoClusterCollection.h:96
auto operator<=>(const ProtoClusterMutableCollectionIterator &other) const
Definition ProtoClusterCollection.h:105
ProtoClusterMutableCollectionIterator & operator+=(difference_type n)
Definition ProtoClusterCollection.cc:372
std::input_iterator_tag iterator_category
Definition ProtoClusterCollection.h:91
ProtoClusterMutableCollectionIterator()=default
ProtoClusterMutableCollectionIterator & operator++()
Definition ProtoClusterCollection.cc:350
ptrdiff_t difference_type
Definition ProtoClusterCollection.h:88
pointer operator->()
Definition ProtoClusterCollection.cc:345
ProtoClusterMutableCollectionIterator & operator=(ProtoClusterMutableCollectionIterator &&)=default
ProtoClusterMutableCollectionIterator & operator--()
Definition ProtoClusterCollection.cc:361
ProtoClusterMutableCollectionIterator(ProtoClusterMutableCollectionIterator &&)=default
Definition ProtoClusterObj.h:20
std::vector< edm4eic::CalorimeterHit > * m_hits
Definition ProtoClusterObj.h:36
Definition CalorimeterHit.cc:17
std::ostream & operator<<(std::ostream &o, const CalorimeterHit &value)
Definition CalorimeterHit.cc:103
std::deque< ProtoClusterObj * > ProtoClusterObjPointerContainer
Definition ProtoClusterCollectionData.h:23
Definition CalorimeterHit.h:31