Creating a New Gaudi Service
- Define the Interface(s)
- What is this service supposed to do? Can the tasks be broken down into multiple components (i.e. interfaces)?
- Define the interface class(es), making sure they derive from Gaudi's IInterface class. (This defines Gaudi mechanism for identifying the interfaces at runtime.)
For each class:
- Define the methods for the interface class.
Note: This is an abstract class.. you will not actually define the implementation of these methods until you define your new Service class...see the next step.
- Define the name of the ID for this interface:
// Declaration of the interface ID ( interface id, major version, minor version)
static const InterfaceID IID_IFluxSvc(910, 1 , 0);
The convention is to name the identifier variable as
IID_NameOfInterfaceClass
Note: 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.
- Define a new class that is derived from Gaudi's Service class and your newly defined Interface class(es).
This requires defining the initialize( ), finalize( ), and queryInterface( ) methods:
initialize( ) |
|
|
|
|
|
|
|
call Service::initialize( ) as the first statement. |
|
|
|
|
|
|
|
make a call to setProperties( ) - to access jobOptions for this service |
|
|
|
|
|
|
finalize( ) |
|
|
|
|
|
|
|
perform any cleanup that is necessary, i.e. free any allocated memory |
|
|
|
|
|
|
queryInterface( ) |
|
|
|
|
|
|
|
reports the type of interfaces that a particular service implements. |
|
|
Example:
StatusCode GlastDetSvc::queryInterface (const IID& riid, void **ppvIF)
{
if (IID_IGlastDetSvc == riid) {
*ppvIF = dynamic_cast<IGlastDetSvc*> (this);
return StatusCode::SUCCESS;
}
else {
return Service::queryInterface (riid, ppvIF);
}
}
Note: Implement the methods that you defined in your Interface class(es) for this particular service.
- 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.
Example for a service, called GlastDetSvc:
(Taken from GlastSvc/GlastSvc_load.cpp):
#include "GaudiKernel/DeclareFactoryEntries.h"
DECLARE_FACTORY_ENTRIES(GlastSvc) {
DECLARE_SERVICE( GlastDetSvc);
}
There is also a GlastSvc_Dll.cpp file defined as follows:
#include "GaudiKernel/LoadFactoryEntries.h"
LOAD_FACTORY_ENTRIES(GlastSvc)
- Ensure that the shared library containing this service is loaded by updating any jobOptions files for jobs where you want this service available.
Also See:
Owned by: Heather Kelly
Last updated by: Chuck Patterson
07/29/2005 |
|
|
|
|