1 #ifndef GAUDIKERNEL_SERVICEHANDLE_H 2 #define GAUDIKERNEL_SERVICEHANDLE_H 16 #include <type_traits> 21 class ServiceHandleProperty;
45 :
GaudiHandle<T>( serviceName,
"Service", theParentName )
59 template <class OWNER, typename = typename std::enable_if<std::is_base_of<IProperty, OWNER>::value>
::type>
63 auto p = owner->OWNER::PropertyHolderImpl::declareProperty(
std::move( PropName ), *
this,
std::move( doc ) );
64 p->template setOwnerType<OWNER>();
183 inline std::ostream& operator<<( std::ostream& os, const ServiceHandle<T>& handle )
185 return operator<<( os, static_cast<const GaudiHandleInfo&>( handle ) );
189 inline std::ostream& operator<<( std::ostream& os, const ServiceHandleArray<T>& handle )
191 return operator<<( os, static_cast<const GaudiHandleInfo&>( handle ) );
194 #endif // ! GAUDIKERNEL_SERVICEHANDLE_H Handle to be used in lieu of naked pointers to services.
SmartIF< ISvcLocator > m_pSvcLocator
ServiceHandle(OWNER *owner, std::string PropName, std::string svcName, std::string doc="")
Autodeclaring constructor with property name, service type/name and documentation.
constexpr static const auto FAILURE
an helper to share the implementation of service() among the various kernel base classes ...
Handle to be used in lieu of naked pointers to gaudis.
std::string messageName() const
name used for printing messages
Define general base for Gaudi exception.
virtual ~ServiceHandleArray()
void setTypeAndName(std::string myTypeAndName)
The component "type/name" string.
SmartIF< IMessageSvc > m_pMessageSvc
SmartIF< IMessageSvc > & messageSvc() const
const std::string & parentName() const
The name of the parent.
T * operator->() const
Allow non const access to the service, even from a const handle...
void setParentName(const std::string &parent)
The name of the parent.
void push_back(Container &c, const Value &v, std::true_type)
SmartIF< ISvcLocator > & serviceLocator() const
Do the real release of the Service.
StatusCode initialize(const std::string &serviceName, const std::string &theParentName)
GAUDI_API ISvcLocator * svcLocator()
std::remove_const_t< T > * nonConst(T *p)
Cast a pointer to a non const type.
This class is used for returning status codes from appropriate routines.
StatusCode retrieve() const
Retrieve the component.
Array of Handles to be used in lieu of vector of naked pointers to tools.
StatusCode retrieve() const
Retrieve the Service.
constexpr static const auto SUCCESS
virtual bool push_back(const ServiceHandle< T > &myHandle)
std::string type() const
The concrete component class name: the part before the '/'.
virtual bool push_back(const std::string &serviceTypeAndName)
Add a handle to the array with "type/name" given in <myHandleTypeAndName>.
std::string name() const
The instance name: the part after the '/'.
ServiceHandle(const ServiceHandle< NCT > &other, typename std::enable_if< std::is_const< CT >::value &&!std::is_same< CT, NCT >::value >::type *=nullptr)
Copy constructor from a non const T to const T service handle.
std::string typeAndName() const
The full type and name: "type/name".
ServiceHandle(const std::string &serviceName, const std::string &theParentName)
Create a handle ('smart pointer') to a service.
StatusCode retrieve(T *&service) const override
Do the real retrieval of the Service.
StatusCode getService(const std::string &name, bool createIf, const InterfaceID &iid, void **ppSvc) const
ServiceHandleArray(const std::vector< std::string > &myTypesAndNamesList, const std::string &myComponentType, const std::string &myParentName)
Generic constructor.
ServiceHandleArray(const std::string &myParentName)
T is the concrete handle type, e.g.