1 #ifndef GAUDIALG_GAUDICOMMONIMP_H 2 #define GAUDIALG_GAUDICOMMONIMP_H 1 23 template <
class PBASE>
25 const bool useRootInTES )
const 37 return ( !useRootInTES || rootInTES().empty()
39 : location.
empty() || ( location ==
"/Event" )
40 ? rootInTES().substr( 0, rootInTES().
size() - 1 )
41 : 0 == location.
find(
"/Event/" )
42 ? rootInTES() + location.
substr( 7 )
43 : location[0] ==
'/' ? rootInTES() + location.
substr( 1 ) : rootInTES() +
location );
48 template <
class PBASE>
54 Assert( service,
"get():: IDataProvider* points to NULL!" );
57 return getter( *
this, service, fullTESLocation( location, useRootInTES ) );
62 template <
class PBASE>
68 Assert( service,
"get():: IDataProvider* points to NULL!" );
71 return getter( *
this, service, fullTESLocation( location, useRootInTES ),
false );
76 template <
class PBASE>
79 const bool useRootInTES )
const 82 Assert( service,
"exist():: IDataProvider* points to NULL!" );
85 return checker( service, fullTESLocation( location, useRootInTES ) );
92 template <
class PBASE>
93 template <
class TYPE,
class TYPE2>
98 Assert( service,
"getOrCreate():: svc points to NULL!" );
101 return getter( *
this, service, fullTESLocation( location, useRootInTES ), location );
106 template <
class PBASE>
107 template <
class TOOL>
112 if ( name.
empty() )
return tool<TOOL>( type, parent, create );
113 Assert( this->toolSvc(),
"tool():: IToolSvc* points to NULL!" );
115 TOOL* Tool =
nullptr;
116 const StatusCode sc = this->toolSvc()->retrieveTool( type, name, Tool, parent, create );
118 Exception(
"tool():: Could not retrieve Tool '" + type +
"'/'" + name +
"'", sc );
121 Exception(
"tool():: Could not retrieve Tool '" + type +
"'/'" + name +
"'" );
124 PBASE::registerTool( Tool );
125 m_managedTools.push_back( Tool );
132 template <
class PBASE>
133 template <
class TOOL>
137 Assert( PBASE::toolSvc(),
"IToolSvc* points to NULL!" );
139 TOOL* Tool =
nullptr;
140 const StatusCode sc = this->toolSvc()->retrieveTool( type, Tool, parent, create );
142 Exception(
"tool():: Could not retrieve Tool '" + type +
"'", sc );
145 Exception(
"tool():: Could not retrieve Tool '" + type +
"'" );
148 PBASE::registerTool( Tool );
149 m_managedTools.push_back( Tool );
156 template <
class PBASE>
157 template <
class SERVICE>
160 Assert( this->svcLoc(),
"ISvcLocator* points to NULL!" );
172 auto baseSvc = this->svcLoc()->service( name, create );
176 if ( !baseSvc || !s ) {
180 addToServiceList( baseSvc );
188 template <
class PBASE>
191 if ( !m_updMgrSvc ) {
192 m_updMgrSvc = svc<IUpdateManagerSvc>(
"UpdateManagerSvc", true );
199 template <
class PBASE>
202 if ( !ok ) Exception( msg, sc );
207 template <
class PBASE>
210 if ( !ok ) Exception( msg, sc );
227 #define ALG_ERROR( message, code ) \ 228 ( Error( message + std::string( " [ at line " ) + std::to_string( __LINE__ ) + std::string( " in file '" ) + \ 229 std::string( __FILE__ ) + "']", \ 235 #endif // GAUDIALG_GAUDICOMMONIMP_H constexpr static const auto FAILURE
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.
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.