Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-21 10:00:32

0001 /***********************************************************************************\
0002 * (c) Copyright 1998-2019 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   virtual StatusCode addService( const std::string& typ, const std::string& nam, int prio ) {
0059     return addService( Gaudi::Utils::TypeNameString( nam, typ ), prio );
0060   }
0061 #endif
0062 
0063   /** Add a service to the "active" list of services of the factory
0064    * @param svc Pointer to the service
0065    *
0066    * @return StatusCode indicating success or failure.
0067    */
0068   virtual StatusCode addService( const Gaudi::Utils::TypeNameString& nametype, int prio = DEFAULT_SVC_PRIORITY ) = 0;
0069 
0070   /** Remove a service from the "active" list of services of the factory
0071    * @param svc Pointer to the service
0072    *
0073    * @return StatusCode indicating success or failure.
0074    */
0075   virtual StatusCode removeService( IService* svc ) = 0;
0076 
0077   /** Remove a service from the "active" list of services of the factory
0078    * @param svc Pointer to the service
0079    *
0080    * @return StatusCode indicating success or failure.
0081    */
0082   virtual StatusCode removeService( std::string_view nam ) = 0;
0083 
0084 #if !defined( GAUDI_V22_API ) || defined( G22_NEW_SVCLOCATOR )
0085   /** Declare an abstract factory for a given service type
0086    * @param factory Abstract factory reference
0087    * @param svctype Service type name
0088    *
0089    * @return StatusCode indicating success or failure.
0090    */
0091   virtual StatusCode declareSvcFactory( const ISvcFactory& /*factory*/, const std::string& /*svctype*/ ) {
0092     // This function is never used.
0093     return StatusCode::FAILURE;
0094   }
0095 #endif
0096 
0097   /** Declare the type of the service to be used when crating a given service name
0098    * @param svcname Service name
0099    * @param svctype Service type name
0100    *
0101    * @return StatusCode indicating success or failure.
0102    */
0103   virtual StatusCode declareSvcType( std::string svcname, std::string svctype ) = 0;
0104 
0105   /** Creates and instance of a service type that has been declared beforehand and
0106    * assigns it a name. It returns a pointer to an IService.
0107    * @param nametype   name/type of the service to create
0108    *
0109    * @return   SmartIF& to the created service.
0110    *
0111    * NOTE: as this returns a &, the underlying implementation
0112    *       must guarantee that once created, these SmartIF remain
0113    *       pinned in their location, thus constraining
0114    *       the underlying implementation (i.e. one cannot use
0115    *       something like std::vector<SmartIF<IService>>).
0116    *       If this interface had used value-semantics, and returned
0117    *       just plain SmartIF<IService> (i.e. WITHOUT the &) then
0118    *       the underlying implementation would have much more freedom)
0119    */
0120   virtual SmartIF<IService>& createService( const Gaudi::Utils::TypeNameString& nametype ) = 0;
0121 
0122 #if !defined( GAUDI_V22_API ) || defined( G22_NEW_SVCLOCATOR )
0123   /** Creates and instance of a service type that has been declared beforehand and
0124    * assigns it a name. It returns a pointer to an IService.
0125    * @param svctype Service type name
0126    * @param svcname Service name to be set
0127    * @param svc Returned service pointer
0128    *
0129    * @return StatusCode indicating success or failure.
0130    */
0131   virtual StatusCode createService( const std::string& svctype, const std::string& svcname, IService*& svc ) {
0132     SmartIF<IService> s = createService( svctype + "/" + svcname );
0133     svc                 = s.get();
0134     if ( svc ) {
0135       svc->addRef(); // Needed to maintain the correct reference counting.
0136       return StatusCode::SUCCESS;
0137     }
0138     return StatusCode::FAILURE;
0139   }
0140 
0141   /** Access to service factory by name to create unmanaged services
0142    * @param  svc_type    [IN]      Name of the service type
0143    * @param  fac         [OUT]     Reference to store pointer to service factory
0144    *
0145    * @return StatusCode indicating success or failure.
0146    */
0147   virtual StatusCode getFactory( const std::string& /*svc_type*/, const ISvcFactory*& /*fac*/ ) const {
0148     // This function is never used.
0149     return StatusCode::FAILURE;
0150   }
0151 
0152   /** Initializes the list of "active" services
0153    *
0154    * @return StatusCode indicating success or failure.
0155    */
0156   virtual StatusCode initializeServices() { return initialize(); }
0157 
0158   /** Starts the list of "active" services
0159    *
0160    * @return StatusCode indicating success or failure.
0161    */
0162   virtual StatusCode startServices() { return start(); }
0163 
0164   /** Stops the list of "active" services
0165    *
0166    * @return StatusCode indicating success or failure.
0167    */
0168   virtual StatusCode stopServices() { return stop(); }
0169 
0170   /** Finalizes the list of "active" services
0171    *
0172    * @return StatusCode indicating success or failure.
0173    */
0174   virtual StatusCode finalizeServices() { return finalize(); }
0175 
0176   /** Reinitializes the list of "active" services
0177    *
0178    * @return StatusCode indicating success or failure.
0179    */
0180   virtual StatusCode reinitializeServices() { return reinitialize(); }
0181 
0182   /** Restarts the list of "active" services
0183    *
0184    * @return StatusCode indicating success or failure.
0185    */
0186   virtual StatusCode restartServices() { return restart(); }
0187 #endif
0188 
0189   virtual int        getPriority( std::string_view name ) const    = 0;
0190   virtual StatusCode setPriority( std::string_view name, int pri ) = 0;
0191 
0192   /// Get the value of the initialization loop check flag.
0193   virtual bool loopCheckEnabled() const = 0;
0194   /// Set the value of the initialization loop check flag.
0195   virtual void setLoopCheckEnabled( bool en = true ) = 0;
0196 };
0197 
0198 #endif // GAUDIKERNEL_ISVCMANAGER_H