4 #include "GaudiKernel/IAlgManager.h"
5 #include "GaudiAlg/GaudiSequencer.h"
6 #include "GaudiAlg/ISequencerTimerTool.h"
7 #include "GaudiKernel/IJobOptionsSvc.h"
15 template<
typename T,
typename ...Args>
16 std::unique_ptr<T> make_unique_( Args&& ...
args ) {
17 return std::unique_ptr<T>(
new T( std::forward<Args>(
args)... ) );
20 bool isDefault(
const std::string&
s) {
return s.empty(); }
21 constexpr
bool isDefault(
double x) {
return x == 0; }
26 class populate_JobOptionsSvc_t {
27 std::vector<std::unique_ptr<Property>> m_props;
31 template <
typename T>
void process(T&& t) {
35 if (!isDefault(std::get<1>(t))) m_props.push_back( make_unique_<prop_t>( std::get<0>(t), std::get<1>(t) ) ) ;
37 template <
typename T,
typename... Args>
void process(T&& t, Args&&...
args) {
38 process(std::forward<T>(t)); process(std::forward<Args>(
args)...);
43 for (
const auto&
i : *props ) {
45 [&
i](
const std::unique_ptr<Property>& prop) {
46 return prop->
name() ==
i->name();
50 if (m_props.empty())
break;
55 template <
typename... Args>
57 process(std::forward<Args>(
args)...);
58 if (!m_props.empty()) check_veto();
59 std::for_each(
std::begin(m_props),
std::end(m_props), [&](
const std::unique_ptr<Property>&
i ) {
63 ~populate_JobOptionsSvc_t() {
64 std::for_each(
std::begin(m_props),
std::end(m_props), [&](
const std::unique_ptr<Property>& i ) {
70 template <
typename Stream,
typename Container,
typename Separator,
typename Transform>
71 Stream& ostream_joiner(Stream& os,
const Container&
c, Separator sep, Transform trans )
74 if (first!=last) { os << trans(*first); ++first; }
75 for (;first!=last;++first) os << sep << trans(*first);
95 declareProperty(
"Members" ,
m_names );
96 declareProperty(
"ModeOR" ,
m_modeOR =
false );
99 declareProperty(
"ReturnOK" ,
m_returnOK =
false );
113 if ( !status.
isSuccess() )
return status;
115 m_timerTool = tool<ISequencerTimerTool>(
"SequencerTimerTool" );
132 status = entry.algorithm()->sysInitialize();
134 return Error(
"Can not initialize " + entry.algorithm()->name(),
172 verbose() <<
"Algorithm " << myAlg->
name() <<
" returned filter passed "
173 << (passed ?
"true" :
"false") <<
endmsg;
174 if ( entry.reverse() ) passed = !passed;
192 if (
m_modeOR ? passed : !passed ) {
195 verbose() <<
"SeqPass is now " << (seqPass ?
"true" :
"false") <<
endmsg;
202 verbose() <<
"SeqPass is " << (seqPass ?
"true" :
"false") <<
endmsg;
203 if ( !
m_ignoreFilter && !m_entries.empty() ) setFilterPassed( seqPass );
249 auto jos = service<IJobOptionsSvc>(
"JobOptionsSvc" );
252 auto appMgr = service<IAlgManager>(
"ApplicationMgr");
255 const std::string &theName = typeName.
name();
256 const std::string &theType = typeName.
type();
265 populate_JobOptionsSvc_t populate_guard{ theName, jos,
266 std::forward_as_tuple(
"Context",
context() ),
267 std::forward_as_tuple(
"RootInTES",
rootInTES() ),
271 result = createSubAlgorithm( theType, theName, myAlg );
276 subAlgorithms()->push_back(myAlg);
312 warning() << theName <<
" is not an Algorithm - failed dynamic_cast"
317 warning() <<
"Unable to find or create " << theName <<
endmsg;
326 msg <<
"Member list: ";
330 return ( alg->
name() == typ ) ? alg->
name() : ( typ +
"/" + alg->
name() );
332 if ( !isDefault(
context()) ) msg <<
", with context '" <<
context() <<
"'";
355 {
m_timerTool = tool<ISequencerTimerTool>(
"SequencerTimerTool" ) ; }
void membershipHandler(Property &theProp)
for asynchronous changes in the list of algorithms
Definition of the MsgStream class used to transmit messages.
virtual const std::vector< const Property * > * getProperties(const std::string &client) const =0
Get the properties associated to a given client.
MsgStream & verbose() const
shortcut for the method msgStream(MSG::VERBOSE)
StatusCode execute() override
Algorithm execution.
bool m_shortCircuit
Indicates whether to stop processing as soon as possible, or to always execute all subalgorithms...
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
virtual StatusCode sysStart()=0
Startup method invoked by the framework.
const std::string & rootInTES() const
Returns the "rootInTES" string.
bool m_returnOK
Forces the sequencer to return a good status.
bool m_modeOR
Indicates that the OR is wanted instead of AND.
const std::string & name() const
property name
StatusCode initialize() override
Algorithm initialization.
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
StatusCode initialize() override
standard initialization method
auto begin(reverse_wrapper< T > &w)
bool isSuccess() const
Test for a status code of SUCCESS.
GAUDI_API const std::string typeinfoName(const std::type_info &)
Get platform independent information about the class type.
StatusCode Error(const std::string &msg, const StatusCode st=StatusCode::FAILURE, const size_t mx=10) const
Print the error message and return with the given StatusCode.
MsgStream & warning() const
shortcut for the method msgStream(MSG::WARNING)
bool filterPassed() const override
Did this algorithm pass or fail its filter criterion for the last event?
const std::string & context() const
Returns the "context" string. Used to identify different processing states.
Algorithm * algorithm() const
bool isFailure() const
Test for a status code of FAILURE.
StatusCode endRun() override
Algorithm endRun.
virtual StatusCode sysInitialize()=0
Initialization method invoked by the framework.
MsgStream & msg() const
shortcut for the method msgStream(MSG::INFO)
const std::string & name() const override
The identifying name of the algorithm object.
SimpleProperty concrete class which implements the full Property interface.
TYPE * get() const
Get interface pointer.
Helper class to parse a string of format "type/name".
void setExecuted(bool state) override
Set the executed flag to the specified state.
Main interface for the JobOptions service.
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
auto end(reverse_wrapper< T > &w)
unsigned long addRef() override
Reference Interface instance.
This class is used for returning status codes from appropriate routines.
StatusCode sysExecute() override
The actions to be performed by the algorithm on an event.
bool m_measureTime
Flag to measure time.
bool isExecuted() const override
Has this algorithm been executed since the last reset?
StatusCode finalize() override
standard finalization method
The useful base class for data processing algorithms.
StatusCode finalize() override
Algorithm finalization.
const TYPE & value() const
explicit conversion
StatusCode decodeNames()
Decode a vector of string.
Base class from which all concrete algorithm classes should be derived.
Property base class allowing Property* collections to be "homogeneous".
bool isEnabled() const override
Is this algorithm enabled or disabled?
const std::string & type() const
virtual StatusCode removePropertyFromCatalogue(const std::string &client, const std::string &name)=0
Remove a property from the JobOptions catalog.
virtual StatusCode addPropertyToCatalogue(const std::string &client, const Property &property)=0
Add a property into the JobOptions catalog.
virtual void declareUpdateHandler(std::function< void(Property &)> fun)
set new callback for update
GaudiSequencer(const std::string &name, ISvcLocator *pSvcLocator)
Standard constructor.
const std::string & name() const
double globalTimeOffset() const
Returns the "globalTimeOffset" double.
std::string typeName(const std::type_info &typ)
MsgStream & info() const
shortcut for the method msgStream(MSG::INFO)
StatusCode release(const IInterface *interface) const
Manual forced (and 'safe') release of the active tool or service.
bool m_ignoreFilter
True if one continues always.
std::vector< AlgorithmEntry > m_entries
List of algorithms to process.
int m_timer
Timer number for the sequencer.
ISequencerTimerTool * m_timerTool
Pointer to the timer tool.
StatusCode beginRun() override
Algorithm beginRun.
StringArrayProperty m_names
Input string, list of algorithms.
MSG::Level msgLevel() const
get the output level from the embedded MsgStream