Class podio::LinkNavigator

template<typename LinkCollT>
class LinkNavigator

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