1 #ifndef GAUDIALG_GAUDICOMMONIMP_H
2 #define GAUDIALG_GAUDICOMMONIMP_H 1
10 #include "GaudiAlg/GetData.h"
11 #include "GaudiAlg/GaudiCommon.h"
23 template <
class PBASE >
24 inline const std::string
26 const bool useRootInTES )
const
38 return ( !useRootInTES || rootInTES().empty() ?
41 location.empty() || ( location ==
"/Event" ) ?
42 rootInTES().substr(0,rootInTES().size()-1)
44 0 == location.find(
"/Event/") ?
45 rootInTES() + location.substr(7)
47 rootInTES() + location );
52 template <
class PBASE >
53 template <
class TYPE >
56 const std::string& location,
57 const bool useRootInTES )
const
60 Assert( service ,
"get():: IDataProvider* points to NULL!" ) ;
63 return getter ( *
this ,
65 fullTESLocation ( location , useRootInTES ) ) ;
70 template <
class PBASE >
71 template <
class TYPE >
74 const std::string& location,
75 const bool useRootInTES )
const
78 Assert( service ,
"get():: IDataProvider* points to NULL!" ) ;
81 return getter ( *
this ,
83 fullTESLocation ( location , useRootInTES ),
89 template <
class PBASE >
90 template <
class TYPE >
92 const std::string& location ,
93 const bool useRootInTES )
const
96 Assert( service ,
"exist():: IDataProvider* points to NULL!" ) ;
99 return checker ( service,
100 fullTESLocation ( location , useRootInTES ) ) ;
107 template <
class PBASE>
108 template <
class TYPE,
class TYPE2>
111 const std::string& location ,
112 const bool useRootInTES )
const
115 Assert ( service ,
"getOrCreate():: svc points to NULL!" ) ;
118 return getter ( *
this ,
120 fullTESLocation( location, useRootInTES ) ,
126 template <
class PBASE >
127 template <
class TOOL >
129 const std::string&
name ,
134 if ( name.empty() )
return tool<TOOL>( type , parent , create ) ;
135 Assert( this->toolSvc(),
"tool():: IToolSvc* points to NULL!" ) ;
137 TOOL* Tool = nullptr ;
139 this->toolSvc()->retrieveTool ( type , name , Tool , parent , create ) ;
141 { Exception(
"tool():: Could not retrieve Tool '" + type +
"'/'" + name +
"'", sc ) ; }
143 { Exception(
"tool():: Could not retrieve Tool '" + type +
"'/'" + name +
"'" ) ; }
145 addToToolList( Tool );
152 template <
class PBASE >
153 template <
class TOOL >
159 Assert ( PBASE::toolSvc(),
"IToolSvc* points to NULL!" );
161 TOOL* Tool = nullptr ;
163 this->toolSvc() -> retrieveTool ( type, Tool, parent , create );
165 { Exception(
"tool():: Could not retrieve Tool '" + type +
"'", sc ) ; }
167 { Exception(
"tool():: Could not retrieve Tool '" + type +
"'" ) ; }
169 addToToolList( Tool );
176 template <
class PBASE >
177 template <
class SERVICE >
179 const bool create )
const
181 Assert ( this->svcLoc(),
"ISvcLocator* points to NULL!" );
193 auto baseSvc = this->svcLoc()->service(name, create);
197 if ( !baseSvc || !s ) {
201 addToServiceList(baseSvc);
209 template <
class PBASE>
214 { m_updMgrSvc = svc<IUpdateManagerSvc>(
"UpdateManagerSvc",
true); }
220 template <
class PBASE>
222 const std::string&
msg ,
225 if (!ok) Exception( msg , sc );
230 template <
class PBASE>
238 template <
class PBASE>
243 if (!ok) Exception( msg , sc );
260 #define ALG_ERROR( message , code ) \
262 std::string ( " [ at line " ) + \
263 std::to_string ( __LINE__ ) + \
264 std::string ( " in file '" ) + \
265 std::string ( __FILE__ ) + "']" , code ) )
271 #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.
auto begin(reverse_wrapper< T > &w)
void resetMsgStream() const
Helper structure for implementation of "get"-functions for GaudiCommon
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.
bool isFailure() const
Test for a status code of FAILURE.
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 "exists"-functions for GaudiCommon
auto end(reverse_wrapper< T > &w)
This class is used for returning status codes from appropriate routines.
Definition of the basic interface.
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.
Helper structure for implementation of "getOrCreate"-functions for GaudiCommon ...
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.
constexpr const struct GaudiCommon_details::svc_eq_t svc_eq
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.
constexpr const struct GaudiCommon_details::svc_lt_t svc_lt
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.