File LinkNavigator.h

namespace podio

Variables

static detail::links::ReturnFromTag ReturnFrom

Tag variable to select the lookup of From objects have links with a To object in podio::LinkNavigator::getLinked.

static detail::links::ReturnToTag ReturnTo

Tag variable to select the lookup of To objects that have links with a From object in podio::LinkNavigator::getLinked.

template<typename LinkCollT>
class LinkNavigator
#include <podio/LinkNavigator.h>

A helper class to more easily handle one-to-many links.

Internally simply populates two maps in its constructor and then queries them to retrieve objects that are linked with another.

Note

There are no guarantees on the order of the objects in these maps. 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 links collection.

Public Functions

LinkNavigator(const LinkCollT &links)

Construct a navigator from an link collection.

LinkNavigator() = delete

We do only construct from a collection.

LinkNavigator(const LinkNavigator&) = default
LinkNavigator &operator=(const LinkNavigator&) = default
LinkNavigator(LinkNavigator&&) = default
LinkNavigator &operator=(LinkNavigator&&) = default
~LinkNavigator() = default
inline std::vector<WeightedObject<FromT>> getLinked(const ToT &object, podio::detail::links::ReturnFromTag) const

Get all the From objects and weights that have links with the passed object.

You will get this overload if you pass the podio::ReturnFrom tag as second argument

Note

This overload works always, even if the LinkCollection that was used to construct this instance of the LinkNavigator has the same From and To types.

Parameters:
  • object – The object that is labeled To in the link

  • . – tag variable for selecting this overload

Returns:

A vector of all objects and their weights that have links with the passed object

template<typename ToU = ToT>
inline std::enable_if_t<!std::is_same_v<FromT, ToU>, std::vector<WeightedObject<FromT>>> getLinked(const ToT &object) const

Get all the From objects and weights that have links with the passed object.

Note

This overload will automatically do the right thing (TM) in case the LinkCollection that has been passed to construct this LinkNavigator has different From and To types.

Parameters:

object – The object that is labeled To in the link

Returns:

A vector of all objects and their weights that have links with the passed object

inline std::vector<WeightedObject<ToT>> getLinked(const FromT &object, podio::detail::links::ReturnToTag) const

Get all the To objects and weights that have links with the passed object.

You will get this overload if you pass the podio::ReturnTo tag as second argument

Note

This overload works always, even if the LinkCollection that was used to construct this instance of the LinkNavigator has the same From and To types.

Parameters:
  • object – The object that is labeled From in the link

  • . – tag variable for selecting this overload

Returns:

A vector of all objects and their weights that have links with the passed object

template<typename FromU = FromT>
inline std::enable_if_t<!std::is_same_v<FromU, ToT>, std::vector<WeightedObject<ToT>>> getLinked(const FromT &object) const

Get all the To objects and weights that have links with the passed object.

Note

This overload will automatically do the right thing (TM) in case the LinkCollection that has been passed to construct this LinkNavigator has different From and To types.

Parameters:

object – The object that is labeled From in the link

Returns:

A vector of all objects and their weights that have links with the passed object

Private Types

using FromT = typename LinkCollT::from_type
using ToT = typename LinkCollT::to_type
template<typename T>
using WeightedObject = detail::links::WeightedObject<T>

Private Members

std::multimap<FromT, WeightedObject<ToT>> m_from2to = {}

Map the from to the to objects.

std::multimap<ToT, WeightedObject<FromT>> m_to2from = {}

Map the to to the from objects.