Skip to content

Commit

Permalink
Rename Association to Link
Browse files Browse the repository at this point in the history
  • Loading branch information
tmadlener committed Oct 15, 2024
1 parent 198100a commit 0bf4f1d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 22 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef PODIO_ASSOCIATIONNAVIGATOR_H
#define PODIO_ASSOCIATIONNAVIGATOR_H
#ifndef PODIO_LINKNAVIGATOR_H
#define PODIO_LINKNAVIGATOR_H

#include "podio/detail/AssociationFwd.h"
#include "podio/detail/LinkFwd.h"

#include <map>
#include <tuple>
Expand All @@ -12,7 +12,7 @@ namespace podio {

namespace detail::associations {
/// A small struct that simply bundles an object and its weight for a more
/// convenient return value for the AssociationNavigator
/// convenient return value for the LinkNavigator
///
/// @note In most uses the names of the members should not really matter as it
/// is possible to us this via structured bindings
Expand All @@ -34,25 +34,25 @@ namespace detail::associations {
/// Hence, there are also no guarantees on the order of the returned objects,
/// even if there inherintly is an order to them in the underlying associations
/// collection.
template <typename AssociationCollT>
class AssociationNavigator {
using FromT = AssociationCollT::from_type;
using ToT = AssociationCollT::to_type;
template <typename LinkCollT>
class LinkNavigator {
using FromT = LinkCollT::from_type;
using ToT = LinkCollT::to_type;

template <typename T>
using WeightedObject = detail::associations::WeightedObject<T>;

public:
/// Construct a navigator from an association collection
AssociationNavigator(const AssociationCollT& associations);
LinkNavigator(const LinkCollT& associations);

/// We do only construct from a collection
AssociationNavigator() = delete;
AssociationNavigator(const AssociationNavigator&) = default;
AssociationNavigator& operator=(const AssociationNavigator&) = default;
AssociationNavigator(AssociationNavigator&&) = default;
AssociationNavigator& operator=(AssociationNavigator&&) = default;
~AssociationNavigator() = default;
LinkNavigator() = delete;
LinkNavigator(const LinkNavigator&) = default;
LinkNavigator& operator=(const LinkNavigator&) = default;
LinkNavigator(LinkNavigator&&) = default;
LinkNavigator& operator=(LinkNavigator&&) = default;
~LinkNavigator() = default;

/// Get all the objects and weights that are associated to the passed object
///
Expand Down Expand Up @@ -93,8 +93,8 @@ class AssociationNavigator {
std::multimap<ToT, WeightedObject<FromT>> m_to2from; ///< Map the to to the from objects
};

template <typename AssociationCollT>
AssociationNavigator<AssociationCollT>::AssociationNavigator(const AssociationCollT& associations) {
template <typename LinkCollT>
LinkNavigator<LinkCollT>::LinkNavigator(const LinkCollT& associations) {
for (const auto& [from, to, weight] : associations) {
m_from2to.emplace(std::piecewise_construct, std::forward_as_tuple(from), std::forward_as_tuple(to, weight));
m_to2from.emplace(std::piecewise_construct, std::forward_as_tuple(to), std::forward_as_tuple(from, weight));
Expand All @@ -103,4 +103,4 @@ AssociationNavigator<AssociationCollT>::AssociationNavigator(const AssociationCo

} // namespace podio

#endif // PODIO_ASSOCIATIONNAVIGATOR_H
#endif // PODIO_LINKNAVIGATOR_H
8 changes: 4 additions & 4 deletions tests/unittests/links.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "catch2/catch_test_macros.hpp"

#include "podio/AssociationNavigator.h"
#include "podio/LinkCollection.h"
#include "podio/LinkNavigator.h"

#include "datamodel/ExampleClusterCollection.h"
#include "datamodel/ExampleHitCollection.h"
Expand Down Expand Up @@ -475,8 +475,8 @@ TEST_CASE("Link JSON conversion", "[links][json]") {

#endif

TEST_CASE("AssociationNavigator basics", "[asssociations]") {
TestAColl coll{};
TEST_CASE("LinkNavigator basics", "[links]") {
TestLColl coll{};
std::vector<ExampleHit> hits(11);
std::vector<ExampleCluster> clusters(3);

Expand All @@ -490,7 +490,7 @@ TEST_CASE("AssociationNavigator basics", "[asssociations]") {
auto a = coll.create();
a.set(hits[10]);

podio::AssociationNavigator nav{coll};
podio::LinkNavigator nav{coll};

for (size_t i = 0; i < 10; ++i) {
const auto& hit = hits[i];
Expand Down

0 comments on commit 0bf4f1d

Please sign in to comment.