36 #include "boost/algorithm/string/predicate.hpp" 37 #include "boost/format.hpp" 50 verbose() <<
"updated property " << p.name() <<
", forcig update" <<
endmsg;
53 m_algMap.declareUpdateHandler( force_update );
54 m_nodeMap.declareUpdateHandler( force_update );
60 m_algMapping.declareUpdateHandler( deprecated_property );
77 return boost::algorithm::starts_with( value, prefix ) ? value.
substr( prefix.
size() ) : value;
87 inline size_t add_prefix( MAP& _map,
const std::string& prefix )
90 if ( prefix.
empty() ) {
94 auto it =
std::find_if_not( _map.begin(), _map.end(), [&](
typename MAP::ValueType::const_reference i ) {
95 return boost::algorithm::starts_with( i.first, prefix );
97 if ( it == _map.end() )
return 0;
102 return 1 + add_prefix( _map, prefix );
114 std::string::size_type ifind =
object.rfind(
'/' );
116 if ( std::string::npos == ifind ) {
125 return 1 + get_dir( top, _set );
133 template <
class MAP,
class SET>
134 inline size_t get_dirs(
const MAP& _map,
SET& _set )
136 size_t size = _set.size();
137 for (
const auto& item : _map ) {
138 get_dir( item.first, _set );
140 return _set.size() -
size;
149 warning() <<
"Failed to access dictionary class for " << name <<
" of type:" << type <<
endmsg;
184 error() <<
"Failed to setup old \"Nodes\"" <<
endmsg;
190 error() <<
"Failed to setup old \"Algorithms\"" <<
endmsg;
206 auto _e = dirs.
find(
"/Event" );
207 if ( dirs.
end() != _e ) {
211 for (
const auto& dir : dirs ) {
220 for (
const auto& alg :
m_algMap ) {
266 <<
"(Alg/Node/Total)." <<
endmsg;
300 warning() <<
"ToolSvc already finalized: cannot release tools. Check options." <<
endmsg;
321 m_nodeMappers.clear();
323 m_algMappers.clear();
351 error() <<
"Failed to retrieve the IAlgManager interface." <<
endmsg;
357 error() <<
"Failed to retrieve Incident service." <<
endmsg;
402 for (
auto attrib : Parser( node ) ) {
403 switch (::
toupper( attrib.tag[0] ) ) {
413 warning() <<
"The obsolete property 'Nodes' redefines the action for '" + tag +
"' to be '" + nam +
"'" <<
endmsg;
431 for (
auto attrib : Parser( alg ) ) {
432 switch (::
toupper( attrib.tag[0] ) ) {
443 warning() <<
"The obsolete property 'Algorithms' redefines the action for '" + tag +
"' to be '" + item.
type() +
444 "/" + item.
name() +
"'" 480 error() <<
"Failed to initialize algorithm " << l.
type <<
"('" << l.
name <<
"')" <<
endmsg;
523 const ToolGetter getter;
527 template <
class R,
class C>
528 R find(
const C&
l )
const 530 for (
auto& i : l ) {
531 auto result = getter( i );
532 if ( isGood( result ) )
return result;
540 : getter(
std::move( _path ) ), nodes( _nodes ), algs( _algs )
544 inline std::string node()
const {
return find<std::string>( nodes ); }
573 verbose() <<
"Incident: [" << incident.
type() <<
"] " 574 <<
" = " << incident.
source() <<
" Location:" << inc->tag() <<
endmsg;
603 if ( isGood( node ) ) {
613 if ( isGood( alg ) ) {
647 error() <<
"Failed to get dictionary for class '" << n.
name <<
"' for location:" << tag <<
endmsg;
651 object.reset( reinterpret_cast<DataObject*>( n.
clazz->New() ) );
654 error() <<
"Failed to create an object of type:" << n.
clazz->GetName() <<
" for location:" << tag <<
endmsg;
661 error() <<
"Failed to register an object of type:" << n.
name <<
" at location:" << tag <<
endmsg;
682 error() <<
"Failed to configure handler for: " << l.
name <<
"[" << l.
type <<
"] " << tag <<
endmsg;
697 error() <<
"Failed to execute the algorithm:" << l.
algorithm->name() <<
" for location:" << tag <<
endmsg;
718 for (
auto& alg :
m_algs ) {
719 auto check = _m.
find( alg.first );
720 if ( _m.
end() != check ) {
721 warning() <<
" The data item is activated for '" << check->first <<
"' as '" << check->second.first <<
"'" 724 const Leaf&
l = alg.second;
727 if ( !mode && 0 == l.
num ) {
738 _m[no_prefix( alg.first,
m_prefix )] = {nam, val};
741 for (
const auto& node :
m_nodes ) {
742 auto check = _m.
find( node.first );
743 if ( _m.
end() != check ) {
744 warning() <<
" The data item is already activated for '" << check->first <<
"' as '" << check->second.first <<
"'" 747 const Node&
n = node.second;
752 if ( !mode && 0 == n.
num ) {
757 val = ( 0 == n.
clazz ) ?
"F" :
"T";
762 _m[no_prefix( node.first,
m_prefix )] = {nam, val};
773 for (
const auto& i : _m ) {
774 n1 =
std::max( n1, i.first.size() );
775 n2 =
std::max( n2, i.second.first.size() );
776 n3 =
std::max( n3, i.second.second.size() );
792 const std::string _f =
" | %%1$-%1%.%1%s | %%2$-%2%.%2%s | %%3$%3%.%3%s |";
801 msg <<
"Data-On-Demand Actions enabled for:";
803 msg <<
"Data-On-Demand Actions has been used for:";
807 fmt1 %
"Address" %
"Creator" % ( mode ?
"S" :
"#" );
813 msg <<
'\n' << line <<
'\n' << header <<
'\n' <<
line;
816 for (
const auto& item : _m ) {
818 msg <<
'\n' << ( fmt % item.first % item.second.first % item.second.second );
void i_setNodeHandler(const std::string &name, const std::string &type)
Internal method to initialize a node handler.
Parse attribute strings allowing iteration over the various attributes.
virtual SmartIF< IAlgorithm > & algorithm(const Gaudi::Utils::TypeNameString &typeName, const bool createIf=true)=0
Returns a smart pointer to a service.
constexpr static const auto FAILURE
StatusCode initialize() override
MsgStream & msg() const
shortcut for the method msgStream(MSG::INFO)
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
GAUDI_API std::string format(const char *,...)
MsgStream format utility "a la sprintf(...)".
const std::string & name() const override
Retrieve name of the service.
const std::string & type() const
Access to the incident type.
The DataOnDemandSvc listens to incidents typically triggered by the data service of the configurable ...
StatusCode finalize() override
virtual StatusCode sysStart()=0
Startup method invoked by the framework.
ChronoEntity m_timer_algs
MsgStream & info() const
shortcut for the method msgStream(MSG::INFO)
const std::string & source() const
Access to the source of the incident.
virtual bool isInitialized() const =0
check if the algorithm is initialized properly
SmartIF< IIncidentSvc > m_incSvc
Incident service.
void handle(const Incident &incident) override
IIncidentListener interfaces overrides: incident handling.
MsgStream & verbose() const
shortcut for the method msgStream(MSG::VERBOSE)
virtual StatusCode createAlgorithm(const std::string &algtype, const std::string &algname, IAlgorithm *&alg, bool managed=false, bool checkIfExists=true)=0
Create an instance of a algorithm type that has been declared beforehand and assigns to it a name...
Gaudi::Property< std::string > m_trapType
Gaudi::Property< Map > m_nodeMap
Gaudi::Property< bool > m_init
A small utility class for chronometry of user codes.
StatusCode initialize() override
Inherited Service overrides: Service initialization.
The helper class to represent the efficient "key" for access.
virtual StatusCode sysInitialize()=0
Initialization method invoked by the framework.
constexpr auto size(const C &c) noexcept(noexcept(c.size())) -> decltype(c.size())
#define DECLARE_COMPONENT(type)
SmartIF< IDataProviderSvc > m_dataSvc
Data provider reference.
Gaudi::Property< Setup > m_algMapping
StatusCode service(const Gaudi::Utils::TypeNameString &name, T *&svc, bool createIf=true)
Templated method to access a service by name.
Gaudi::Property< std::vector< std::string > > m_algMapTools
ClassH clazz
the actual class
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
Interface of tools used by the DataOnDemandSvc to choose the type of node to be created at a path...
Gaudi::Property< std::string > m_prefix
Gaudi::Property< std::vector< std::string > > m_nodeMapTools
Helper class to parse a string of format "type/name".
Gaudi::Property< Map > m_algMap
StatusCode setup()
Setup routine (called by (re-) initialize.
MsgStream & warning() const
shortcut for the method msgStream(MSG::WARNING)
StatusCode execHandler(const std::string &tag, Leaf &leaf)
Execute leaf handler (algorithm)
This class is used for returning status codes from appropriate routines.
StatusCode setupNodeHandlers()
Initialize node handlers.
iterator find(const key_type &key)
Helper class of the DataOnDemandSvc.
virtual Gaudi::Utils::TypeNameString algorithmForPath(const std::string &path)=0
For the given path, returns a TypeNameString object identifying the algorithm to be run to produce th...
virtual StatusCode sysExecute(const EventContext &)=0
System execution. This method invokes the execute() method of a concrete algorithm.
GAUDI_API const EventContext & currentContext()
NodeMap m_nodes
Map of "empty" objects to be placed as intermediate nodes.
PropertyBase base class allowing PropertyBase* collections to be "homogeneous".
StatusCode reinitialize() override
void dump(const MSG::Level level, const bool mode=true) const
dump the content of DataOnDemand service
constexpr static const auto SUCCESS
Gaudi::Property< bool > m_partialPath
std::vector< IDODNodeMapper * > m_nodeMappers
std::string outputUserTime() const
print the chrono ;
Interface of tools used by the DataOnDemandSvc to choose the algorithm to be run to produce the data ...
SmartIF< IAlgManager > m_algMgr
Algorithm manager.
SmartIF< IToolSvc > m_toolSvc
Data provider reference.
Helper object, useful for measurement of CPU-performance of highly-recursive structures, e.g.
virtual Out operator()(const vector_of_const_< In > &inputs) const =0
AlgMap m_algs
Map of algorithms to handle incidents.
virtual StatusCode registerObject(boost::string_ref fullPath, DataObject *pObject)=0
Register object with the data store.
Gaudi::Property< Setup > m_nodeMapping
const std::string & type() const
ChronoEntity m_timer_nodes
const StatusCode & ignore() const
Ignore/check StatusCode.
Gaudi::Property< std::string > m_dataSvcName
Base class for all Incidents (computing events).
virtual void addListener(IIncidentListener *lis, const std::string &type="", long priority=0, bool rethrow=false, bool singleShot=false)=0
Add listener.
bool dataObject
trivial object? DataObject?
DataOnDemandSvc(const std::string &name, ISvcLocator *svc)
Standard initializing service constructor.
StatusCode finalize() override
Inherited Service overrides: Service finalization.
MsgStream & msgStream() const
Return an uninitialized MsgStream.
Gaudi::StateMachine::State FSMState() const override
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.
void reset(TYPE *ptr=nullptr)
Set the internal pointer to the passed one disposing of the old one.
virtual void removeListener(IIncidentListener *lis, const std::string &type="")=0
Remove listener.
Data service incident class.
const std::string & name() const
implementation of various functions for streaming.
StatusCode setupAlgHandlers()
Initialize leaf handlers.
Helper class of the DataOnDemandSvc.
virtual std::string nodeTypeForPath(const std::string &path)=0
For the given path, returns a the type name of the object to be created at the path.
StatusCode i_setAlgHandler(const std::string &name, const Gaudi::Utils::TypeNameString &alg)
Internal method to initialize an algorithm handler.
Gaudi::Property< bool > m_dump
SmartIF< ISvcLocator > & serviceLocator() const override
Retrieve pointer to service locator.
StatusCode configureHandler(Leaf &leaf)
Configure handler for leaf.
void toupper(std::string &s)
Gaudi::Property< bool > m_allowInitFailure
std::vector< IDODAlgMapper * > m_algMappers
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
StatusCode reinitialize() override
Inherited Service overrides: Service reinitialization.
StatusCode update()
update the handlers
MSG::Level msgLevel() const
get the cached level (originally extracted from the embedded MsgStream)