Skip to content

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?

@clemenci @graven

Action items:

  • Make declareUpdateHander call useUpdateHandler by default. Behaviour should be modifiable with a tagged_bool argument (see for example PromptDecision)
Edited by Frank Winklmeier
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information