1 #ifndef GAUDIALG_GAUDICOMMONIMP_H 2 #define GAUDIALG_GAUDICOMMONIMP_H 1 23 template <
class PBASE>
25 const bool useRootInTES )
const {
36 return ( !useRootInTES || rootInTES().empty()
38 : location.
empty() || ( location ==
"/Event" )
39 ? rootInTES().substr( 0, rootInTES().
size() - 1 )
40 : 0 == location.
find(
"/Event/" )
41 ? rootInTES() + location.
substr( 7 )
42 : location[0] ==
'/' ? rootInTES() + location.
substr( 1 ) : rootInTES() +
location );
47 template <
class PBASE>
52 Assert( service,
"get():: IDataProvider* points to NULL!" );
55 return getter( *
this, service, fullTESLocation( location, useRootInTES ) );
60 template <
class PBASE>
64 const bool useRootInTES )
const {
66 Assert( service,
"get():: IDataProvider* points to NULL!" );
69 return getter( *
this, service, fullTESLocation( location, useRootInTES ),
false );
74 template <
class PBASE>
77 const bool useRootInTES )
const {
79 Assert( service,
"exist():: IDataProvider* points to NULL!" );
82 return checker( service, fullTESLocation( location, useRootInTES ) );
89 template <
class PBASE>
90 template <
class TYPE,
class TYPE2>
93 const bool useRootInTES )
const {
95 Assert( service,
"getOrCreate():: svc points to NULL!" );
98 return getter( *
this, service, fullTESLocation( location, useRootInTES ), location );
103 template <
class PBASE>
104 template <
class TOOL>
106 bool create )
const {
108 if ( name.
empty() )
return tool<TOOL>( type, parent, create );
109 Assert( this->toolSvc(),
"tool():: IToolSvc* points to NULL!" );
111 TOOL* Tool =
nullptr;
112 const StatusCode sc = this->toolSvc()->retrieveTool( type, name, Tool, parent, create );
113 if ( sc.
isFailure() ) { Exception(
"tool():: Could not retrieve Tool '" + type +
"'/'" + name +
"'", sc ); }
114 if ( !Tool ) { Exception(
"tool():: Could not retrieve Tool '" + type +
"'/'" + name +
"'" ); }
116 PBASE::registerTool( Tool );
117 m_managedTools.push_back( Tool );
124 template <
class PBASE>
125 template <
class TOOL>
128 Assert( PBASE::toolSvc(),
"IToolSvc* points to NULL!" );
130 TOOL* Tool =
nullptr;
131 const StatusCode sc = this->toolSvc()->retrieveTool( type, Tool, parent, create );
132 if ( sc.
isFailure() ) { Exception(
"tool():: Could not retrieve Tool '" + type +
"'", sc ); }
133 if ( !Tool ) { Exception(
"tool():: Could not retrieve Tool '" + type +
"'" ); }
135 PBASE::registerTool( Tool );
136 m_managedTools.push_back( Tool );
143 template <
class PBASE>
144 template <
class SERVICE>
146 Assert( this->svcLoc(),
"ISvcLocator* points to NULL!" );
154 if ( !s ) { Exception(
"svc():: Could not retrieve Svc '" + name +
"'",
StatusCode::FAILURE ); }
156 auto baseSvc = this->svcLoc()->service( name, create );
160 if ( !baseSvc || !s ) { Exception(
"svc():: Could not retrieve Svc '" + name +
"'",
StatusCode::FAILURE ); }
162 addToServiceList( baseSvc );
170 template <
class PBASE>
172 if ( !m_updMgrSvc ) { m_updMgrSvc = svc<IUpdateManagerSvc>(
"UpdateManagerSvc", true ); }
178 template <
class PBASE>
180 if ( !ok ) Exception( msg, sc );
185 template <
class PBASE>
187 if ( !ok ) Exception( msg, sc );
204 #define ALG_ERROR( message, code ) \ 205 ( Error( message + std::string( " [ at line " ) + std::to_string( __LINE__ ) + std::string( " in file '" ) + \ 206 std::string( __FILE__ ) + "']", \ 212 #endif // GAUDIALG_GAUDICOMMONIMP_H Small smart pointer class with automatic reference counting for IInterface.
IUpdateManagerSvc * updMgrSvc() const
Short-cut to locate the Update Manager Service.
constexpr const struct GaudiCommon_details::svc_eq_t svc_eq
Gaudi::Utils::GetData< TYPE >::return_type getOrCreate(IDataProviderSvc *svc, const std::string &location, const bool useRootInTES=true) const
Get the existing data object from Gaudi Event Transient store.
Helper structure for implementation of "get"-functions for GaudiCommon<BASE>
bool exist(IDataProviderSvc *svc, const std::string &location, const bool useRootInTES=true) const
Check the existence of a data object or container in the Gaudi Transient Event Store.
Data provider interface definition.
constexpr auto size(const C &c) noexcept(noexcept(c.size())) -> decltype(c.size())
constexpr const struct GaudiCommon_details::svc_lt_t svc_lt
Helper structure for implementation of "exists"-functions for GaudiCommon<BASE>
This class is used for returning status codes from appropriate routines.
Definition of the basic interface.
Helper structure for implementation of "getOrCreate"-functions for GaudiCommon<BASE> ...
Interface class to the Update Manager service.
Gaudi::Utils::GetData< TYPE >::return_type get(IDataProviderSvc *svc, const std::string &location, const bool useRootInTES=true) const
Templated access to the data in Gaudi Transient Store.
void Assert(const bool ok, const std::string &message="", const StatusCode sc=StatusCode(StatusCode::FAILURE, true)) const
Assertion - throw exception if the given condition is not fulfilled.
constexpr static const auto FAILURE
const std::string fullTESLocation(const std::string &location, const bool useRootInTES) const
Returns the full correct event location given the rootInTes settings.
Gaudi::Utils::GetData< TYPE >::return_type getIfExists(IDataProviderSvc *svc, const std::string &location, const bool useRootInTES=true) const
Quicker version of the get function which bypasses the check on the retrieved data.
TOOL * tool(const std::string &type, const std::string &name, const IInterface *parent=0, bool create=true) const
Useful method for the easy location of tools.
SmartIF< SERVICE > svc(const std::string &name, const bool create=true) const
A useful method for the easy location of services.