Skip to content

Commit

Permalink
Switch to more canonical member type names
Browse files Browse the repository at this point in the history
  • Loading branch information
tmadlener committed Jul 17, 2024
1 parent 3284135 commit 7ec3fe5
Showing 1 changed file with 15 additions and 17 deletions.
32 changes: 15 additions & 17 deletions include/podio/detail/AssociationCollectionImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,11 @@ class AssociationCollection : public podio::CollectionBase {
"Associations need to be instantiated with the default types!");

// convenience typedefs
using AssocT = Association<FromT, ToT>;
using MutableAssocT = MutableAssociation<FromT, ToT>;

using CollectionT = podio::AssociationCollection<FromT, ToT>;
using CollectionDataT = podio::AssociationCollectionData<FromT, ToT>;

public:
using value_type = Association<FromT, ToT>;
using mutable_type = MutableAssociation<FromT, ToT>;
using const_iterator = AssociationCollectionIterator<FromT, ToT>;
using iterator = AssociationMutableCollectionIterator<FromT, ToT>;
using difference_type = ptrdiff_t;
Expand All @@ -66,34 +64,34 @@ class AssociationCollection : public podio::CollectionBase {
}

/// Append a new association to the collection and return this object
MutableAssocT create() {
mutable_type create() {
if (m_isSubsetColl) {
throw std::logic_error("Cannot create new elements on a subset collection");
}

auto obj = m_storage.entries.emplace_back(new AssociationObj<FromT, ToT>());
obj->id = {int(m_storage.entries.size() - 1), m_collectionID};
return MutableAssocT(obj);
return mutable_type(obj);
}

/// Returns the immutable object of given index
AssocT operator[](unsigned int index) const {
return AssocT(m_storage.entries[index]);
value_type operator[](unsigned int index) const {
return value_type(m_storage.entries[index]);
}
/// Returns the mutable object of given index
MutableAssocT operator[](unsigned int index) {
return MutableAssocT(m_storage.entries[index]);
mutable_type operator[](unsigned int index) {
return mutable_type(m_storage.entries[index]);
}
/// Returns the immutable object of given index
AssocT at(unsigned int index) const {
return AssocT(m_storage.entries.at(index));
value_type at(unsigned int index) const {
return value_type(m_storage.entries.at(index));
}
/// Returns the mutable object of given index
MutableAssocT at(unsigned int index) {
return MutableAssocT(m_storage.entries.at(index));
mutable_type at(unsigned int index) {
return mutable_type(m_storage.entries.at(index));
}

void push_back(MutableAssocT object) {
void push_back(mutable_type object) {
// We have to do different things here depending on whether this is a
// subset collection or not. A normal collection cannot collect objects
// that are already part of another collection, while a subset collection
Expand All @@ -109,11 +107,11 @@ class AssociationCollection : public podio::CollectionBase {
}

} else {
push_back(AssocT(object));
push_back(value_type(object));
}
}

void push_back(AssocT object) {
void push_back(value_type object) {
if (!m_isSubsetColl) {
throw std::invalid_argument("Can only add immutable objects to subset collections");
}
Expand Down

0 comments on commit 7ec3fe5

Please sign in to comment.