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

IToolSvc.h

Go to the documentation of this file.
00001 #ifndef GAUDIKERNEL_ITOOLSVC_H
00002 #define GAUDIKERNEL_ITOOLSVC_H
00003 
00004 #include "GaudiKernel/IInterface.h"
00005 #include "GaudiKernel/System.h"
00006 #include <string>
00007 
00008 // Forward declaration
00009 class IAlgTool;
00010 // Declaration of the interface ID ( interface id, major version, minor version) 
00011 static const InterfaceID IID_IToolSvc(301, 1 , 0); 
00012 
00019 class IToolSvc : virtual public IInterface {
00020   public:
00021 
00023   static const InterfaceID& interfaceID() { return IID_IToolSvc; }
00024 
00034   virtual StatusCode retrieve(const std::string& type,
00035                               IAlgTool*& tool,
00036                               const IInterface* parent=0,
00037                               bool createIf=true ) = 0;
00038 
00049   virtual StatusCode retrieve(const std::string& type,
00050                               const std::string& name,
00051                               IAlgTool*& tool,
00052                               const IInterface* parent=0,
00053                               bool createIf=true) = 0;
00054 
00055 
00064   template <class T>
00065   StatusCode retrieveTool( const std::string& type, T*& tool, 
00066                            const IInterface* parent=0, bool createIf=true ) {
00067     IAlgTool* algtool;
00068     StatusCode sc = retrieve( type, 
00069                               algtool,
00070                               parent,
00071                               createIf );
00072     if( sc.isSuccess() ) {
00073       tool = dynamic_cast<T*>( algtool);
00074       if( 0 == tool) sc = StatusCode::FAILURE;
00075     }
00076     return sc;
00077   }
00078 
00090   template <class T>
00091   StatusCode retrieveTool( const std::string& type, const std::string& name, T*& tool, 
00092                            const IInterface* parent=0, bool createIf=true ) {
00093     IAlgTool* algtool;
00094     StatusCode sc = retrieve( type, 
00095                               name,
00096                               algtool,
00097                               parent,
00098                               createIf );
00099     if( sc.isSuccess() ) {
00100       tool = dynamic_cast<T*>( algtool);
00101       if( 0 == tool) sc = StatusCode::FAILURE;
00102     }
00103     return sc;
00104   }
00105 
00106 };
00107 
00108 
00109 #endif // GAUDIKERNEL_ITOOLSVC_H

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