The Gaudi Framework  v32r2 (46d42edc)
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"
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:
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
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
Definition: ISvcLocator.h:25
Implementation of property with value of concrete type.
Definition: Property.h:352
STL class.
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
Gaudi::Property< std::string > m_rootInTES
Definition: FixTESPath.h:60
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:50
Definition of the basic interface.
Definition: IInterface.h:244
virtual bool hasProperty(const std::string &name) const =0
Return true if we have a property with the given name.
bool PyHelper() setProperty(IInterface *p, char *name, char *value)
Definition: Bootstrap.cpp:233
std::string fullTESLocation(std::string_view location, std::string_view rit)
Definition: FixTESPath.cpp:46
PropertyBase base class allowing PropertyBase* collections to be "homogeneous".
Definition: Property.h:32
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
const std::string & rootInTES() const
Returns the "rootInTES" string.
Definition: FixTESPath.h:52
std::string fullTESLocation(std::string_view location, bool useRootInTES) const
Returns the full correct event location given the rootInTes settings.
Definition: FixTESPath.h:55
StatusCode initialize() override
Definition: FixTESPath.h:39
bool isFailure() const
Definition: StatusCode.h:130
std::unique_ptr< IDataHandleVisitor > fixDataHandlePath(std::string_view rit, std::string rootName, MsgStream *dbg)
Definition: FixTESPath.cpp:67
The IProperty is the basic interface for all components which have properties that can be set or get.
Definition: IProperty.h:20