Project

General

Profile

Feature #3349

Updated by Christopher Green over 7 years ago

My standard mantra for getting a data product is:<pre> is:

string moduleLable(pset.get<string>("moduleLabel");

art::Handle<StatusG4> g4StatusHandle;
event.getByLabel( moduleLabel, g4StatusHandle);
StatusG4 const& g4Status = *g4StatusHandle;</pre>

*g4StatusHandle;

It occurred to Adam and I that maybe the following might work:<pre>auto work:

auto
const& g4Status = event.getByLabel<StatusG4>(moduleLabel);</pre> event.getByLabel<StatusG4>(moduleLabel);

Even better would be if we can get rid of the const & and still have the variable g4Status be const&.<pre>auto const&.

auto
g4Status = event.getByLabel<StatusG4>(_g4ModulleLabel);</pre> event.getByLabel<StatusG4>(_g4ModulleLabel);

We propose to extend the API to include this new method. We recognize that this method has no way to indicate failure except to throw and exception - that is the behaviour we want. People who need to deal with the possibility of a product being absent or with multiple valid answers to the get can still use the old version. We believe that the new version can be implemented by calling through to the old version.

If it is necessary to change the function name that's fine too.

Rob

Back