Prevent user code from modifying `Gaudi::Property`
@olupton noticed this anti-pattern in LHCb code:
class PrPixelTracking : public Gaudi::Functional::... {
Gaudi::Property<float> m_maxScatter{this, "MaxScatter", 0.004, "Acceptance criteria for adding new hits"};
StatusCode PrPixelTracking::initialize() {
...
// use the square of the scatter to avoid calls to sqrt()
m_maxScatter.set(m_maxScatter.value()*m_maxScatter.value());
...
}
}
This is a problem for us since we're doing snapshots ("TCKs") of the configuration after initialize
and we rely on it being idempotent (applying the snapshot and running initialize
again should lead to the same state). We know how to properly implement this using Gaudi::Property::declareUpdateHandler
, but is there a way to actively forbid such anti-patterns? Namely, can we make properties read-only from the point of view of the owning component?
Action items:
-
Make declareUpdateHander
calluseUpdateHandler
by default. Behaviour should be modifiable with atagged_bool
argument (see for example PromptDecision)
Edited by Rosen Matev