| The Gaudi Framework v32r1 (f65d50dc)

FixTESPath.h
Go to the documentation of this file.
1 #ifndef GAUDIALG_FIXTESPATH_H
2 #define GAUDIALG_FIXTESPATH_H
3 #include <memory>
4 #include <string>
5 #include <string_view>
6 #include <type_traits>
7
8 #include "GaudiKernel/AlgTool.h"
9 #include "GaudiKernel/Algorithm.h"
10 #include "GaudiKernel/IDataManagerSvc.h"
11 #include "GaudiKernel/MsgStream.h"
12 #include "GaudiKernel/Property.h"
13
14 namespace FixTESPathDetails {
15 std::unique_ptr<IDataHandleVisitor> fixDataHandlePath( std::string_view rit, std::string rootName, MsgStream* dbg );
16 std::string fullTESLocation( std::string_view location, std::string_view rit );
17 } // namespace FixTESPathDetails
18
19 template <class BASE>
20 class FixTESPath : public BASE {
21 public:
24 template <typename U = BASE, typename = std::enable_if_t<std::is_base_of_v<Gaudi::Algorithm, BASE>, U>>
25 FixTESPath( const std::string& name, ISvcLocator* pSvcLocator ) : BASE( name, pSvcLocator ) {}
26
29 template <typename U = BASE, typename = std::enable_if_t<std::is_base_of_v<AlgTool, BASE>, U>>
30 FixTESPath( const std::string& type, const std::string& name, const IInterface* ancestor )
31 : BASE( type, name, ancestor ) {
32 // setup RootInTES from parent if available
33 if ( const IProperty* ancestorProp = dynamic_cast<const IProperty*>( ancestor );
34 ancestorProp && ancestorProp->hasProperty( "RootInTES" ) ) {
35 this->setProperty( ancestorProp->getProperty( "RootInTES" ) ).ignore();
36 }
37 }
38
39 StatusCode initialize() override {
40 const StatusCode sc = BASE::initialize();
41 if ( sc.isFailure() ) return sc;
42 // TODO: just call 'acceptDHVisitor` and remove m_updateDataHandles...
43 SmartIF<IDataManagerSvc> dataMgrSvc{BASE::evtSvc()};
44 this->m_updateDataHandles = FixTESPathDetails::fixDataHandlePath(
45 rootInTES(), dataMgrSvc->rootName(), BASE::msgLevel( MSG::DEBUG ) ? &this->debug() : nullptr );
46 return sc;
47 }
48
52 const std::string& rootInTES() const { return m_rootInTES; }
53 // ==========================================================================
55 std::string fullTESLocation( std::string_view location, bool useRootInTES ) const {
56 return FixTESPathDetails::fullTESLocation( location, useRootInTES ? rootInTES() : std::string_view{} );
57 }
58 // ==========================================================================
59 private:
60 Gaudi::Property<std::string> m_rootInTES{this,
61 "RootInTES",
62 {},
63 [=]( Gaudi::Details::PropertyBase& ) { // Check rootInTES ends with a '/'
64 auto& rit = this->m_rootInTES.value();
65 if ( !rit.empty() && rit.back() != '/' ) rit += '/';
66 },
67 "note: overridden by parent settings"};
68 };
69
70 #endif
MsgStream
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
Algorithm.h
SmartIF< IDataManagerSvc >
ISvcLocator
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
Definition: ISvcLocator.h:25
gaudiComponentHelp.name
name
Definition: gaudiComponentHelp.py:41
Gaudi::Property
Implementation of property with value of concrete type.
Definition: Property.h:352
MsgStream.h
AlgTool.h
GaudiPython.HistoUtils.location
location
Definition: HistoUtils.py:936
MSG::DEBUG
Definition: IMessageSvc.h:15
std::string
STL class.
FixTESPath::FixTESPath
FixTESPath(const std::string &type, const std::string &name, const IInterface *ancestor)
Tool constructor - SFINAE-ed to insure this constructor is only defined if BASE derives from AlgTool.
Definition: FixTESPath.h:30
IDataManagerSvc.h
FixTESPath::m_rootInTES
Gaudi::Property< std::string > m_rootInTES
Definition: FixTESPath.h:60
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:50
IInterface
Definition of the basic interface.
Definition: IInterface.h:244
gaudirun.type
type
Definition: gaudirun.py:142
FixTESPathDetails
Definition: FixTESPath.h:14
IProperty::hasProperty
virtual bool hasProperty(const std::string &name) const =0
Return true if we have a property with the given name.
setProperty
bool PyHelper() setProperty(IInterface *p, char *name, char *value)
Definition: Bootstrap.cpp:233
FixTESPathDetails::fullTESLocation
std::string fullTESLocation(std::string_view location, std::string_view rit)
Definition: FixTESPath.cpp:40
Gaudi::Details::PropertyBase
PropertyBase base class allowing PropertyBase* collections to be "homogeneous".
Definition: Property.h:32
FixTESPath::FixTESPath
FixTESPath(const std::string &name, ISvcLocator *pSvcLocator)
Algorithm constructor - the SFINAE constraint below ensures that this is constructor is only defined ...
Definition: FixTESPath.h:25
FixTESPath::rootInTES
const std::string & rootInTES() const
Returns the "rootInTES" string.
Definition: FixTESPath.h:52
std::unique_ptr< IDataHandleVisitor >
Property.h
FixTESPath::fullTESLocation
std::string fullTESLocation(std::string_view location, bool useRootInTES) const
Returns the full correct event location given the rootInTes settings.
Definition: FixTESPath.h:55
FixTESPath::initialize
StatusCode initialize() override
Definition: FixTESPath.h:39
StatusCode::isFailure
bool isFailure() const
Definition: StatusCode.h:130
FixTESPathDetails::fixDataHandlePath
std::unique_ptr< IDataHandleVisitor > fixDataHandlePath(std::string_view rit, std::string rootName, MsgStream *dbg)
Definition: FixTESPath.cpp:61
IProperty
The IProperty is the basic interface for all components which have properties that can be set or get.
Definition: IProperty.h:20
FixTESPath
Definition: FixTESPath.h:20