File indexing completed on 2025-01-18 09:57:33
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef GAUDIALG_FIXTESPATH_H
0012 #define GAUDIALG_FIXTESPATH_H
0013 #include <memory>
0014 #include <string>
0015 #include <string_view>
0016 #include <type_traits>
0017
0018 #include "GaudiKernel/AlgTool.h"
0019 #include "GaudiKernel/Algorithm.h"
0020 #include "GaudiKernel/IDataManagerSvc.h"
0021 #include "GaudiKernel/MsgStream.h"
0022 #include <Gaudi/Property.h>
0023
0024 namespace FixTESPathDetails {
0025 std::unique_ptr<IDataHandleVisitor> fixDataHandlePath( std::string_view rit, std::string rootName, MsgStream* dbg );
0026 std::string fullTESLocation( std::string_view location, std::string_view rit );
0027 }
0028
0029 template <class BASE>
0030 class FixTESPath : public BASE {
0031 public:
0032
0033
0034 template <typename U = BASE, typename = std::enable_if_t<std::is_base_of_v<Gaudi::Algorithm, BASE>, U>>
0035 FixTESPath( std::string name, ISvcLocator* pSvcLocator ) : BASE( std::move( name ), pSvcLocator ) {}
0036
0037
0038
0039 template <typename U = BASE, typename = std::enable_if_t<std::is_base_of_v<AlgTool, BASE>, U>>
0040 FixTESPath( std::string type, std::string name, const IInterface* ancestor )
0041 : BASE( std::move( type ), std::move( name ), ancestor ) {
0042
0043 if ( const IProperty* ancestorProp = dynamic_cast<const IProperty*>( ancestor );
0044 ancestorProp && ancestorProp->hasProperty( "RootInTES" ) ) {
0045 this->setProperty( ancestorProp->getProperty( "RootInTES" ) ).ignore();
0046 }
0047 }
0048
0049 StatusCode initialize() override {
0050 return BASE::initialize().andThen( [&] {
0051
0052 SmartIF<IDataManagerSvc> dataMgrSvc{ BASE::evtSvc() };
0053 this->m_updateDataHandles = FixTESPathDetails::fixDataHandlePath(
0054 rootInTES(), dataMgrSvc->rootName(), BASE::msgLevel( MSG::DEBUG ) ? &this->debug() : nullptr );
0055 } );
0056 }
0057
0058
0059
0060
0061 const std::string& rootInTES() const { return m_rootInTES; }
0062
0063
0064 std::string fullTESLocation( std::string_view location, bool useRootInTES ) const {
0065 return FixTESPathDetails::fullTESLocation( location, useRootInTES ? rootInTES() : std::string_view{} );
0066 }
0067
0068 private:
0069 Gaudi::Property<std::string> m_rootInTES{ this,
0070 "RootInTES",
0071 {},
0072 [this]( Gaudi::Details::PropertyBase& ) {
0073 auto& rit = this->m_rootInTES.value();
0074 if ( !rit.empty() && rit.back() != '/' ) rit += '/';
0075 },
0076 "note: overridden by parent settings" };
0077 };
0078
0079 #endif