Gaudi Interfaces
Gaudi component classes (Algorithms, Services, Tools, etc) are concrete implementations of an abstract Interface class.
What are interface classes?
Interface classes define a set of methods and imply certain behavior that concrete implementations must provide.
How are they beneficial?
Factoring the code this way leads to some practical benefits.
- Reduced compilation dependencies
- User code accesses a component object only through the interface class. This means their code must only "#include" the interface class header file. This header is unlikely to ever change and thus user code need not be recompiled when the concrete implementation code changes.
- Central registration
- interface implementations register themselves so they can be looked up by name by other code. This further reduces coupling between codes and lends support to configuration mechanisms.
- Support scripting
- because interfaces provide well a defined collection of methods their concrete implementations can be easily accessible from Python. One needs only to make the interface accessible and all implementations can then be accessed.
- Faster casting
- A concrete component may implement one or more interfaces. Standard C++ would require a
dynamic_cast
to go from one interface to another. Gaudi interfaces have a faster mechanism (queryInterface
) that can use static casts and which ends up being faster. [In practice this is not a huge benefit, but is one nonetheless].