23.05.2014 Views

Athena Developer Guide

Athena Developer Guide

Athena Developer Guide

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>Athena</strong><br />

Chapter 14 Tools and ToolSvc Version/Issue: 2.0.0<br />

14.3 The ToolSvc<br />

The ToolSvc manages Tools. It is its responsibility to create tools and make them available to<br />

Algorithms or Services.<br />

The ToolSvc verifies if a tool type is available and creates the necessary instance after having verified<br />

if it doesn’t already exist. If a tool instance exists the ToolSvc will not create a new identical one but<br />

pass to the algorithm the existing instance. Tools are created on a “first request” basis: the first<br />

Algorithm requesting a tool will prompt its creation. The relationship between an algorithm, the<br />

ToolSvc and Tools is shown in Figure 14.1.<br />

IToolSvc<br />

ToolSvc<br />

IService<br />

IAlgTool<br />

IProperty<br />

ConcreteAlgorithm<br />

AlgTool<br />

IToolFactory<br />

ToolFactory<br />

< T ><br />

ConcreteTool<br />

Figure 14.1 ToolSvc design diagram<br />

The ToolSvc will “hold” a tool until it is no longer used by any component or until the finalize()<br />

method of the tool service is called. Algorithms can inform the ToolSvc they are not going to use a<br />

tool previously requested via the releaseTool method of the IToolSvc interface 1 .<br />

The ToolSvc is created by default by the ApplicationMgr and algorithms wishing to use the<br />

service can retrieve it using the service accessor method of the Algorithm base class as shown in<br />

the lines below.<br />

include "GaudiKernel/IToolSvc.h"<br />

...<br />

IToolSvc* toolSvc=0;<br />

StatusCode sc = service( "ToolSvc",toolSvc);<br />

if ( sc.isFailure) {<br />

...<br />

1. The releaseTool method is not available in this release<br />

page 129

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!