Skip to content

change return type of Property::declare{Read,Update}Handler from void to Property&,

Gerhard Raven requested to merge graven/Gaudi:declare-returns-this into master

i.e. return *this.

The reason is that this way one can write code like this:

  declareProperty("trackMaxChi2", m_trackMaxChi2 = 25.)
    ->declareUpdateHandler( [this](Property&){ this->m_trackChi = std::sqrt(this->m_trackMaxChi2); } )
    .useUpdateHandler();

this keeps m_trackChi in sync with m_trackMaxChi2. Without the call to useUpdateHandler, if there is no entry in the JobOptionsSvc, m_trackChi would not be set, and one would have to duplicate the code to 'derive' m_trackChi from m_trackMaxChi2 just to initialize it to the proper default.

(note: it is a pity that declareProperty returns 'this' instead of '*this' -- typically setters should return *this, as a nullptr is impossible anyway!)

Merge request reports

Loading