diff --git a/include/podio/detail/Link.h b/include/podio/detail/Link.h index 7317c4400..b2730769e 100644 --- a/include/podio/detail/Link.h +++ b/include/podio/detail/Link.h @@ -61,7 +61,7 @@ class LinkT { /// Constructor with weight LinkT(float weight) : m_obj(new LinkObjT{}, podio::utils::MarkOwned) { - m_obj->weight = weight; + m_obj->data.weight = weight; } /// Copy constructor @@ -89,7 +89,7 @@ class LinkT { /// original one template >> MutableLink clone(bool cloneRelations = true) const { - auto tmp = new LinkObjT(podio::ObjectID{}, m_obj->weight); + auto tmp = new LinkObjT(podio::ObjectID{}, m_obj->data); if (cloneRelations) { if (m_obj->m_from) { tmp->m_from = new FromT(*m_obj->m_from); @@ -112,13 +112,13 @@ class LinkT { /// Get the weight of the link float getWeight() const { - return m_obj->weight; + return m_obj->data.weight; } /// Set the weight of the link template > void setWeight(float value) { - m_obj->weight = value; + m_obj->data.weight = value; } /// Access the related-from object diff --git a/include/podio/detail/LinkCollectionData.h b/include/podio/detail/LinkCollectionData.h index b73e285e3..948d7247d 100644 --- a/include/podio/detail/LinkCollectionData.h +++ b/include/podio/detail/LinkCollectionData.h @@ -32,7 +32,7 @@ class LinkCollectionData { m_rel_to(new std::vector()), m_refCollections(std::move(*buffers.references)) { if (!isSubsetColl) { - m_data.reset(buffers.dataAsVector()); + m_data.reset(buffers.dataAsVector()); } } @@ -100,7 +100,7 @@ class LinkCollectionData { m_data->reserve(entries.size()); for (const auto obj : entries) { - m_data->push_back(obj->weight); + m_data->push_back(obj->data); if (obj->m_from) { m_refCollections[0]->emplace_back(obj->m_from->getObjectID()); diff --git a/include/podio/detail/LinkFwd.h b/include/podio/detail/LinkFwd.h index 492347230..3ef706251 100644 --- a/include/podio/detail/LinkFwd.h +++ b/include/podio/detail/LinkFwd.h @@ -59,7 +59,13 @@ class LinkObj; template using LinkObjPointerContainer = std::deque*>; -using LinkDataContainer = std::vector; +/// Simple struct to keep implementation more in line with generated links and +/// to ease evolution of generated links into templated ones +struct LinkData { + float weight{}; +}; + +using LinkDataContainer = std::vector; template class LinkT; diff --git a/include/podio/detail/LinkObj.h b/include/podio/detail/LinkObj.h index 3396840eb..69297e921 100644 --- a/include/podio/detail/LinkObj.h +++ b/include/podio/detail/LinkObj.h @@ -15,15 +15,15 @@ class LinkObj { public: /// Constructor - LinkObj() : id(), weight(0.0f), m_from(nullptr), m_to(nullptr) { + LinkObj() : id(), data(0.0f), m_from(nullptr), m_to(nullptr) { } - /// Constructor from ObjectID and weight (does not initialize relations yet!) - LinkObj(const podio::ObjectID id_, float weight_) : id(id_), weight(weight_) { + /// Constructor from ObjectID and data (does not initialize relations yet!) + LinkObj(const podio::ObjectID id_, LinkData data_) : id(id_), data(data_) { } /// Copy constructor (deep-copy of relations) - LinkObj(const LinkObj& other) : id(), weight(other.weight), m_from(nullptr), m_to(nullptr) { + LinkObj(const LinkObj& other) : id(), data(other.data), m_from(nullptr), m_to(nullptr) { if (other.m_from) { m_from = new FromT(*other.m_from); } @@ -43,7 +43,7 @@ class LinkObj { public: podio::ObjectID id{}; - float weight{1.0f}; + LinkData data{1.0f}; FromT* m_from{nullptr}; ToT* m_to{nullptr}; };