Skip to content
Snippets Groups Projects

Add support to ToolHandle for const tool interfaces

Merged Christopher Rob Jones requested to merge jonrob/Gaudi:ConstToolInterfacesMaster into master

Based on lhcb/Gaudi!65 (merged) from the LHCb future branch.

The current model for using ToolHandles has something like

ToolHandle<ITrackExtrapolator> m_trExt{ "TrackRungeKuttaExtrapolator", this };

as an algorithm data member. This works fine, but I just noticed that this model allows access to non-const methods of the tool, even in const methods of the parent algorithm. This is a problem if we want to enforce usage of only const interface methods in functional algorithms.

With raw pointers I explicitly declare them const

const ITrackExtrapolator m_trExt{nullptr};

But the equivalent does not work with ToolHandle, as some methods require non-const access (for instance to release the tool).

This update uses a little bit of type traits and const_casting to allow the user to declare they only want const access to the tool

ToolHandle<const ITrackExtrapolator> m_trExt{ "TrackRungeKuttaExtrapolator", this };

but internally allows the handle to discard the const qualifier only where needed.

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
Please register or sign in to reply
Loading