Go to the documentation of this file.
27 #include <fmt/format.h>
43 return boost::algorithm::starts_with( value,
prefix ) ? value.
substr(
prefix.size() ) : value;
55 if (
prefix.empty() ) {
return 0; }
57 auto it =
std::find_if_not( _map.begin(), _map.end(), [&](
typename MAP::ValueType::const_reference i ) {
58 return boost::algorithm::starts_with( i.first, prefix );
60 if ( it == _map.end() )
return 0;
65 return 1 + add_prefix( _map,
prefix );
76 std::string::size_type ifind =
object.rfind(
'/' );
78 if ( std::string::npos == ifind ) {
return 0; }
79 if ( 0 == ifind ) {
return 0; }
83 return 1 + get_dir(
top, _set );
91 template <
class MAP,
class SET>
92 inline size_t get_dirs(
const MAP& _map,
SET& _set ) {
93 size_t size = _set.size();
94 for (
const auto& item : _map ) { get_dir( item.first, _set ); }
95 return _set.size() -
size;
102 if ( !cl ) { warning() <<
"Failed to access dictionary class for " <<
name <<
" of type:" <<
type <<
endmsg; }
132 error() <<
"Failed to setup old \"Nodes\"" <<
endmsg;
138 error() <<
"Failed to setup old \"Algorithms\"" <<
endmsg;
150 auto _e = dirs.
find(
"/Event" );
151 if ( dirs.
end() != _e ) { dirs.
erase( _e ); }
153 for (
const auto& dir : dirs ) {
198 <<
"(Alg/Node/Total)." <<
endmsg;
232 warning() <<
"ToolSvc already finalized: cannot release tools. Check options." <<
endmsg;
277 error() <<
"Failed to retrieve the IAlgManager interface." <<
endmsg;
283 error() <<
"Failed to retrieve Incident service." <<
endmsg;
290 error() <<
"Failed to retrieve the data provider interface of " <<
m_dataSvcName <<
endmsg;
298 error() <<
"Failed to retrieve ToolSvc" <<
endmsg;
327 for (
auto attrib : Parser( node ) ) {
328 switch ( ::
toupper( attrib.tag[0] ) ) {
338 warning() <<
"The obsolete property 'Nodes' redefines the action for '" + tag +
"' to be '" + nam +
"'" <<
endmsg;
355 for (
auto attrib : Parser(
alg ) ) {
356 switch ( ::
toupper( attrib.tag[0] ) ) {
367 warning() <<
"The obsolete property 'Algorithms' redefines the action for '" + tag +
"' to be '" + item.
type() +
368 "/" + item.
name() +
"'"
382 l.algorithm =
m_algMgr->algorithm(
l.name,
false );
387 error() <<
"Failed to create algorithm " <<
l.type <<
"('" <<
l.name <<
"')" <<
endmsg;
388 l.algorithm =
nullptr;
393 sc =
l.algorithm->sysInitialize();
395 error() <<
"Failed to initialize algorithm " <<
l.type <<
"('" <<
l.name <<
"')" <<
endmsg;
396 l.algorithm =
nullptr;
401 sc =
l.algorithm->sysStart();
403 error() <<
"Failed to 'run' algorithm " <<
l.type <<
"('" <<
l.name <<
"')" <<
endmsg;
404 l.algorithm =
nullptr;
434 const ToolGetter getter;
438 template <
class R,
class C>
439 R
find(
const C&
l )
const {
440 for (
auto& i :
l ) {
441 auto result = getter( i );
442 if ( isGood( result ) )
return result;
450 : getter(
std::
move( _path ) ), nodes( _nodes ),
algs( _algs ) {}
452 inline std::string node()
const {
return find<std::string>( nodes ); }
469 if ( !inc ) {
return; }
476 verbose() <<
"Incident: [" << incident.
type() <<
"] "
477 <<
" = " << incident.
source() <<
" Location:" << inc->tag() <<
endmsg;
502 if ( isGood( node ) ) {
512 if ( isGood(
alg ) ) {
535 if (
n.dataObject ) {
539 if ( !
n.clazz ) {
n.clazz = TClass::GetClass(
n.name.c_str() ); }
541 error() <<
"Failed to get dictionary for class '" <<
n.name <<
"' for location:" << tag <<
endmsg;
545 object.reset(
reinterpret_cast<DataObject*
>(
n.clazz->New() ) );
548 error() <<
"Failed to create an object of type:" <<
n.clazz->GetName() <<
" for location:" << tag <<
endmsg;
555 error() <<
"Failed to register an object of type:" <<
n.name <<
" at location:" << tag <<
endmsg;
570 if ( !
l.algorithm ) {
573 error() <<
"Failed to configure handler for: " <<
l.name <<
"[" <<
l.type <<
"] " << tag <<
endmsg;
588 error() <<
"Failed to execute the algorithm:" <<
l.algorithm->name() <<
" for location:" << tag <<
endmsg;
609 warning() <<
" The data item is activated for '" <<
check->first <<
"' as '" <<
check->second.first <<
"'"
613 std::string nam = (
l.name ==
l.type ?
l.type : (
l.type +
"/" +
l.name ) );
615 if ( !mode && 0 ==
l.num ) {
continue; }
619 val = ( !
l.algorithm ) ?
"F" :
"T";
624 _m[no_prefix(
alg.first,
m_prefix )] = { nam, val };
627 for (
const auto& node :
m_nodes ) {
630 warning() <<
" The data item is already activated for '" <<
check->first <<
"' as '" <<
check->second.first <<
"'"
633 const Node&
n = node.second;
638 if ( !mode && 0 ==
n.num ) {
continue; }
641 val = ( 0 ==
n.clazz ) ?
"F" :
"T";
646 _m[no_prefix( node.first,
m_prefix )] = { nam, val };
649 if ( _m.
empty() ) {
return; }
655 for (
const auto& i : _m ) {
656 n1 =
std::max( n1, i.first.size() );
657 n2 =
std::max( n2, i.second.first.size() );
658 n3 =
std::max( n3, i.second.second.size() );
666 msg <<
"Data-On-Demand Actions enabled for:";
668 msg <<
"Data-On-Demand Actions has been used for:";
671 const auto header =
fmt::format(
" | {3:<{0}.{0}s} | {4:<{1}.{1}s} | {5:>{2}.{2}s} |", n1, n2, n3,
"Address",
672 "Creator", ( mode ?
"S" :
"#" ) );
677 for (
const auto& item : _m ) {
678 msg <<
fmt::format(
"\n | {3:<{0}.{0}s} | {4:<{1}.{1}s} | {5:>{2}.{2}s} |", n1, n2, n3, item.first,
679 item.second.first, item.second.second );
void toupper(std::string &s)
StatusCode i_setAlgHandler(const std::string &name, const Gaudi::Utils::TypeNameString &alg)
Internal method to initialize an algorithm handler.
void i_setNodeHandler(const std::string &name, const std::string &type)
Internal method to initialize a node handler.
StatusCode initialize() override
const std::string & source() const
Access to the source of the incident.
constexpr auto size(const T &, Args &&...) noexcept
const std::string & name() const
Gaudi::Property< Setup > m_algMapping
Gaudi::Property< std::vector< std::string > > m_algMapTools
StatusCode initialize() override
Inherited Service overrides: Service initialization.
GAUDI_API const EventContext & currentContext()
iterator find(const key_type &key)
StatusCode configureHandler(Leaf &leaf)
Configure handler for leaf.
Gaudi::Property< bool > m_allowInitFailure
void reset(TYPE *ptr=nullptr)
Set the internal pointer to the passed one disposing of the old one.
StatusCode setupAlgHandlers()
Initialize leaf handlers.
StatusCode setup()
Setup routine (called by (re-) initialize.
SmartIF< IDataProviderSvc > m_dataSvc
Data provider reference.
std::vector< IDODAlgMapper * > m_algMappers
MSG::Level msgLevel() const
get the cached level (originally extracted from the embedded MsgStream)
StatusCode finalize() override
Gaudi::StateMachine::State FSMState() const override
Interface of tools used by the DataOnDemandSvc to choose the algorithm to be run to produce the data ...
SmartIF< IAlgManager > m_algMgr
Algorithm manager.
unsigned long long m_stat
Helper class to parse a string of format "type/name".
Gaudi::Property< bool > m_partialPath
const std::string & name() const override
Retrieve name of the service
Gaudi::Property< std::string > m_trapType
std::string outputUserTime() const
print the chrono ;
SmartIF< IToolSvc > m_toolSvc
Data provider reference.
Gaudi::Property< Map > m_nodeMap
def check(causes, result)
const ValueType & value() const
StatusCode execHandler(const std::string &tag, Leaf &leaf)
Execute leaf handler (algorithm)
Gaudi::Property< std::string > m_prefix
GAUDI_API std::string format(const char *,...)
MsgStream format utility "a la sprintf(...)".
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Gaudi::Property< bool > m_dump
unsigned long long m_statNode
const std::string & type() const
const StatusCode & ignore() const
Allow discarding a StatusCode without warning.
Gaudi::Property< std::vector< std::string > > m_nodeMapTools
void dump(const MSG::Level level, const bool mode=true) const
dump the content of DataOnDemand service
Gaudi::Property< Map > m_algMap
AlgMap m_algs
Map of algorithms to handle incidents.
Gaudi::Property< Setup > m_nodeMapping
constexpr static const auto SUCCESS
Gaudi::Property< std::string > m_dataSvcName
StatusCode setupNodeHandlers()
Initialize node handlers.
#define DECLARE_COMPONENT(type)
NodeMap m_nodes
Map of "empty" objects to be placed as intermediate nodes.
StatusCode reinitialize() override
ChronoEntity m_timer_algs
StatusCode finalize() override
Inherited Service overrides: Service finalization.
StatusCode update()
update the handlers
const std::string & type() const
Access to the incident type.
constexpr static const auto FAILURE
ChronoEntity m_timer_nodes
Parse attribute strings allowing iteration over the various attributes.
StatusCode reinitialize() override
Inherited Service overrides: Service reinitialization.
StatusCode service(const std::string &name, const T *&psvc, bool createIf=true) const
Access a service by name, creating it if it doesn't already exist.
Gaudi::Property< bool > m_init
SmartIF< ISvcLocator > & serviceLocator() const override
Retrieve pointer to service locator
SmartIF< IIncidentSvc > m_incSvc
Incident service.
void handle(const Incident &incident) override
IIncidentListener interfaces overrides: incident handling.
Interface of tools used by the DataOnDemandSvc to choose the type of node to be created at a path.
std::vector< IDODNodeMapper * > m_nodeMappers
unsigned long long m_statAlg