Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-15 08:58:01

0001 /***********************************************************************************\
0002 * (c) Copyright 1998-2024 CERN for the benefit of the LHCb and ATLAS collaborations *
0003 *                                                                                   *
0004 * This software is distributed under the terms of the Apache version 2 licence,     *
0005 * copied verbatim in the file "LICENSE".                                            *
0006 *                                                                                   *
0007 * In applying this licence, CERN does not waive the privileges and immunities       *
0008 * granted to it by virtue of its status as an Intergovernmental Organization        *
0009 * or submit itself to any jurisdiction.                                             *
0010 \***********************************************************************************/
0011 #ifndef GAUDIKERNEL_ISVCMANAGER_H
0012 #define GAUDIKERNEL_ISVCMANAGER_H
0013 
0014 // Include files
0015 #include <GaudiKernel/IComponentManager.h>
0016 #include <GaudiKernel/SmartIF.h>
0017 #include <GaudiKernel/TypeNameString.h>
0018 #include <string>
0019 
0020 // Forward class declaration
0021 #if defined( GAUDI_V20_COMPAT ) || ( !defined( GAUDI_V22_API ) || defined( G22_NEW_SVCLOCATOR ) )
0022 class ISvcFactory;
0023 #  include <GaudiKernel/IService.h>
0024 #else
0025 class IService;
0026 #endif
0027 class ISvcLocator;
0028 
0029 /** @class ISvcManager ISvcManager.h GaudiKernel/ISvcManager.h
0030 
0031     The ISvcManager is the interface implemented by the Service Factory in the
0032     Application Manager to support management functions. Clients use this
0033     interface to declare abstract service factories, and to create concrete
0034     instances of services.
0035 
0036     @author Pere Mato
0037 */
0038 class GAUDI_API ISvcManager : virtual public IComponentManager {
0039 public:
0040   /// InterfaceID
0041   DeclareInterfaceID( ISvcManager, 4, 0 );
0042 
0043   static const int DEFAULT_SVC_PRIORITY = 100;
0044 
0045   /** Add a service to the "active" list of services of the factory
0046    * @param svc Pointer to the service
0047    *
0048    * @return StatusCode indicating success or failure.
0049    */
0050   virtual StatusCode addService( IService* svc, int prio = DEFAULT_SVC_PRIORITY ) = 0;
0051 
0052 #if !defined( GAUDI_V22_API ) || defined( G22_NEW_SVCLOCATOR )
0053   /** Add a service to the "active" list of services of the factory
0054    * @param svc Pointer to the service
0055    *
0056    * @return StatusCode indicating success or failure.
0057    */
0058   [[deprecated( "use addService(type_name, prio) instead" )]] virtual StatusCode
0059   addService( const std::string& typ, const std::string& nam, int prio ) {
0060     return addService( Gaudi::Utils::TypeNameString( nam, typ ), prio );
0061   }
0062 #endif
0063 
0064   /** Add a service to the "active" list of services of the factory
0065    * @param svc Pointer to the service
0066    *
0067    * @return StatusCode indicating success or failure.
0068    */
0069   virtual StatusCode addService( const Gaudi::Utils::TypeNameString& nametype, int prio = DEFAULT_SVC_PRIORITY ) = 0;
0070 
0071   /** Remove a service from the "active" list of services of the factory
0072    * @param svc Pointer to the service
0073    *
0074    * @return StatusCode indicating success or failure.
0075    */
0076   virtual StatusCode removeService( IService* svc ) = 0;
0077 
0078   /** Remove a service from the "active" list of services of the factory
0079    * @param svc Pointer to the service
0080    *
0081    * @return StatusCode indicating success or failure.
0082    */
0083   virtual StatusCode removeService( std::string_view nam ) = 0;
0084 
0085 #if !defined( GAUDI_V22_API ) || defined( G22_NEW_SVCLOCATOR )
0086   /** Declare an abstract factory for a given service type
0087    * @param factory Abstract factory reference
0088    * @param svctype Service type name
0089    *
0090    * @return StatusCode indicating success or failure.
0091    */
0092   [[deprecated]] virtual StatusCode declareSvcFactory( const ISvcFactory& /*factory*/,
0093                                                        const std::string& /*svctype*/ ) {
0094     // This function is never used.
0095     return StatusCode::FAILURE;
0096   }
0097 #endif
0098 
0099   /** Declare the type of the service to be used when crating a given service name
0100    * @param svcname Service name
0101    * @param svctype Service type name
0102    *
0103    * @return StatusCode indicating success or failure.
0104    */
0105   virtual StatusCode declareSvcType( std::string svcname, std::string svctype ) = 0;
0106 
0107   /** Creates and instance of a service type that has been declared beforehand and
0108    * assigns it a name. It returns a pointer to an IService.
0109    * @param nametype   name/type of the service to create
0110    *
0111    * @return   SmartIF& to the created service.
0112    *
0113    * NOTE: as this returns a &, the underlying implementation
0114    *       must guarantee that once created, these SmartIF remain
0115    *       pinned in their location, thus constraining
0116    *       the underlying implementation (i.e. one cannot use
0117    *       something like std::vector<SmartIF<IService>>).
0118    *       If this interface had used value-semantics, and returned
0119    *       just plain SmartIF<IService> (i.e. WITHOUT the &) then
0120    *       the underlying implementation would have much more freedom)
0121    */
0122   virtual SmartIF<IService>& createService( const Gaudi::Utils::TypeNameString& nametype ) = 0;
0123 
0124 #if !defined( GAUDI_V22_API ) || defined( G22_NEW_SVCLOCATOR )
0125   /** Creates and instance of a service type that has been declared beforehand and
0126    * assigns it a name. It returns a pointer to an IService.
0127    * @param svctype Service type name
0128    * @param svcname Service name to be set
0129    * @param svc Returned service pointer
0130    *
0131    * @return StatusCode indicating success or failure.
0132    */
0133   [[deprecated( "use createService(type_name) instead" )]] virtual StatusCode
0134   createService( const std::string& svctype, const std::string& svcname, IService*& svc ) {
0135     SmartIF<IService> s = createService( svctype + "/" + svcname );
0136     svc                 = s.get();
0137     if ( svc ) {
0138       svc->addRef(); // Needed to maintain the correct reference counting.
0139       return StatusCode::SUCCESS;
0140     }
0141     return StatusCode::FAILURE;
0142   }
0143 
0144   /** Access to service factory by name to create unmanaged services
0145    * @param  svc_type    [IN]      Name of the service type
0146    * @param  fac         [OUT]     Reference to store pointer to service factory
0147    *
0148    * @return StatusCode indicating success or failure.
0149    */
0150   [[deprecated]] virtual StatusCode getFactory( const std::string& /*svc_type*/, const ISvcFactory*& /*fac*/ ) const {
0151     // This function is never used.
0152     return StatusCode::FAILURE;
0153   }
0154 
0155   /** Initializes the list of "active" services
0156    *
0157    * @return StatusCode indicating success or failure.
0158    */
0159   [[deprecated]] virtual StatusCode initializeServices() { return initialize(); }
0160 
0161   /** Starts the list of "active" services
0162    *
0163    * @return StatusCode indicating success or failure.
0164    */
0165   [[deprecated]] virtual StatusCode startServices() { return start(); }
0166 
0167   /** Stops the list of "active" services
0168    *
0169    * @return StatusCode indicating success or failure.
0170    */
0171   [[deprecated]] virtual StatusCode stopServices() { return stop(); }
0172 
0173   /** Finalizes the list of "active" services
0174    *
0175    * @return StatusCode indicating success or failure.
0176    */
0177   [[deprecated]] virtual StatusCode finalizeServices() { return finalize(); }
0178 
0179   /** Reinitializes the list of "active" services
0180    *
0181    * @return StatusCode indicating success or failure.
0182    */
0183   [[deprecated]] virtual StatusCode reinitializeServices() { return reinitialize(); }
0184 
0185   /** Restarts the list of "active" services
0186    *
0187    * @return StatusCode indicating success or failure.
0188    */
0189   [[deprecated]] virtual StatusCode restartServices() { return restart(); }
0190 #endif
0191 
0192   virtual int        getPriority( std::string_view name ) const    = 0;
0193   virtual StatusCode setPriority( std::string_view name, int pri ) = 0;
0194 
0195   /// Get the value of the initialization loop check flag.
0196   virtual bool loopCheckEnabled() const = 0;
0197   /// Set the value of the initialization loop check flag.
0198   virtual void setLoopCheckEnabled( bool en = true ) = 0;
0199 };
0200 
0201 #endif // GAUDIKERNEL_ISVCMANAGER_H