23.05.2014 Views

Athena Developer Guide

Athena Developer Guide

Athena Developer Guide

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

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

Chapter 5 Writing algorithms Version/Issue: 2.0.0<br />

Constructor and Destructor The base class has a single constructor which takes two arguments: The<br />

first is the name that will identify the algorithm object being instantiated and the second is a pointer to<br />

one of the interfaces implemented by the application manager: ISvcLocator. This interface may be<br />

used to request special services that an algorithm may wish to use, but which are not available via the<br />

standard accessor methods (below).<br />

The IAlgorithm interface Principally this consists of the three pure virtual methods that must be<br />

implemented by a derived algorithm: initialize(), execute() and finalize(). These are<br />

where the algorithm does its useful work and discussed in more detail in section 5.3. Other methods of<br />

the interface are the accessor name() which returns the algorithm’s identifying name, and<br />

sysInitialize(), sysFinalize(), sysExecute() which are used internally by the<br />

framework. The latter three methods are not virtual and may not be overridden.<br />

Service accessor methods Lines 21 to 35 declare accessor methods which return pointers to key<br />

service interfaces. These methods are available for use only after the Algorithm base class has been<br />

initialized, i.e. they may not be used from within a concrete algorithm constructor, but may be used<br />

from within the initialize() method (see 5.3.3). The services and interface types to which they<br />

point are self explanatory (see also Chapter 2). Services may be located by name using the templated<br />

service() function in lines 21 and 22 or by using the serviceLocator() accessor method on<br />

line 35, as described in section 13.2 of Chapter 13. Line 26 declares a facility to modify the message<br />

output level from within the code (the message service is described in detail in section 13.4of Chapter<br />

13).<br />

Creation of sub algorithms The methods on lines 37 to 39 are intended to be used by a derived class<br />

to manage sub-algorithms, as discussed in section 5.4.<br />

Declaration and setting of properties As mentioned above, one of the responsibilities of the base<br />

class is the management of properties. The methods in lines 41 to 45 are used by the framework to set<br />

properties as defined in the job options file. The declareProperty methods (lines 47 to 53) are<br />

intended to be used by a derived class to declare its properties. This is discussed in more detail in<br />

section 5.3.2. and in Chapter 13.<br />

Filtering The methods in lines 14 to 19 are used by sequencers and filters to access the state of the<br />

algorithm, as discussed in section 5.5.<br />

5.3 Derived algorithm classes<br />

In order for an algorithm object to do anything useful it must be specialised, i.e. it must extend (inherit<br />

from, be derived from) the Algorithm base class. In general it will be necessary to implement the<br />

methods of the IAlgorithm interface, and declare the algorithm’s properties to the property<br />

management machinery of the Algorithm base class. Additionally there is one non-obvious technical<br />

matter to cover, namely algorithm factories.<br />

page 25

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

Saved successfully!

Ooh no, something went wrong!