35 #include "boost/algorithm/string/predicate.hpp" 36 #include "boost/format.hpp" 49 verbose() <<
"updated property " << p.name() <<
", forcig update" <<
endmsg;
52 m_algMap.declareUpdateHandler( force_update );
53 m_nodeMap.declareUpdateHandler( force_update );
59 m_algMapping.declareUpdateHandler( deprecated_property );
76 return boost::algorithm::starts_with( value, prefix ) ? value.
substr( prefix.
size() ) : value;
86 inline size_t add_prefix( MAP& _map,
const std::string& prefix )
89 if ( prefix.
empty() ) {
93 auto it =
std::find_if_not( _map.begin(), _map.end(), [&](
typename MAP::ValueType::const_reference i ) {
94 return boost::algorithm::starts_with( i.first, prefix );
96 if ( it == _map.end() )
return 0;
101 return 1 + add_prefix( _map, prefix );
113 std::string::size_type ifind =
object.rfind(
'/' );
115 if ( std::string::npos == ifind ) {
124 return 1 + get_dir( top, _set );
132 template <
class MAP,
class SET>
133 inline size_t get_dirs(
const MAP& _map,
SET& _set )
135 size_t size = _set.size();
136 for (
const auto& item : _map ) {
137 get_dir( item.first, _set );
139 return _set.size() - size;
148 warning() <<
"Failed to access dictionary class for " << name <<
" of type:" << type <<
endmsg;
183 error() <<
"Failed to setup old \"Nodes\"" <<
endmsg;
189 error() <<
"Failed to setup old \"Algorithms\"" <<
endmsg;
205 auto _e = dirs.
find(
"/Event" );
206 if ( dirs.
end() != _e ) {
210 for (
const auto& dir : dirs ) {
219 for (
const auto& alg :
m_algMap ) {
265 <<
"(Alg/Node/Total)." <<
endmsg;
299 warning() <<
"ToolSvc already finalized: cannot release tools. Check options." <<
endmsg;
320 m_nodeMappers.clear();
322 m_algMappers.clear();
350 error() <<
"Failed to retrieve the IAlgManager interface." <<
endmsg;
356 error() <<
"Failed to retrieve Incident service." <<
endmsg;
401 for (
auto attrib : Parser( node ) ) {
402 switch (::
toupper( attrib.tag[0] ) ) {
412 warning() <<
"The obsolete property 'Nodes' redefines the action for '" + tag +
"' to be '" + nam +
"'" <<
endmsg;
430 for (
auto attrib : Parser( alg ) ) {
431 switch (::
toupper( attrib.tag[0] ) ) {
442 warning() <<
"The obsolete property 'Algorithms' redefines the action for '" + tag +
"' to be '" + item.
type() +
443 "/" + item.
name() +
"'" 479 error() <<
"Failed to initialize algorithm " << l.
type <<
"('" << l.
name <<
"')" <<
endmsg;
522 const ToolGetter getter;
526 template <
class R,
class C>
527 R find(
const C&
l )
const 529 for (
auto& i : l ) {
530 auto result = getter( i );
531 if ( isGood( result ) )
return result;
539 : getter(
std::move( _path ) ), nodes( _nodes ), algs( _algs )
543 inline std::string node()
const {
return find<std::string>( nodes ); }
572 verbose() <<
"Incident: [" << incident.
type() <<
"] " 573 <<
" = " << incident.
source() <<
" Location:" << inc->tag() <<
endmsg;
602 if ( isGood( node ) ) {
612 if ( isGood( alg ) ) {
646 error() <<
"Failed to get dictionary for class '" << n.
name <<
"' for location:" << tag <<
endmsg;
650 object.reset( reinterpret_cast<DataObject*>( n.
clazz->New() ) );
653 error() <<
"Failed to create an object of type:" << n.
clazz->GetName() <<
" for location:" << tag <<
endmsg;
660 error() <<
"Failed to register an object of type:" << n.
name <<
" at location:" << tag <<
endmsg;
681 error() <<
"Failed to configure handler for: " << l.
name <<
"[" << l.
type <<
"] " << tag <<
endmsg;
696 error() <<
"Failed to execute the algorithm:" << l.
algorithm->name() <<
" for location:" << tag <<
endmsg;
717 for (
auto& alg :
m_algs ) {
718 auto check = _m.
find( alg.first );
719 if ( _m.
end() != check ) {
720 warning() <<
" The data item is activated for '" << check->first <<
"' as '" << check->second.first <<
"'" 723 const Leaf&
l = alg.second;
726 if ( !mode && 0 == l.
num ) {
737 _m[no_prefix( alg.first,
m_prefix )] = {nam, val};
740 for (
const auto& node :
m_nodes ) {
741 auto check = _m.
find( node.first );
742 if ( _m.
end() != check ) {
743 warning() <<
" The data item is already activated for '" << check->first <<
"' as '" << check->second.first <<
"'" 746 const Node&
n = node.second;
751 if ( !mode && 0 == n.
num ) {
756 val = ( 0 == n.
clazz ) ?
"F" :
"T";
761 _m[no_prefix( node.first,
m_prefix )] = {nam, val};
772 for (
const auto& i : _m ) {
773 n1 =
std::max( n1, i.first.size() );
774 n2 =
std::max( n2, i.second.first.size() );
775 n3 =
std::max( n3, i.second.second.size() );
791 const std::string _f =
" | %%1$-%1%.%1%s | %%2$-%2%.%2%s | %%3$%3%.%3%s |";
800 msg <<
"Data-On-Demand Actions enabled for:";
802 msg <<
"Data-On-Demand Actions has been used for:";
806 fmt1 %
"Address" %
"Creator" % ( mode ?
"S" :
"#" );
812 msg <<
'\n' << line <<
'\n' << header <<
'\n' <<
line;
815 for (
const auto& item : _m ) {
817 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.
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.
bool isSuccess() const
Test for a status code of SUCCESS.
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.
bool isFailure() const
Test for a status code of FAILURE.
The helper class to represent the efficient "key" for access.
virtual StatusCode sysInitialize()=0
Initialization method invoked by the framework.
virtual StatusCode sysExecute()=0
System execution. This method invokes the execute() method of a concrete algorithm.
#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...
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
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.
AlgMap m_algs
Map of algorithms to handle incidents.
Gaudi::Property< Setup > m_nodeMapping
const std::string & type() const
ChronoEntity m_timer_nodes
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.
virtual StatusCode registerObject(const std::string &fullPath, DataObject *pObject)=0
Register object with the data store.
MSG::Level msgLevel() const
get the output level from the embedded MsgStream
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