All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
ToolSvc.h
Go to the documentation of this file.
1 // $Id: ToolSvc.h,v 1.12 2008/06/02 14:21:35 marcocle Exp $
2 #ifndef GAUDISVC_TOOLSVC_H
3 #define GAUDISVC_TOOLSVC_H
4 
5 // Include Files
6 #include "GaudiKernel/Service.h"
7 #include "GaudiKernel/IToolSvc.h"
8 #include <vector>
9 
23 class ToolSvc : public extends1<Service, IToolSvc> {
24 
25 public:
26 
27  // Typedefs
28  typedef std::list<IAlgTool*> ListTools;
29 
31  virtual StatusCode initialize();
32 
34  virtual StatusCode finalize();
35 
36  // Start transition for tools
37  virtual StatusCode start();
38 
39  // Stop transition for tools
40  virtual StatusCode stop();
41 
43  virtual StatusCode retrieve(const std::string& type, const InterfaceID& iid,
44  IAlgTool*& tool, const IInterface* parent,
45  bool createIf);
46 
48  virtual StatusCode retrieve(const std::string& tooltype, const std::string& toolname,
49  const InterfaceID& iid, IAlgTool*& tool,
50  const IInterface* parent, bool createIf);
51 
53  virtual std::vector<std::string> getInstances( const std::string& toolType );
54 
56  virtual std::vector<std::string> getInstances() const;
57 
59  virtual std::vector<IAlgTool*> getTools() const;
60 
62  virtual StatusCode releaseTool( IAlgTool* tool );
63 
65  StatusCode create(const std::string& type, const IInterface* parent,
66  IAlgTool*& tool);
67 
69  StatusCode create(const std::string& type, const std::string& name,
70  const IInterface* parent, IAlgTool*& tool);
71 
73  bool existsTool( const std::string& toolname) const;
74 
76  std::string nameTool(const std::string& nameByUser, const IInterface* parent);
77 
79  unsigned long refCountTool( IAlgTool* tool ) const { return tool->refCount(); }
80 
85  ToolSvc( const std::string& name, ISvcLocator* svc );
86 
88  virtual ~ToolSvc();
89 
90  virtual void registerObserver(IToolSvc::Observer *obs) ;
91  virtual void unRegisterObserver(IToolSvc::Observer *obs) ;
92 
93 
94 private: // methods
95 
96  // helper functions
97  //
99  unsigned long totalToolRefCount() const;
101  unsigned long totalToolRefCount( const ListTools& ) const;
103  unsigned long minimumToolRefCount() const;
104 
106  StatusCode finalizeTool( IAlgTool* itool ) const;
107 
108 private: // data
109 
111  ListTools m_instancesTools; // List of all instances of tools
112 
115 
116  std::vector<IToolSvc::Observer*> m_observers;
117 };
118 
119 #endif
120 
121