Modernize HltDAQ
- prefer Gaudi::Property and direct member initialization
- prefer delegating to base class constructor
Merge request reports
Activity
@rmatev FYI
- Resolved by Gerhard Raven
77 77 //============================================================================= 78 78 HltRoutingBitsWriter::HltRoutingBitsWriter( const std::string& name, 79 79 ISvcLocator* pSvcLocator) 80 : HltEvaluator( name , pSvcLocator ) 80 : HltEvaluator( name , pSvcLocator ) 81 81 { 82 declareProperty("RoutingBits", m_bits) ->declareUpdateHandler( &HltRoutingBitsWriter::updateBits, this ); 83 declareProperty("UpdateExistingRawBank",m_updateBank = false); 84 declareProperty("RawEventLocation", m_raw_location = LHCb::RawEventLocation::Default); 82 m_bits.declareUpdateHandler( &HltRoutingBitsWriter::updateBits, this ); yes, and I've suggested it to @clemenci already -- but in quite a few cases where we now have update handlers, it is actually even better to define a dedicated type, and then add
toStream
andparse
functions to deal with them, and do the work of theupdateHandler
inparse
instead. I've done exactly that in one of the merge requests I submitted yesterday or monday, but I cannot find back which one...Ah, found it: !457 (diffs). I introduced a
Gaudi::Property<TCK>
andGaudi::Property<std::map<TCK,std::string>>
whereTCK
is defined in TCK.hAside: it would have perhaps been better if
TCK
had been defined in a namespace, and if instead of needingtoStream
inGaudi::Utils
andparse
inGaudi::Parsers
it would be found by ADL, i.e.toStream
andparse
would live in the same namespace as the class they work on....Edited by Gerhard RavenI think we can allow ADL trivially, just by replacing
--- a/GaudiKernel/GaudiKernel/Property.h +++ b/GaudiKernel/GaudiKernel/Property.h @@ -156,7 +156,8 @@ namespace Gaudi inline TYPE fromString( const std::string& s ) { TYPE tmp; - if ( !Gaudi::Parsers::parse( tmp, s ).isSuccess() ) { + using Gaudi::Parsers::parse; + if ( !parse( tmp, s ).isSuccess() ) { throw std::invalid_argument( "cannot parse '" + s + "' to " + System::typeinfoName( typeid( TYPE ) ) ); } return tmp; @@ -615,7 +616,8 @@ namespace Gaudi void toStream( std::ostream& out ) const override { m_handlers.useReadHandler( *this ); - Utils::toStream( m_value, out ); + using Utils::toStream; + toStream( m_value, out ); } };
@clemenci: what do you think? Should be fully backwards compatible...
Done, see gaudi/Gaudi!242 (merged).
I've checked explicitly that if I add a namespace around
TCK
(and put ausing LHCb::Hlt::TCK
at the end ofTCK.h
for backwards compatibility) , and putparse
andtoStream
in that namespace, that gaudi/Gaudi!242 (merged) indeed allows ADL and that this is sufficient to then defineGaudi::Property<TCK>
in any bit of code with only a plain includeTCK.h
-- i.e. things indeed work as expected.Edited by Gerhard RavenEven better, you do not need an explicit name space, you can just define
toStream
andparse
as friend functions in the class which you want to make into a property!Edited by Gerhard Raven
Mentioned in merge request !463 (merged)
- Resolved by Gerhard Raven
Mentioned in commit 125b0e81
Mentioned in commit 34d46b8b
Mentioned in commit 05d0260b