Creating a New Gaudi Tool

  1. Define the Interface(s)
    1. What is this service supposed to do?  Can the tasks be broken down into multiple components (i.e. interfaces)
    1. Define the interface class(es), making sure they derive from Gaudi's IAlgTool class.

    For each class:

    • Define the name of the ID for this interface.

    // Declaration of the interface ID ( interface id, major version, minor version) 
    static const InterfaceID IID_IExampleTool("IExampleTool", 1 , 0); 


    The convention is to name the identifier variable as:

    IID_NameOfInterfaceClass

    Each Interface is assigned its own unique ID.  Gaudi has already defined IDs for each of its own interfaces.  You do not want to re-use an existing ID.

    Add a public method to the Interface class:

    static const InterfaceID& interfaceID() { return IID_IExampleTool; }

  1. Define a new concrete class that is derived from Gaudi's AlgTool class and your newly defined Interface class(es).

    This class much contain a constructor of the form:

myNewTool( const std::string& type, const std::string& name, const IInterface* parent);

In the new concrete class implementation file you must have something like:

#include "GaudiKernel/ToolFactory.h"

static ToolFactory<myNewTool> s_factory;
const IToolFactory& myNewToolFactory = s_factory;

myNewTool::myNewTool( const std::string& type, 
                                            const std::string& name,         
                                            const IInterface* parent)
                                        : AlgTool(type,name,parent)
        {
        // declare base interface for all consecutive concrete classes
        declareInterface<IExampleTool>(this);
        }

  1. Make your service available to be dynamically loaded at run time.  This is accomplished within your package's packagename_load( ) and packagename_dll( ) routines.

Currently, the convention is to place these files within a directory called Dll under the package's src directory.  You will only have to modify the packagename_load( ) file by adding the following line to the DECLARE_FACTORY_ENTRIES method:

DECLARE_TOOL(myNewTool);

 

Owned by: Heather Kelly

Last updated by: Chuck Patterson 07/29/2005