Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members  

ToolSvc.h

Go to the documentation of this file.
00001 // $Header: /nfs/slac/g/glast/ground/cvs/GaudiSvc/src/ToolSvc/ToolSvc.h,v 1.1.1.2 2001/04/18 18:32:51 tlindner Exp $
00002 #ifndef ToolSVC_ToolSVC_H
00003 #define ToolSVC_ToolSVC_H
00004 
00005 // Include Files
00006 #include "GaudiKernel/Service.h"
00007 #include "GaudiKernel/IObjManager.h"
00008 #include "GaudiKernel/IToolSvc.h"
00009 
00010 // Forward declarations
00011 template <class TYPE> class SvcFactory;
00012 
00013 //------------------------------------------------------------------
00014 //
00015 // ClassName:   ToolSvc
00016 //  
00017 // Description: This service manages tools. 
00018 //              Tools can be common, in which case a single instance
00019 //              can be shared by different algorithms, or private
00020 //              in which case it is necessary to specify the parent
00021 //              when requesting it.
00022 //              The parent of a tool can be an algortihm or a Service
00023 //              The environment of a tool is set by using that of the
00024 //              parent. A common tool is considered to belong to the
00025 //              ToolSvc itself.
00026 //              Note that this is a prototype version.
00027 //              
00028 // Author:      G.Corti, P.Mato
00029 //------------------------------------------------------------------
00030 
00031 class ToolSvc : public Service, virtual public IToolSvc {
00032 
00033 public: 
00034   
00035 // Typedefs 
00036   typedef std::list<IAlgTool*>     ListTools;
00037 
00038 // Inherited Service overrides:
00039 //
00040   // Initialise the service.
00041   virtual StatusCode initialize();
00042   
00043   // Finalise the service.
00044   virtual StatusCode finalize();
00045   
00046   // Query the interfaces.
00047   //   Input: riid, Requested interface ID
00048   //          ppvInterface, Pointer to requested interface
00049   //   Return: StatusCode indicating SUCCESS or FAILURE.
00050   // N.B. Don't forget to release the interface after use!!!
00051   virtual StatusCode queryInterface( const IID& riid, void** ppvInterface );
00052     
00053 // IToolSvc interfaces overwrite
00054 // 
00055   // Retrieve tool, create it by default as common tool if it does not already exist
00056   virtual StatusCode retrieve(const std::string& type, IAlgTool*& tool, const IInterface* parent,
00057                                   bool createIf); 
00058   
00059   virtual StatusCode retrieve(const std::string& tooltype, const std::string& toolname,  
00060                                   IAlgTool*& tool, const IInterface* parent, bool createIf);
00061 
00062 
00063 // Additional methods not in the interfaces  
00064 //
00065   // Create Tool standard way with automatically assigned name
00066   StatusCode create(const std::string& type, const IInterface* parent, 
00067                             IAlgTool*& tool);
00068 
00069   // Create Tool standard way with specified name
00070   StatusCode create(const std::string& type, const std::string& name, 
00071                             const IInterface* parent, IAlgTool*& tool);
00072 
00073   // Check if the tool instance exists
00074   bool existsTool( const std::string& toolname) const;
00075 
00076   // Get Tool full name by combining nameByUser and "parent" part
00077   std::string nameTool(const std::string& nameByUser, const IInterface* parent);
00078 
00079 protected:
00080   
00081   // Standard Constructor.
00082   //   Input:  name   String with service name
00083   //   Input:  svc    Pointer to service locator interface
00084   ToolSvc( const std::string& name, ISvcLocator* svc );
00085   
00086   // Destructor.
00087   virtual ~ToolSvc();
00088 
00089 private:
00090   // Allow SvcFactory to instantiate the service.
00091   friend class SvcFactory<ToolSvc>;
00092 
00093   // Manager of the AlgTool Objects
00094   IObjManager* m_objManager;             
00095 
00096   // Common Tools
00097   ListTools*    m_instancesTools;        // List of all instances of tools
00098 
00099 };
00100 
00101 #endif
00102 
00103 

Generated at Wed Nov 21 12:22:31 2001 by doxygen1.2.3 written by Dimitri van Heesch, © 1997-2000