3#ifndef EDM4EIC_ProtoClusterCollection_H
4#define EDM4EIC_ProtoClusterCollection_H
13#include "podio/ICollectionProvider.h"
14#include "podio/CollectionBase.h"
15#include "podio/detail/Pythonizations.h"
16#include "podio/utilities/TypeHelpers.h"
18#if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
19#include "nlohmann/json_fwd.hpp"
59 return m_index <=> other.m_index;
63 return m_index == x.m_index;
82 ProtoCluster m_object { podio::utils::MaybeSharedPtr<ProtoClusterObj>{
nullptr} };
108 return m_index <=> other.m_index;
112 return m_index == x.m_index;
131 MutableProtoCluster m_object { podio::utils::MaybeSharedPtr<ProtoClusterObj>{
nullptr} };
159#if defined(__cpp_lib_containers_ranges)
160 template<podio::detail::RangeConvertibleTo<value_type> R>
166 template<podio::detail::RangeConvertibleTo<value_type> R>
169 constexpr static std::string_view
typeName =
"edm4eic::ProtoClusterCollection";
171 constexpr static std::string_view
dataTypeName =
"edm4eic::ProtoClusterData";
177 podio::detail::pythonizations::pythonize_subscript(klass, name);
181 void print(std::ostream& os=std::cout,
bool flush=
true) const final;
188 template<typename... Args>
192 std::
size_t size() const final;
198 bool empty() const final;
210 return m_isSubsetColl;
239 if (!m_isSubsetColl) {
240 std::for_each(m_storage.entries.begin(), m_storage.entries.end(),
241 [ID] (
ProtoClusterObj* obj) { obj->id = {obj->id.index, static_cast<uint32_t>(ID)}; }
247 return m_collectionID;
252 return getID() !=
static_cast<uint32_t
>(podio::ObjectID::untracked) &&
253 getID() !=
static_cast<uint32_t
>(podio::ObjectID::invalid);
256 [[deprecated(
"isValid will be removed, use hasID() if you want to check if it has an ID, otherwise assume the "
257 "collection is valid")]]
262 size_t getDatamodelRegistryIndex() const final;
266 return iterator(0, &m_storage.entries);
275 return iterator(m_storage.entries.size(), &m_storage.entries);
278 return const_iterator(m_storage.entries.size(), &m_storage.entries);
311 mutable bool m_isPrepared{
false};
312 bool m_isSubsetColl{
false};
313 uint32_t m_collectionID{
static_cast<uint32_t
>(podio::ObjectID::untracked)};
314 mutable std::unique_ptr<std::mutex> m_storageMtx{std::make_unique<std::mutex>()};
318std::ostream&
operator<<(std::ostream& o,
const ProtoClusterCollection& v);
320template<
typename... Args>
322 if (m_isSubsetColl) {
323 throw std::logic_error(
"Cannot create new elements on a subset collection");
325 auto obj =
new ProtoClusterObj({
static_cast<int>(m_storage.entries.size()), m_collectionID}, {std::forward<Args>(args)...});
326 m_storage.entries.push_back(obj);
329 obj->
m_hits =
new std::vector<edm4eic::CalorimeterHit>();
330 obj->m_weights =
new std::vector<float>();
331 m_storage.createRelations(obj);
336#if defined(__cpp_lib_containers_ranges)
337template<podio::detail::RangeConvertibleTo<ProtoClusterCollection::value_type> R>
342 for (
auto&& elem : range) {
343 push_back(std::forward<
decltype(elem)>(elem));
348template<podio::detail::RangeConvertibleTo<ProtoClusterCollection::value_type> R>
351 if constexpr (podio::detail::RangeOf<R, value_type>) {
355 for (
auto&& elem : range) {
356 coll.
push_back(std::forward<
decltype(elem)>(elem));
363#if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
373#if defined(__clang__)
374 #pragma clang diagnostic push
375 #pragma clang diagnostic ignored "-Wunknown-warning-option"
376 #pragma clang diagnostic ignored "-Wdeprecated-redundant-constexpr-static-def"
377 #pragma clang diagnostic ignored "-Wdeprecated"
381 #pragma clang diagnostic pop
382#elif defined(__GNUC__)
383 #pragma GCC diagnostic push
384 #pragma GCC diagnostic ignored "-Wdeprecated"
388 #pragma GCC diagnostic pop
Definition MutableProtoCluster.h:35
Definition ProtoClusterCollectionData.h:32
Definition ProtoClusterCollection.h:139
const_reverse_iterator crend() const
Definition ProtoClusterCollection.h:299
ProtoClusterCollection(ProtoClusterCollection &&)=default
std::size_t max_size() const final
maximal number of elements in the collection
Definition ProtoClusterCollection.cc:53
ProtoClusterMutableCollectionIterator iterator
Definition ProtoClusterCollection.h:144
std::reverse_iterator< iterator > reverse_iterator
Definition ProtoClusterCollection.h:148
ProtoClusterCollection()=default
bool isValid() const final
Definition ProtoClusterCollection.h:258
void push_back(const MutableProtoCluster &object)
Append object to the collection.
Definition ProtoClusterCollection.cc:123
const_iterator end() const
Definition ProtoClusterCollection.h:277
podio::SchemaVersionT getSchemaVersion() const final
schema version
Definition ProtoClusterCollection.cc:164
bool setReferences(const podio::ICollectionProvider *collectionProvider) final
Definition ProtoClusterCollection.cc:119
uint32_t getID() const final
Definition ProtoClusterCollection.h:246
friend class ProtoClusterCollectionData
Definition ProtoClusterCollection.h:309
reverse_iterator rend()
Definition ProtoClusterCollection.h:293
bool isSubsetCollection() const final
Definition ProtoClusterCollection.h:209
static constexpr std::string_view dataTypeName
Definition ProtoClusterCollection.h:171
void prepareAfterRead() final
Definition ProtoClusterCollection.cc:104
const std::string_view getValueTypeName() const final
fully qualified type name of elements - with namespace
Definition ProtoClusterCollection.h:203
iterator begin()
Definition ProtoClusterCollection.h:265
void prepareForWrite() const final
Definition ProtoClusterCollection.cc:95
const_reverse_iterator crbegin() const
Definition ProtoClusterCollection.h:290
MutableProtoCluster mutable_type
Definition ProtoClusterCollection.h:142
MutableProtoCluster create()
Append a new object to the collection, and return this object.
Definition ProtoClusterCollection.cc:78
const std::string_view getTypeName() const final
fully qualified type name
Definition ProtoClusterCollection.h:201
~ProtoClusterCollection() override
Definition ProtoClusterCollection.cc:28
const_iterator begin() const
Definition ProtoClusterCollection.h:268
const_reverse_iterator rbegin() const
Definition ProtoClusterCollection.h:287
size_t size_type
Definition ProtoClusterCollection.h:146
static void __cppyy_pythonize__(PyObject *klass, const std::string &name)
Cppyy protocol to setup the pythonizations for this class. Not to be called directly.
Definition ProtoClusterCollection.h:176
bool hasID() const final
check if the collection has a valid ID
Definition ProtoClusterCollection.h:251
std::reverse_iterator< const_iterator > const_reverse_iterator
Definition ProtoClusterCollection.h:147
ProtoClusterCollection(const ProtoClusterCollection &)=delete
std::size_t size() const final
number of elements in the collection
Definition ProtoClusterCollection.cc:49
void setID(uint32_t ID) final
Definition ProtoClusterCollection.h:237
void setSubsetCollection(bool setSubset=true) final
Definition ProtoClusterCollection.cc:67
static constexpr std::string_view typeName
Definition ProtoClusterCollection.h:169
reverse_iterator rbegin()
Definition ProtoClusterCollection.h:284
static constexpr std::string_view valueTypeName
Definition ProtoClusterCollection.h:170
ProtoClusterCollection & operator=(const ProtoClusterCollection &)=delete
ProtoCluster at(std::size_t index) const
Returns the const object of given index.
Definition ProtoClusterCollection.cc:37
ProtoCluster value_type
Definition ProtoClusterCollection.h:141
const std::string_view getDataTypeName() const final
fully qualified type name of stored POD elements - with namespace
Definition ProtoClusterCollection.h:205
iterator end()
Definition ProtoClusterCollection.h:274
void print(std::ostream &os=std::cout, bool flush=true) const final
Print this collection to the passed stream.
Definition ProtoClusterCollection.cc:425
static ProtoClusterCollection from(R &&range)
Definition ProtoClusterCollection.h:349
ptrdiff_t difference_type
Definition ProtoClusterCollection.h:145
podio::CollectionWriteBuffers getBuffers() final
Get the collection buffers for this collection.
Definition ProtoClusterCollection.cc:155
ProtoClusterCollectionIterator const_iterator
Definition ProtoClusterCollection.h:143
void clear() final
Definition ProtoClusterCollection.cc:90
const_reverse_iterator rend() const
Definition ProtoClusterCollection.h:296
ProtoClusterCollection & operator=(ProtoClusterCollection &&)=default
const_iterator cend() const
Definition ProtoClusterCollection.h:280
const_iterator cbegin() const
Definition ProtoClusterCollection.h:271
bool empty() const final
Is the collection empty.
Definition ProtoClusterCollection.cc:63
Definition ProtoClusterCollection.h:38
ProtoClusterCollectionIterator(size_t index, const ProtoClusterObjPointerContainer *collection)
Definition ProtoClusterCollection.h:49
pointer operator->()
Definition ProtoClusterCollection.cc:268
constexpr auto operator<=>(const ProtoClusterCollectionIterator &other) const
Definition ProtoClusterCollection.h:58
ProtoClusterCollectionIterator(ProtoClusterCollectionIterator &&)=default
ProtoCluster reference
Definition ProtoClusterCollection.h:42
std::random_access_iterator_tag iterator_concept
Definition ProtoClusterCollection.h:47
ProtoClusterCollectionIterator & operator-=(difference_type n)
Definition ProtoClusterCollection.cc:310
ProtoClusterCollectionIterator()=default
ProtoClusterCollectionIterator & operator++()
Definition ProtoClusterCollection.cc:273
ProtoClusterCollectionIterator & operator=(const ProtoClusterCollectionIterator &)=default
ProtoClusterCollectionIterator & operator=(ProtoClusterCollectionIterator &&)=default
ProtoClusterCollectionIterator & operator--()
Definition ProtoClusterCollection.cc:284
ProtoClusterCollectionIterator operator-(difference_type n) const
Definition ProtoClusterCollection.cc:315
ProtoCluster * pointer
Definition ProtoClusterCollection.h:43
constexpr bool operator==(const ProtoClusterCollectionIterator &x) const
Definition ProtoClusterCollection.h:62
ProtoClusterCollectionIterator & operator+=(difference_type n)
Definition ProtoClusterCollection.cc:295
~ProtoClusterCollectionIterator()=default
ProtoClusterCollectionIterator operator+(difference_type n) const
Definition ProtoClusterCollection.cc:300
reference operator[](difference_type n) const
Definition ProtoClusterCollection.cc:321
ProtoClusterCollectionIterator(const ProtoClusterCollectionIterator &)=default
std::input_iterator_tag iterator_category
Definition ProtoClusterCollection.h:44
reference operator*() const
Definition ProtoClusterCollection.cc:264
ptrdiff_t difference_type
Definition ProtoClusterCollection.h:41
ProtoCluster value_type
Definition ProtoClusterCollection.h:40
Definition ProtoCluster.h:43
Definition ProtoClusterCollection.h:87
MutableProtoCluster * pointer
Definition ProtoClusterCollection.h:92
ProtoClusterMutableCollectionIterator & operator-=(difference_type n)
Definition ProtoClusterCollection.cc:377
MutableProtoCluster reference
Definition ProtoClusterCollection.h:91
ProtoClusterMutableCollectionIterator operator-(difference_type n) const
Definition ProtoClusterCollection.cc:382
ProtoClusterMutableCollectionIterator(const ProtoClusterMutableCollectionIterator &)=default
reference operator*() const
Definition ProtoClusterCollection.cc:331
~ProtoClusterMutableCollectionIterator()=default
std::random_access_iterator_tag iterator_concept
Definition ProtoClusterCollection.h:96
ProtoClusterMutableCollectionIterator operator+(difference_type n) const
Definition ProtoClusterCollection.cc:367
ProtoClusterMutableCollectionIterator & operator=(const ProtoClusterMutableCollectionIterator &)=default
ProtoCluster value_type
Definition ProtoClusterCollection.h:89
reference operator[](difference_type n) const
Definition ProtoClusterCollection.cc:388
ProtoClusterMutableCollectionIterator(size_t index, const ProtoClusterObjPointerContainer *collection)
Definition ProtoClusterCollection.h:98
ProtoClusterMutableCollectionIterator & operator+=(difference_type n)
Definition ProtoClusterCollection.cc:362
std::input_iterator_tag iterator_category
Definition ProtoClusterCollection.h:93
ProtoClusterMutableCollectionIterator()=default
ProtoClusterMutableCollectionIterator & operator++()
Definition ProtoClusterCollection.cc:340
constexpr auto operator<=>(const ProtoClusterMutableCollectionIterator &other) const
Definition ProtoClusterCollection.h:107
ptrdiff_t difference_type
Definition ProtoClusterCollection.h:90
constexpr bool operator==(const ProtoClusterMutableCollectionIterator &x) const
Definition ProtoClusterCollection.h:111
pointer operator->()
Definition ProtoClusterCollection.cc:335
ProtoClusterMutableCollectionIterator & operator=(ProtoClusterMutableCollectionIterator &&)=default
ProtoClusterMutableCollectionIterator & operator--()
Definition ProtoClusterCollection.cc:351
ProtoClusterMutableCollectionIterator(ProtoClusterMutableCollectionIterator &&)=default
Definition ProtoClusterObj.h:20
std::vector< edm4eic::CalorimeterHit > * m_hits
Definition ProtoClusterObj.h:36
Definition ArrowMapper.cc:61
std::ostream & operator<<(std::ostream &o, const CalorimeterHit &value)
Definition CalorimeterHit.cc:99
std::deque< ProtoClusterObj * > ProtoClusterObjPointerContainer
Definition ProtoClusterCollectionData.h:24
Definition CalorimeterHit.h:31