Skip to content

Commit

Permalink
Default initialize ObjectIDs to untracked
Browse files Browse the repository at this point in the history
  • Loading branch information
tmadlener committed Sep 18, 2023
1 parent 05f6041 commit 294ef3f
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
10 changes: 5 additions & 5 deletions include/podio/ObjectID.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@ namespace podio {
class ObjectID {

public:
/// index of object in collection
int index;
/// ID of the collection
uint32_t collectionID;

/// not part of a collection
static const int untracked = -1;
/// invalid or non-available object
static const int invalid = -2;

/// index of object in collection
int index{untracked};
/// ID of the collection
uint32_t collectionID{static_cast<uint32_t>(untracked)};

/// index and collectionID uniquely defines the object.
/// this operator is necessary for meaningful comparisons in python
bool operator==(const ObjectID& other) const {
Expand Down
4 changes: 2 additions & 2 deletions python/templates/Collection.cc.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@

{% with collection_type = class.bare_type + 'Collection' %}
{{ collection_type }}::{{ collection_type }}() :
m_isValid(false), m_isPrepared(false), m_isSubsetColl(false), m_collectionID(0), m_storageMtx(std::make_unique<std::mutex>()), m_storage() {}
m_isValid(false), m_isPrepared(false), m_isSubsetColl(false), m_collectionID(podio::ObjectID::untracked), m_storageMtx(std::make_unique<std::mutex>()), m_storage() {}

{{ collection_type }}::{{ collection_type }}({{ collection_type }}Data&& data, bool isSubsetColl) :
m_isValid(false), m_isPrepared(false), m_isSubsetColl(isSubsetColl), m_collectionID(0), m_storageMtx(std::make_unique<std::mutex>()), m_storage(std::move(data)) {}
m_isValid(false), m_isPrepared(false), m_isSubsetColl(isSubsetColl), m_collectionID(podio::ObjectID::untracked), m_storageMtx(std::make_unique<std::mutex>()), m_storage(std::move(data)) {}

{{ collection_type }}::~{{ collection_type }}() {
// Need to tell the storage how to clean-up
Expand Down
4 changes: 2 additions & 2 deletions python/templates/Obj.cc.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
{{ utils.namespace_open(class.namespace) }}
{% with obj_type = class.bare_type + 'Obj' %}
{{ obj_type }}::{{ obj_type }}() :
{% raw %} ObjBase{{podio::ObjectID::untracked, 0}, 0}{% endraw %},
{% raw %} ObjBase{{}, 0}{% endraw %},
data(){{ single_relations_initialize(OneToOneRelations) }}
{%- for relation in OneToManyRelations + VectorMembers %},
m_{{ relation.name }}(new std::vector<{{ relation.full_type }}>())
Expand All @@ -29,7 +29,7 @@
{ }

{{ obj_type }}::{{ obj_type }}(const {{ obj_type }}& other) :
{% raw %} ObjBase{{podio::ObjectID::untracked, 0}, 0}{% endraw %},
{% raw %} ObjBase{{}, 0}{% endraw %},
data(other.data){{ single_relations_initialize(OneToOneRelations) }}
{%- for relation in OneToManyRelations + VectorMembers %},
m_{{ relation.name }}(new std::vector<{{ relation.full_type }}>(*(other.m_{{ relation.name }})))
Expand Down
2 changes: 1 addition & 1 deletion python/templates/macros/implementations.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ const podio::ObjectID {{ full_type }}::getObjectID() const {
if (m_obj) {
return m_obj->id;
}
return podio::ObjectID{podio::ObjectID::invalid, 0};
return podio::ObjectID{};
}

{% set inverse_type = class.bare_type if prefix else 'Mutable' + class.bare_type %}
Expand Down

0 comments on commit 294ef3f

Please sign in to comment.