Go to the documentation of this file.
27 #include <fmt/format.h>
40 inline std::string no_prefix(
const std::string& value,
const std::string&
prefix ) {
41 return boost::algorithm::starts_with( value,
prefix ) ? value.substr(
prefix.size() ) : value;
50 inline size_t add_prefix( MAP& _map,
const std::string&
prefix ) {
52 if (
prefix.empty() ) {
return 0; }
54 auto it = std::find_if_not( _map.begin(), _map.end(), [&](
typename MAP::ValueType::const_reference i ) {
55 return boost::algorithm::starts_with( i.first, prefix );
57 if ( it == _map.end() )
return 0;
59 std::string value = std::move( it->second );
61 _map[
key] = std::move( value );
62 return 1 + add_prefix( _map,
prefix );
70 inline size_t get_dir(
const std::string&
object,
SET& _set ) {
71 std::string::size_type ifind =
object.rfind(
'/' );
73 if ( std::string::npos == ifind ) {
return 0; }
74 if ( 0 == ifind ) {
return 0; }
75 const std::string
top = std::string(
object, 0, ifind );
77 return 1 + get_dir(
top, _set );
84 template <
class MAP,
class SET>
85 inline size_t get_dirs(
const MAP& _map,
SET& _set ) {
86 size_t size = _set.size();
87 for (
const auto& item : _map ) { get_dir( item.first, _set ); }
88 return _set.size() -
size;
94 if ( !cl ) { warning() <<
"Failed to access dictionary class for " <<
name <<
" of type:" <<
type <<
endmsg; }
121 error() <<
"Failed to setup old \"Nodes\"" <<
endmsg;
127 error() <<
"Failed to setup old \"Algorithms\"" <<
endmsg;
135 std::set<std::string> dirs;
139 auto _e = dirs.find(
"/Event" );
140 if ( dirs.end() != _e ) { dirs.erase( _e ); }
142 for (
const auto& dir : dirs ) {
180 <<
"(Alg/Node/Total)." <<
endmsg;
214 warning() <<
"ToolSvc already finalized: cannot release tools. Check options." <<
endmsg;
253 error() <<
"Failed to retrieve the IAlgManager interface." <<
endmsg;
259 error() <<
"Failed to retrieve Incident service." <<
endmsg;
266 error() <<
"Failed to retrieve the data provider interface of " <<
m_dataSvcName <<
endmsg;
274 error() <<
"Failed to retrieve ToolSvc" <<
endmsg;
295 std::string nam, typ, tag;
300 for (
auto attrib : Parser( node ) ) {
301 switch ( ::
toupper( attrib.tag[0] ) ) {
303 tag = std::move( attrib.value );
306 nam = std::move( attrib.value );
311 warning() <<
"The obsolete property 'Nodes' redefines the action for '" + tag +
"' to be '" + nam +
"'" <<
endmsg;
321 std::string typ, tag;
325 for (
auto attrib : Parser(
alg ) ) {
326 switch ( ::
toupper( attrib.tag[0] ) ) {
328 tag = std::move( attrib.value );
331 typ = std::move( attrib.value );
337 warning() <<
"The obsolete property 'Algorithms' redefines the action for '" + tag +
"' to be '" + item.
type() +
338 "/" + item.
name() +
"'"
349 l.algorithm =
m_algMgr->algorithm(
l.name,
false );
354 error() <<
"Failed to create algorithm " <<
l.type <<
"('" <<
l.name <<
"')" <<
endmsg;
355 l.algorithm =
nullptr;
360 sc =
l.algorithm->sysInitialize();
362 error() <<
"Failed to initialize algorithm " <<
l.type <<
"('" <<
l.name <<
"')" <<
endmsg;
363 l.algorithm =
nullptr;
368 sc =
l.algorithm->sysStart();
370 error() <<
"Failed to 'run' algorithm " <<
l.type <<
"('" <<
l.name <<
"')" <<
endmsg;
371 l.algorithm =
nullptr;
385 ToolGetter( std::string _path ) :
path(
std::move( _path ) ) {}
394 inline bool isGood(
const std::string& r ) {
return !r.empty(); }
401 const ToolGetter getter;
402 const std::vector<IDODNodeMapper*>& nodes;
403 const std::vector<IDODAlgMapper*>&
algs;
405 template <
class R,
class C>
406 R find(
const C&
l )
const {
407 for (
auto& i :
l ) {
408 auto result = getter( i );
409 if ( isGood( result ) )
return result;
416 Finder( std::string _path,
const std::vector<IDODNodeMapper*>& _nodes,
const std::vector<IDODAlgMapper*>& _algs )
417 : getter(
std::move( _path ) ), nodes( _nodes ),
algs( _algs ) {}
419 inline std::string node()
const {
return find<std::string>( nodes ); }
433 if ( !inc ) {
return; }
440 verbose() <<
"Incident: [" << incident.
type() <<
"] "
441 <<
" = " << incident.
source() <<
" Location:" << inc->tag() <<
endmsg;
465 std::string node = finder.node();
466 if ( isGood( node ) ) {
476 if ( isGood(
alg ) ) {
494 std::unique_ptr<DataObject> object;
496 if (
n.dataObject ) {
500 if ( !
n.clazz ) {
n.clazz = TClass::GetClass(
n.name.c_str() ); }
502 error() <<
"Failed to get dictionary for class '" <<
n.name <<
"' for location:" << tag <<
endmsg;
506 object.reset(
reinterpret_cast<DataObject*
>(
n.clazz->New() ) );
509 error() <<
"Failed to create an object of type:" <<
n.clazz->GetName() <<
" for location:" << tag <<
endmsg;
516 error() <<
"Failed to register an object of type:" <<
n.name <<
" at location:" << tag <<
endmsg;
528 if ( !
l.algorithm ) {
531 error() <<
"Failed to configure handler for: " <<
l.name <<
"[" <<
l.type <<
"] " << tag <<
endmsg;
546 error() <<
"Failed to execute the algorithm:" <<
l.algorithm->name() <<
" for location:" << tag <<
endmsg;
556 typedef std::pair<std::string, std::string> Pair;
557 std::map<std::string, Pair> _m;
560 if ( _m.end() !=
check ) {
561 warning() <<
" The data item is activated for '" <<
check->first <<
"' as '" <<
check->second.first <<
"'"
565 std::string nam = (
l.name ==
l.type ?
l.type : (
l.type +
"/" +
l.name ) );
567 if ( !mode && 0 ==
l.num ) {
continue; }
571 val = ( !
l.algorithm ) ?
"F" :
"T";
573 val = std::to_string(
l.num );
576 _m[no_prefix(
alg.first,
m_prefix )] = { nam, val };
579 for (
const auto& node :
m_nodes ) {
580 auto check = _m.find( node.first );
581 if ( _m.end() !=
check ) {
582 warning() <<
" The data item is already activated for '" <<
check->first <<
"' as '" <<
check->second.first <<
"'"
585 const Node&
n = node.second;
586 std::string nam =
"'" +
n.name +
"'";
590 if ( !mode && 0 ==
n.num ) {
continue; }
593 val = ( 0 ==
n.clazz ) ?
"F" :
"T";
595 val = std::to_string(
n.num );
598 _m[no_prefix( node.first,
m_prefix )] = { nam, val };
601 if ( _m.empty() ) {
return; }
607 for (
const auto& i : _m ) {
608 n1 = std::max( n1, i.first.size() );
609 n2 = std::max( n2, i.second.first.size() );
610 n3 = std::max( n3, i.second.second.size() );
612 n1 = std::min( n1,
size_t{ 60 } );
613 n2 = std::min( n2,
size_t{ 60 } );
618 msg <<
"Data-On-Demand Actions enabled for:";
620 msg <<
"Data-On-Demand Actions has been used for:";
623 const auto header =
fmt::format(
" | {3:<{0}.{0}s} | {4:<{1}.{1}s} | {5:>{2}.{2}s} |", n1, n2, n3,
"Address",
624 "Creator", ( mode ?
"S" :
"#" ) );
629 for (
const auto& item : _m ) {
630 msg <<
fmt::format(
"\n | {3:<{0}.{0}s} | {4:<{1}.{1}s} | {5:>{2}.{2}s} |", n1, n2, n3, item.first,
631 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
SmartIF< IFace > service(const std::string &name, bool createIf=true) const
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.
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