1 #ifndef GAUDIKERNEL_ALGORITHM_H
2 #define GAUDIKERNEL_ALGORITHM_H
6 #include "GaudiKernel/IProperty.h"
7 #include "GaudiKernel/IAlgorithm.h"
8 #include "GaudiKernel/IService.h"
9 #include "GaudiKernel/PropertyMgr.h"
10 #include "GaudiKernel/ISvcLocator.h"
11 #include "GaudiKernel/IMessageSvc.h"
12 #include "GaudiKernel/IStateful.h"
18 #include "GaudiKernel/IDataProviderSvc.h"
19 #include "GaudiKernel/IHistogramSvc.h"
20 #include "GaudiKernel/IConversionSvc.h"
21 #include "GaudiKernel/INTupleSvc.h"
22 #include "GaudiKernel/IChronoStatSvc.h"
23 #include "GaudiKernel/IRndmGenSvc.h"
24 #include "GaudiKernel/IAuditorSvc.h"
25 #include "GaudiKernel/IToolSvc.h"
26 #include "GaudiKernel/IMonitorSvc.h"
27 #include "GaudiKernel/IExceptionSvc.h"
28 #include "GaudiKernel/IAlgContextSvc.h"
29 #include "GaudiKernel/Property.h"
30 #include <Gaudi/PluginService.h>
32 #ifndef PACKAGE_VERSION
33 #define PACKAGE_VERSION "unknown"
147 const std::string&
name()
const override;
149 const std::string& version()
const override;
174 bool isExecuted( )
const override;
177 void setExecuted(
bool state )
override;
182 void resetExecuted( )
override;
194 bool isEnabled( )
const override;
197 bool filterPassed( )
const override;
200 void setFilterPassed(
bool state )
override;
208 (
const std::string&
name, T*& psvc,
bool createIf =
true )
const {
209 return service_i(name, createIf, T::interfaceID(), (
void**)&psvc);
216 return service_i(svcType, svcName, T::interfaceID(), (
void**)&psvc);
220 SmartIF<IService> service(
const std::string& name,
const bool createIf =
true,
const bool quiet =
false)
const;
224 return service(name,createIf,quiet).as<T>();
228 void setOutputLevel(
int level );
343 const std::string& name,
Algorithm*& pSubAlg );
346 const std::vector<Algorithm*>* subAlgorithms()
const;
349 std::vector<Algorithm*>* subAlgorithms() ;
364 const std::vector<Property*>& getProperties( )
const override;
366 bool hasProperty(
const std::string& name)
const override;
408 (
const std::string& name ,
410 const std::string& doc =
"none" )
const
412 return m_propertyMgr->declareProperty(name, property, doc);
417 (
const std::string& name ,
419 const std::string& rname =
"" )
const
421 return m_propertyMgr -> declareRemoteProperty ( name , rsvc , rname );
436 if ( !m_pMonitorSvc ){
437 m_pMonitorSvc = service(m_monitorSvcName,
false,
true);
439 return m_pMonitorSvc;
450 const std::string& desc )
const
464 const std::string&
format,
467 const std::string& desc )
const
470 if ( mS ) mS->
declareInfo(name, format, var, size, desc,
this);
517 template <
class TYPE>
519 (
const std::string& name ,
538 void initOutputLevel(
Property& prop);
562 bool m_registerContext = false ;
579 bool m_filterPassed =
true;
580 bool m_isEnabled =
true;
581 bool m_isExecuted =
false;
587 StatusCode service_i(
const std::string& svcName,
591 StatusCode service_i(
const std::string& svcType,
592 const std::string& svcName,
603 #ifndef GAUDI_NEW_PLUGIN_SERVICE
608 template <
typename S,
typename... Args>
610 return new T(std::forward<Args>(
args)...);
616 #define DECLARE_ALGORITHM_FACTORY(x) \
617 DECLARE_FACTORY_WITH_CREATOR(x, AlgFactory< x >, Algorithm::Factory)
618 #define DECLARE_NAMED_ALGORITHM_FACTORY(x, n) \
619 DECLARE_FACTORY_WITH_CREATOR_AND_ID(x, AlgFactory< x >, \
620 #n, Algorithm::Factory)
621 #define DECLARE_NAMESPACE_ALGORITHM_FACTORY(n, x) \
622 DECLARE_ALGORITHM_FACTORY(n::x)
627 #define DECLARE_ALGORITHM_FACTORY(x) DECLARE_COMPONENT(x)
628 #define DECLARE_NAMED_ALGORITHM_FACTORY(x, n) DECLARE_COMPONENT_WITH_ID(x, #n)
629 #define DECLARE_NAMESPACE_ALGORITHM_FACTORY(n, x) DECLARE_COMPONENT(n::x)
633 #endif //GAUDIKERNEL_ALGORITHM_H
StatusCode service(const std::string &svcType, const std::string &svcName, T *&psvc) const
Access a service by name and type, creating it if it doesn't already exist.
SmartIF< IChronoStatSvc > m_CSS
Chrono & Stat Service.
StatusCode setProperty(IProperty *component, const std::string &name, const TYPE &value, const std::string &doc)
simple function to set the property of the given object from the value
Base class used to implement the interfaces.
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
SmartIF< ISvcLocator > & svcLoc() const
shortcut for method serviceLocator
void declareInfo(const std::string &name, const std::string &format, const void *var, int size, const std::string &desc) const
Declare monitoring information (special case)
SmartIF< IHistogramSvc > m_HDS
Histogram data service.
IntegerProperty & outputLevelProperty()
Accessor for the Message level property.
SmartIF< IConversionSvc > m_DCS
Detector conversion service.
BooleanProperty m_auditInit
global flag for auditors
StatusCode terminate() override
Dummy implementation of IStateful::terminate() method.
SmartIF< IToolSvc > m_ptoolSvc
ToolSvc Service.
StatusCode finalize() override
the default (empty) implementation of IStateful::finalize() method
SmartIF< ISvcLocator > m_pSvcLocator
Pointer to service locator service.
Gaudi::PluginService::Factory< IAlgorithm *, const std::string &, ISvcLocator * > Factory
int errorCount() const
Get the number of failures of the algorithm.
GAUDI_API bool hasProperty(const IProperty *p, const std::string &name)
simple function which check the existence of the property with the given name.
bool m_auditorBeginRun
flag for auditors in "beginRun()"
SmartIF< IExceptionSvc > m_EXS
Exception Handler Service.
SmartIF< IRndmGenSvc > m_RGS
Random Number Generator Service.
State
Allowed states for classes implementing the state machine (ApplicationMgr, Algorithm, Service, AlgTool).
SmartIF< IAuditorSvc > m_pAuditorSvc
Auditor Service.
bool isFinalized() const override
Has the Algorithm already been finalized?
const char *PyHelper() getProperty(IInterface *p, char *name)
SmartIF< IMonitorSvc > m_pMonitorSvc
Online Monitoring Service.
std::string m_version
Algorithm's version.
int m_errorMax
Algorithm Max number of errors.
int m_errorCount
Algorithm error counter.
implements & operator=(const implements &)
Assignment operator (do not touch the reference count).
SmartIF< IDataProviderSvc > m_DDS
Detector data service.
std::vector< Algorithm * > m_subAlgms
Sub algorithms.
SmartIF< IDataProviderSvc > m_EDS
Event data service.
bool m_auditorExecute
flag for auditors in "execute()"
Definition of the IMonitorSvc interface, which publishes Gaudi variables to outside monitoring proces...
SmartIF< T > service(const std::string &name, bool createIf=true, bool quiet=false) const
bool m_auditorReinitialize
flag for auditors in "Reinitialize()"
SmartIF< PropertyMgr > m_propertyMgr
For management of properties.
This class is used for returning status codes from appropriate routines.
SmartIF< IConversionSvc > m_ECS
Event conversion service.
bool PyHelper() setProperty(IInterface *p, char *name, char *value)
bool m_isFinalized
Algorithm has been finalized flag.
SmartIF< INTupleSvc > m_NTS
N tuple service.
SmartIF< IMonitorSvc > & monitorSvc() const
Access the monitor service.
The IAlgorithm is the interface implemented by the Algorithm base class.
void declareInfo(const std::string &name, const T &var, const std::string &desc) const
Declare monitoring information.
bool m_auditorRestart
flag for auditors in "Restart()"
bool m_auditorStart
flag for auditors in "initialize()"
Base class from which all concrete algorithm classes should be derived.
SmartIF< IDataProviderSvc > & evtSvc() const
shortcut for method eventSvc
Property base class allowing Property* collections to be "homogeneous".
virtual void declareInfo(const std::string &name, const bool &var, const std::string &desc, const IInterface *owner)=0
Declare monitoring information.
Gaudi::StateMachine::State FSMState() const override
returns the current state of the algorithm
bool isInitialized() const override
Has the Algorithm already been initialized?
Class wrapping the signature for a factory with any number of arguments.
bool registerContext() const
register for Algorithm Context Service?
std::string m_name
Algorithm's name for identification.
static S::ReturnType create(Args &&...args)
StatusCode initialize() override
the default (empty) implementation of IStateful::initialize() method
bool m_auditorInitialize
flag for auditors in "initialize()"
IntegerProperty m_outputLevel
Algorithm output level.
StatusCode start() override
the default (empty) implementation of IStateful::start() method
SmartIF< IAlgContextSvc > m_contextSvc
Algorithm Context Service.
int outputLevel() const
retrieve the Algorithm output level
StatusCode stop() override
the default (empty) implementation of IStateful::stop() method
SmartIF< IMessageSvc > m_MS
Message service.
bool m_auditorStop
flag for auditors in "Reinitialize()"
Gaudi::StateMachine::State targetFSMState() const override
returns the state the algorithm will be in after the ongoing transition
The IProperty is the basic interface for all components which have properties that can be set or get...
bool m_auditorEndRun
flag for auditors in "endRun()"
std::string m_monitorSvcName
Name to use for Monitor Service.
GAUDI_API std::string format(const char *,...)
MsgStream format utility "a la sprintf(...)".
StatusCode configure() override
Dummy implementation of IStateful::configure() method.
bool m_auditorFinalize
flag for auditors in "finalize()"