Commit 66f93563 authored by cvs2svn's avatar cvs2svn
Browse files

This commit was manufactured by cvs2svn to create tag

'GAUDI_v19r3-pre'.

git-svn-id: svn+ssh://svn.cern.ch/reps/gaudi/distribution/tags/GAUDI/GAUDI_v19r3-pre@3810 53ecefc3-a64d-0410-9bdf-b8581fa3287e
parent 6d9395b5
// $Header: /tmp/svngaudi/tmp.jEpFh25751/Gaudi/GaudiKernel/GaudiKernel/AlgFactory.h,v 1.9 2007/01/23 09:13:06 mato Exp $
#ifndef GAUDIKERNEL_ALGFACTORY_H
#define GAUDIKERNEL_ALGFACTORY_H
#include "Reflex/PluginService.h"
// The following is needed to be backward compatible with the old factories of Gaudi. Otherwise the components
// having the constructor/destructor protected will not be working
class IAlgorithm;
class ISvcLocator;
template <typename T> class AlgFactory {
public: static IAlgorithm* create(const std::string& name, ISvcLocator *svcloc) {
return new T(name, svcloc );
}
};
namespace {
template < typename P > class Factory<P, IAlgorithm*(std::string, ISvcLocator*)> {
public: static void* Func( void*, const std::vector<void*>& arg, void*) {
return AlgFactory<P>::create(*(std::string*)(arg[0]), (ISvcLocator*)(arg[1]));
}
};
}
//---Specialization needed to overcome a problem with Reflex.....
#ifndef TYPEDISTILLER_STRING_SPECIALIZATION
#define TYPEDISTILLER_STRING_SPECIALIZATION
namespace ROOT {
namespace Reflex {
template<> class TypeDistiller<std::string> {
public:
static Type Get() {
return TypeBuilder("std::basic_string<char>");
}
};
}
}
#endif
// Macros to declare component factories
#define DECLARE_ALGORITHM_FACTORY(x) PLUGINSVC_FACTORY(x,IAlgorithm*(std::string, ISvcLocator*))
#define DECLARE_NAMESPACE_ALGORITHM_FACTORY(n,x) using n::x; PLUGINSVC_FACTORY(x,IAlgorithm*(std::string, ISvcLocator*))
#define DECLARE_ALGORITHM(x) /*dummy*/
#define DECLARE_NAMESPACE_ALGORITHM(n,x) /*dummy*/
#endif // GAUDIKERNEL_ALGFACTORY_H
// $Id: AlgTool.h,v 1.15 2006/12/10 20:29:15 leggett Exp $
#ifndef GAUDIKERNEL_ALGTOOL_H
#define GAUDIKERNEL_ALGTOOL_H
// Include files
#include "GaudiKernel/IAlgTool.h"
#include "GaudiKernel/IProperty.h"
#include "GaudiKernel/IService.h"
#include "GaudiKernel/ISvcLocator.h"
#include "GaudiKernel/IMessageSvc.h"
#include "GaudiKernel/IToolSvc.h"
#include "GaudiKernel/PropertyMgr.h"
#include "GaudiKernel/IAuditorSvc.h"
#include <vector>
#include <list>
// Forward declarations
/** @class AlgTool AlgTool.h GaudiKernel/AlgTool.h
*
* Base class from which all the concrete tool classes
* should be derived. Specific methods for doing something
* usefull should be implemented in the concrete tools.
* Sub-types of this class could implement an additional
* interface for behaviour common to sets of concrete tools
* (for example vertexers).
*
* @author Gloria Corti
* @author Pere Mato
*/
class AlgTool : public virtual IAlgTool,
public virtual IProperty {
friend class ToolSvc;
public:
/// Query for a given interface
virtual StatusCode queryInterface(const InterfaceID& riid, void** ppvUnknown);
/// Reference Interface instance.
virtual unsigned long addRef();
/// Release Interface instance.
virtual unsigned long release();
/// Retrieve full identifying name of the concrete tool object.
virtual const std::string& name() const;
/// Retrieve type (concrete class) of the sub-algtool.
virtual const std::string& type() const;
/// Retrieve parent of the sub-algtool.
virtual const IInterface* parent() const;
/// Initialize AlgTool
virtual StatusCode initialize();
virtual StatusCode sysInitialize();
/// Finalize AlgTool
virtual StatusCode finalize();
virtual StatusCode sysFinalize();
/// Default implementations for IProperty interface.
virtual StatusCode setProperty( const Property& p );
virtual StatusCode setProperty( const std::string& s );
virtual StatusCode setProperty( const std::string& n, const std::string& v);
virtual StatusCode getProperty(Property* p) const;
virtual const Property& getProperty( const std::string& name) const;
virtual StatusCode getProperty( const std::string& n, std::string& v ) const;
virtual const std::vector<Property*>& getProperties( ) const;
/** Standard Constructor.
* @param type the concrete class of the sub-algtool
* @param name the full name of the concrete sub-algtool
* @param parent the parent of the concrete sub-algtool
*/
AlgTool( const std::string& type,
const std::string& name,
const IInterface* parent);
/// Retrieve pointer to service locator.
ISvcLocator* serviceLocator() const;
/// shortcut for the methos service locator
ISvcLocator* svcLoc() const { return serviceLocator() ; }
/// Retrieve pointer to message service.
IMessageSvc* msgSvc() const;
/// The standard ToolSvc service, Return a pointer to the service if present
IToolSvc* toolSvc() const;
/** Method for setting declared properties to the values specified in the
* jobOptions via the job option service. This method is called by the
* ToolSvc after creating the concrete tool, before passing it to the
* requesting parent and does not need to be called explicitly.
*/
StatusCode setProperties();
/** Access a service by name,
* creating it if it doesn't already exist.
*/
template <class T>
StatusCode service
( const std::string& name, T*& svc, bool createIf = true ) const {
return service_i(name, createIf, T::interfaceID(), (void**)&svc);
}
/** Access a service by name, type creating it if it doesn't already exist.
*/
template <class T>
StatusCode service( const std::string& type, const std::string& name, T*& svc) const {
return service_i(type, name, T::interfaceID(), (void**)&svc);
}
/// declare interface
void declInterface( const InterfaceID&, void*);
template <class I> class declareInterface {
public:
template <class T> declareInterface(T* tool) {
tool->declInterface( I::interfaceID(), (I*)tool);
}
};
/// Declare named properties
template <class T>
StatusCode declareProperty( const std::string& name, T& property,
const std::string& doc = "none") const {
m_propertyMgr->declareProperty(name, property, doc);
return StatusCode(StatusCode::SUCCESS,true);
}
IAuditorSvc* auditorSvc() const;
protected:
/// get tool's output level
int outputLevel () const { return (int)m_outputLevel ; }
/** Current number of refCounts.
Avoids having to call addRef() + release() to get current refCount.
Used in ToolSvc.
*/
virtual unsigned long refCount() const { return m_refCount; }
/// Accessor for the Message level property
IntegerProperty & outputLevelProperty() { return m_outputLevel; }
protected:
// Standard destructor.
virtual ~AlgTool();
private:
typedef std::list<std::pair<InterfaceID,void*> > InterfaceList;
IntegerProperty m_outputLevel; ///< AlgTool output level
std::string m_type; ///< AlgTool type (concrete class name)
const std::string m_name; ///< AlgTool full name
const IInterface* m_parent; ///< AlgTool parent
unsigned long m_refCount; ///< Reference counter
mutable ISvcLocator* m_svcLocator; ///< Pointer to Service Locator service
mutable IMessageSvc* m_messageSvc; ///< Message service
mutable IToolSvc* m_ptoolSvc; ///< Tool service
PropertyMgr* m_propertyMgr; ///< Property Manager
InterfaceList m_interfaceList; ///< Interface list
std::string m_threadID; ///< Thread Id for Alg Tool
/** implementation of service method */
StatusCode service_i(const std::string& algName,
bool createIf,
const InterfaceID& iid,
void** ppSvc) const;
StatusCode service_i(const std::string& svcType,
const std::string& svcName,
const InterfaceID& iid,
void** ppS) const;
mutable IAuditorSvc* m_pAuditorSvc; ///< Auditor Service
BooleanProperty m_auditInit;
bool m_auditorInitialize;///< flag for auditors in "initialize()"
bool m_auditorFinalize; ///< flag for auditors in "finalize()"
};
#endif // GAUDIKERNEL_ALGTOOL_H
// $Id: AlgToolHistory.h,v 1.1 2006/11/09 10:24:04 mato Exp $
#ifndef GAUDIKERNEL_ALGTOOLHISTORY_H
#define GAUDIKERNEL_ALGTOOLHISTORY_H
#include "GaudiKernel/HistoryObj.h"
class Property;
class AlgTool;
class JobHistory;
#include <string>
#include <vector>
/** @class AlgToolHistory AlgToolHistory.h
*
* AlgToolHistory class definition
*
* @author: Charles Leggett
*
*/
class AlgToolHistory: public HistoryObj {
public: // typedefs
// List of properties. This may change.
typedef std::vector<Property*> PropertyList;
private: // data
// Algtool full type.
std::string m_type;
// Algtool version.
std::string m_version;
// Algtool name.
std::string m_name;
// Pointer to the algtool
const AlgTool *m_tool;
// Properties.
PropertyList m_properties;
// Link to jobHistory
const JobHistory *m_jobHistory;
public:
AlgToolHistory(const AlgTool& alg, const JobHistory* job);
AlgToolHistory(const std::string& algVersion,
const std::string& algName,
const std::string& algType,
const AlgTool* tool,
const PropertyList& props,
const JobHistory* job);
// Destructor.
virtual ~AlgToolHistory() {};
// Class IDs
virtual const CLID& clID() const { return classID(); }
static const CLID& classID();
// Return the algtool type.
const std::string& algtool_type() const { return m_type; }
// Return the algtool version.
const std::string& algtool_version() const { return m_version; }
// Return the algtool name.
const std::string& algtool_name() const { return m_name; }
// Pointer to the algtool
const AlgTool* algtool_instance() const { return m_tool; }
// Return the algorithm properties.
const PropertyList& properties() const { return m_properties; }
};
// Output stream.
std::ostream& operator<<(std::ostream& lhs, const AlgToolHistory& rhs);
#endif
// $Id: Algorithm.h,v 1.27 2007/01/10 15:47:26 hmd Exp $
#ifndef GAUDIKERNEL_ALGORITHM_H
#define GAUDIKERNEL_ALGORITHM_H
// Include files
#include "GaudiKernel/IProperty.h"
#include "GaudiKernel/IAlgorithm.h"
#include "GaudiKernel/IService.h"
#include "GaudiKernel/PropertyMgr.h"
#include "GaudiKernel/ISvcLocator.h"
#include "GaudiKernel/IMessageSvc.h"
#include <string>
#include <vector>
// Extra include files (forward declarations should be sufficient)
#include "GaudiKernel/IDataProviderSvc.h"
#include "GaudiKernel/IHistogramSvc.h"
#include "GaudiKernel/IConversionSvc.h"
#include "GaudiKernel/INTupleSvc.h"
#include "GaudiKernel/IChronoStatSvc.h"
#include "GaudiKernel/IRndmGenSvc.h"
#include "GaudiKernel/IAuditorSvc.h"
#include "GaudiKernel/IToolSvc.h"
#include "GaudiKernel/IMonitorSvc.h"
#include "GaudiKernel/IExceptionSvc.h"
#include "GaudiKernel/Property.h"
#ifndef PACKAGE_VERSION
#define PACKAGE_VERSION "unknown"
#endif
/** @class Algorithm Algorithm.h GaudiKernel/Algorithm.h
*
* Base class from which all concrete algorithm classes should
* be derived.
* In order for a concrete algorithm class to do anything
* useful the methods initialize(), execute() and finalize()
* should be overridden.
* The base class provides utility methods for accessing
* standard services (event data service etc.); for declaring
* properties which may be configured by the job options
* service; and for creating sub algorithms.
* The only base class functionality which may be used in the
* constructor of a concrete algorithm is the declaration of
* member variables as properties. All other functionality,
* i.e. the use of services and the creation of sub-algorithms,
* may be used only in initialise() and afterwards (see the
* Gaudi user guide).
*
* @author Paul Maley
* @author Pere Mato
* @author David Quarrie
* @date 1998
*/
class Algorithm : virtual public IAlgorithm,
virtual public IProperty {
public:
/** Constructor
* @param name The algorithm object's name
* @param svcloc A pointer to a service location service
*/
Algorithm( const std::string& name, ISvcLocator *svcloc,
const std::string& version=PACKAGE_VERSION );
/// Destructor
virtual ~Algorithm();
/** Reinitialization method invoked by the framework. This method is responsible
* for any reinitialization required by the framework itself.
* It will in turn invoke the reinitialize() method of the derived algorithm,
* and of any sub-algorithms which it creates.
*/
virtual StatusCode sysReinitialize();
/** Initialization method invoked by the framework. This method is responsible
* for any bookkeeping of initialization required by the framework itself.
* It will in turn invoke the initialize() method of the derived algorithm,
* and of any sub-algorithms which it creates.
*/
virtual StatusCode sysInitialize();
/** The actions to be performed by the algorithm on an event. This method is
* invoked once per event for top level algorithms by the application
* manager.
* This method invokes execute() method.
* For sub-algorithms either the sysExecute() method or execute() method
* must be EXPLICITLY invoked by the parent algorithm.
*/
virtual StatusCode sysExecute();
/** System finalization. This method invokes the finalize() method of a
* concrete algorithm and the finalize() methods of all of that algorithm's
* sub algorithms.
*/
virtual StatusCode sysFinalize();
/** beginRun method invoked by the framework. This method is responsible
for any beginRun actions required by the framework itself.
It will in turn invoke the beginRun() method of the derived algorithm,
and of any sub-algorithms which it creates.
*/
virtual StatusCode sysBeginRun( );
/** endRun method invoked by the framework. This method is responsible
for any endRun actions required by the framework itself.
It will in turn invoke the endRun() method of the derived algorithm,
and of any sub-algorithms which it creates.
*/
virtual StatusCode sysEndRun( );
/** The identifying name of the algorithm object. This is the name of a
* particular instantiation of an algorithm object as opposed to the name
* of the algorithm itself, e.g. "LinearTrackFit" may be the name of a
* concrete algorithm class,
* whereas "ApproxTrackFit" and "BestTrackFit" may be two instantiations
* of the class configured to find tracks with different fit criteria.
*/
virtual const std::string& name() const;
virtual const std::string& version() const;
/// the default (empty) implementation of IAlgorithm::initialize() methoda
virtual StatusCode initialize () { return StatusCode::SUCCESS ; }
/// the default (empty) implementation of IAlgorithm::reinitialize() methoda
virtual StatusCode reinitialize ();
/// the default (empty) implementation of IAlgorithm::finalize() methoda
virtual StatusCode finalize () { return StatusCode::SUCCESS ; }
/// Has this algorithm been executed since the last reset?
virtual bool isExecuted( ) const;
/// Set the executed flag to the specified state
virtual StatusCode setExecuted( bool state );
/** Reset the executed state of the Algorithm for the duration
* of the current event.
*/
virtual StatusCode resetExecuted( );
/** Algorithm begin run. This method is called at the beginning
* of the event loop.
*/
virtual StatusCode beginRun();
/// Algorithm end run. This method is called at the end of the event loop
virtual StatusCode endRun();
/// Is this algorithm enabled or disabled?
virtual bool isEnabled( ) const;
/// Did this algorithm pass or fail its filter criterion for the last event?
virtual bool filterPassed( ) const;
/// Set the filter passed flag to the specified state
virtual StatusCode setFilterPassed( bool state );
/// Access a service by name, creating it if it doesn't already exist.
template <class T>
StatusCode service
( const std::string& name, T*& psvc, bool createIf = true ) const {
return service_i(name, createIf, T::interfaceID(), (void**)&psvc);
}
/// Access a service by name and type, creating it if it doesn't already exist.
template <class T>
StatusCode service( const std::string& svcType, const std::string& svcName,
T*& psvc) const {
return service_i(svcType, svcName, T::interfaceID(), (void**)&psvc);
}
/// Set the outputlevel for current algorithm
void setOutputLevel( int level );
/** The standard auditor service.May not be invoked before sysInitialize()
* has been invoked.
*/
IAuditorSvc* auditorSvc() const;
/** The standard Chrono & Stat service,
* Return a pointer to the service if present
*/
IChronoStatSvc* chronoSvc() const;
/// Obsoleted name, kept due to the backwards compatibility
IChronoStatSvc* chronoStatService() const;
/** The standard detector data service.
* May not be invoked before sysInitialize() has been invoked.
*/
IDataProviderSvc* detSvc() const;
/// Obsoleted name, kept due to the backwards compatibility
IDataProviderSvc* detDataService() const;
/** The standard detector data persistency conversion service.
* May not be invoked before sysInitialize() has been invoked.
*/
IConversionSvc* detCnvSvc() const;
/// Obsoleted name, kept due to the backwards compatibility
IConversionSvc* detDataCnvService() const;
/** The standard event data service.
* May not be invoked before sysInitialize() has been invoked.
*/
IDataProviderSvc* eventSvc() const;
/// shortcut for method eventSvc
IDataProviderSvc* evtSvc () const { return eventSvc() ; }
/// Obsoleted name, kept due to the backwards compatibility
IDataProviderSvc* eventDataService() const;
/** The standard event data persistency conversion service.
* May not be invoked before sysInitialize() has been invoked.
*/
IConversionSvc* eventCnvSvc() const;
/// Obsoleted name, kept due to the backwards compatibility
IConversionSvc* eventDataCnvService() const;
/** The standard histogram service.
* May not be invoked before sysInitialize() has been invoked.
*/
IHistogramSvc* histoSvc() const;
/// Obsoleted name, kept due to the backwards compatibility
IHistogramSvc* histogramDataService() const;
/** The standard message service.
* Returns a pointer to the standard message service.
* May not be invoked before sysInitialize() has been invoked.
*/
IMessageSvc* msgSvc() const;
/// Obsoleted name, kept due to the backwards compatibility
IMessageSvc* messageService() const;
/** The standard N tuple service.
* Returns a pointer to the N tuple service if present.
*/
INTupleSvc* ntupleSvc() const;
/// Obsoleted name, kept due to the backwards compatibility
INTupleSvc* ntupleService() const;
/** AIDA-based NTuple service
* Returns a pointer to the AIDATuple service if present.
*/
// IAIDATupleSvc* atupleSvc() const;
/** The standard RandomGen service,
* Return a pointer to the service if present
*/
IRndmGenSvc* randSvc() const;
/// The standard ToolSvc service, Return a pointer to the service if present
IToolSvc* toolSvc() const;
/// Get the exception svc
IExceptionSvc* exceptionSvc() const;
/** The standard service locator.
* Returns a pointer to the service locator service.
* This service may be used by an algorithm to request
* any services it requires in addition to those provided by default.
*/
ISvcLocator* serviceLocator() const;
/// shortcut for method serviceLocator
ISvcLocator* svcLoc () const { return serviceLocator() ; }
/** Create a sub algorithm.
* A call to this method creates a child algorithm object.
* Note that the returned pointer is to Algorithm
* (as opposed to IAlgorithm), and thus the methods of IProperty
* are also available for the direct setting of the sub-algorithm's
* properties. Using this mechanism instead of creating daughter
* algorithms directly via the new operator is prefered since then
* the framework may take care of all of the necessary book-keeping.
* @param type The concrete algorithm class of the sub algorithm
* @param name The name to be given to the sub algorithm
* @param pSubAlg Set to point to the newly created algorithm object
*/
StatusCode createSubAlgorithm( const std::string& type,
const std::string& name, Algorithm*& pSubAlg );
/// List of sub-algorithms. Returns a pointer to a vector of (sub) Algorithms
std::vector<Algorithm*>* subAlgorithms() const;
/// Implementation of IProperty::setProperty
virtual StatusCode setProperty( const Property& p );
/// Implementation of IProperty::setProperty
virtual StatusCode setProperty( const std::string& s );
/// Implementation of IProperty::setProperty
virtual StatusCode setProperty(