More efficient Toolhandle<T>::get() method
I would like to use ToolHandle more, but I also want to use it optimally efficiently, by which I mean I want inline access to the underlying tool pointer, with no validity checks (I always retrieve()
my tools up front in initialize()) and true const behaviour (for thread safety). Essentially what I want is GaudiHandle<T>::get()
, but unfortunately in the current implementation this method is hidden behind the virtual ToolHandle<T>::get()
method, that also down casts the tool to IAlgTool*
(so no use for direct usage).
This MR fixes both these issues. get() is now fully optimal in ToolHandle<T>
as it simply refers back to GaudiHandle in an inline method.
The BaseToolHandle<T>::get()
method is just a wrapper that calls a hidden (protected) virtual function (getAsIAlgTool()
) that returns what get() previously did.
I also tightened up the const'ness, providing both const and non-const methods that return const and non-const tool pointers respectively.
I also updated a few methods to remove multiple return statements (which normally cause compilers to abort inlining) and adding some noexcept
here and there..
The only API change is that ToolHandle<T>::get()
now returns T*
instead of IAlgTool*
, but this is not a problem as the user can still choose to use it as a IAlgTool*
if they want..
Gaudi master builds fine with this, not tested any other projects yet.
cheers Chris