The Gaudi Framework  v30r4 (9b837755)
DataOnDemandSvc.cpp
Go to the documentation of this file.
1 // ============================================================================
2 // Include files
3 // ============================================================================
4 // STD & STL
5 // ============================================================================
6 #include <map>
7 #include <math.h>
8 #include <set>
9 #include <string>
10 // ============================================================================
11 // GaudiKernel
12 // ============================================================================
14 #include "GaudiKernel/Chrono.h"
16 #include "GaudiKernel/DataObject.h"
18 #include "GaudiKernel/IAlgorithm.h"
22 #include "GaudiKernel/IToolSvc.h"
24 #include "GaudiKernel/MsgStream.h"
25 #include "GaudiKernel/Property.h"
27 #include "GaudiKernel/ToStream.h"
29 // ============================================================================
30 // Local
31 // ============================================================================
32 #include "DataOnDemandSvc.h"
33 // ============================================================================
34 // Boost
35 // ============================================================================
36 #include "boost/algorithm/string/predicate.hpp"
37 #include "boost/format.hpp"
38 // ============================================================================
39 // anonymous namespace to hide few local functions
40 // ============================================================================
41 namespace
42 {
43  // ==========================================================================
49  inline std::string no_prefix( const std::string& value, const std::string& prefix )
50  {
51  return boost::algorithm::starts_with( value, prefix ) ? value.substr( prefix.size() ) : value;
52  }
53  // ==========================================================================
60  template <class MAP>
61  inline size_t add_prefix( MAP& _map, const std::string& prefix )
62  {
63  // empty prefix
64  if ( prefix.empty() ) {
65  return 0;
66  } // RETURN
68  auto it = std::find_if_not( _map.begin(), _map.end(), [&]( typename MAP::ValueType::const_reference i ) {
69  return boost::algorithm::starts_with( i.first, prefix );
70  } );
71  if ( it == _map.end() ) return 0;
72  std::string key = prefix + it->first;
73  std::string value = std::move( it->second ); // steal the value we're about to erase..
74  _map.erase( it );
75  _map[key] = std::move( value ); // and move it into its new location
76  return 1 + add_prefix( _map, prefix ); // RETURN, recursion
77  //
78  }
79  // ==========================================================================
85  template <class SET>
86  inline size_t get_dir( const std::string& object, SET& _set )
87  {
88  std::string::size_type ifind = object.rfind( '/' );
89  // stop recursion
90  if ( std::string::npos == ifind ) {
91  return 0;
92  } // RETURN
93  if ( 0 == ifind ) {
94  return 0;
95  }
96  //
97  const std::string top = std::string( object, 0, ifind );
98  _set.insert( top );
99  return 1 + get_dir( top, _set ); // RETURN, recursion
100  }
101  // ==========================================================================
107  template <class MAP, class SET>
108  inline size_t get_dirs( const MAP& _map, SET& _set )
109  {
110  size_t size = _set.size();
111  for ( const auto& item : _map ) {
112  get_dir( item.first, _set );
113  }
114  return _set.size() - size;
115  }
116  // ==========================================================================
117 } // end of anonymous namespace
118 
120 {
121  ClassH cl = TClass::GetClass( type.c_str() );
122  if ( !cl ) {
123  warning() << "Failed to access dictionary class for " << name << " of type:" << type << endmsg;
124  }
125  m_nodes[name] = Node( cl, false, type );
126 }
127 
129 {
130  Leaf leaf( alg.type(), alg.name() );
131  if ( m_init ) {
132  StatusCode sc = configureHandler( leaf );
133  if ( sc.isFailure() ) {
134  if ( m_allowInitFailure ) {
135  // re-store the content of the leaf object to try again to initialize
136  // the algorithm later (on demand)
137  leaf = Leaf( alg.type(), alg.name() );
138  } else
139  return sc;
140  }
141  }
142  m_algs[name] = leaf;
143  return StatusCode::SUCCESS;
144 }
145 
146 // ============================================================================
147 // update the content of Data-On-Demand actions
148 // ============================================================================
150 {
151  if ( !m_updateRequired ) {
152  return StatusCode::SUCCESS;
153  }
154 
156  StatusCode sc = setupNodeHandlers(); // convert "Nodes" new "NodeMap"
157  if ( sc.isFailure() ) {
158  error() << "Failed to setup old \"Nodes\"" << endmsg;
159  return sc;
160  }
162  sc = setupAlgHandlers(); // convert "Algorithms" into "AlgMap"
163  if ( sc.isFailure() ) {
164  error() << "Failed to setup old \"Algorithms\"" << endmsg;
165  return sc;
166  }
168  add_prefix( m_algMap, m_prefix );
170  add_prefix( m_nodeMap, m_prefix );
173  if ( m_partialPath ) {
174  get_dirs( m_algMap, dirs );
175  }
176  if ( m_partialPath ) {
177  get_dirs( m_nodeMap, dirs );
178  }
179  //
180  auto _e = dirs.find( "/Event" );
181  if ( dirs.end() != _e ) {
182  dirs.erase( _e );
183  }
184  // add all directories as nodes
185  for ( const auto& dir : dirs ) {
186  if ( m_algMap.end() == m_algMap.find( dir ) && m_nodeMap.end() == m_nodeMap.find( dir ) )
187  m_nodeMap[dir] = "DataObject";
188  }
189  //
190  m_algs.clear();
191  m_nodes.clear();
192  //
194  for ( const auto& alg : m_algMap ) {
195  if ( i_setAlgHandler( alg.first, alg.second ).isFailure() ) return StatusCode::FAILURE;
196  }
198  for ( const auto& node : m_nodeMap ) {
199  i_setNodeHandler( node.first, node.second );
200  }
202  m_updateRequired = false;
203  //
204  return StatusCode::SUCCESS;
205 }
206 //=============================================================================
207 // Inherited Service overrides:
208 //=============================================================================
210 {
211  // initialize the Service Base class
213  if ( sc.isFailure() ) {
214  return sc;
215  }
216  sc = setup();
217  if ( sc.isFailure() ) {
218  return sc;
219  }
220  //
221  if ( m_dump ) {
222  dump( MSG::INFO );
223  } else if ( msgLevel( MSG::DEBUG ) ) {
224  dump( MSG::DEBUG );
225  }
226  //
227  if ( m_init ) {
228  return update();
229  }
230  //
231  return StatusCode::SUCCESS;
232 }
233 // ============================================================================
234 // finalization of the service
235 // ============================================================================
237 {
238  //
239  info() << "Handled \"" << m_trapType.value() << "\" incidents: " << m_statAlg << "/" << m_statNode << "/" << m_stat
240  << "(Alg/Node/Total)." << endmsg;
241  if ( m_dump || msgLevel( MSG::DEBUG ) ) {
242  info() << m_total.outputUserTime( "Algorithm timing: Mean(+-rms)/Min/Max:%3%(+-%4%)/%6%/%7%[ms] ",
244  << m_total.outputUserTime( "Total:%2%[s]", System::Sec ) << endmsg;
245  info() << m_timer_nodes.outputUserTime( "Nodes timing: Mean(+-rms)/Min/Max:%3%(+-%4%)/%6%/%7%[ms] ",
247  << m_timer_nodes.outputUserTime( "Total:%2%[s]", System::Sec ) << endmsg;
248  info() << m_timer_algs.outputUserTime( "Algs timing: Mean(+-rms)/Min/Max:%3%(+-%4%)/%6%/%7%[ms] ",
250  << m_timer_algs.outputUserTime( "Total:%2%[s]", System::Sec ) << endmsg;
251  info() << m_timer_all.outputUserTime( "All timing: Mean(+-rms)/Min/Max:%3%(+-%4%)/%6%/%7%[ms] ",
253  << m_timer_all.outputUserTime( "Total:%2%[s]", System::Sec ) << endmsg;
254  }
255  // dump it!
256  if ( m_dump ) {
257  dump( MSG::INFO, false );
258  } else if ( msgLevel( MSG::DEBUG ) ) {
259  dump( MSG::DEBUG, false );
260  }
261  //
262  if ( m_incSvc ) {
264  m_incSvc.reset();
265  }
266  m_algMgr.reset();
267  m_dataSvc.reset();
268  if ( m_toolSvc ) { // we may not have retrieved the ToolSvc
269  // Do not call releaseTool if the ToolSvc was already finalized.
271  for ( const auto& i : m_nodeMappers ) m_toolSvc->releaseTool( i ).ignore();
272  for ( const auto& i : m_algMappers ) m_toolSvc->releaseTool( i ).ignore();
273  } else {
274  warning() << "ToolSvc already finalized: cannot release tools. Check options." << endmsg;
275  }
278  m_toolSvc.reset();
279  }
280  return Service::finalize();
281 }
282 // ============================================================================
284 // ============================================================================
286 {
287  // reinitialize the Service Base class
288  if ( m_incSvc ) {
290  m_incSvc.reset();
291  }
292  m_algMgr.reset();
293  m_dataSvc.reset();
294  for ( const auto& i : m_nodeMappers ) m_toolSvc->releaseTool( i ).ignore();
295  m_nodeMappers.clear();
296  for ( const auto& i : m_algMappers ) m_toolSvc->releaseTool( i ).ignore();
297  m_algMappers.clear();
298  m_toolSvc.reset();
299  //
301  if ( sc.isFailure() ) {
302  return sc;
303  }
304  //
305  sc = setup();
306  if ( sc.isFailure() ) {
307  return sc;
308  }
309  //
310  if ( m_dump ) {
311  dump( MSG::INFO );
312  } else if ( msgLevel( MSG::DEBUG ) ) {
313  dump( MSG::DEBUG );
314  }
315  //
316  return StatusCode::SUCCESS;
317 }
318 // ============================================================================
319 // setup service
320 // ============================================================================
322 {
323  if ( !( m_algMgr = serviceLocator() ) ) // assignment meant
324  {
325  error() << "Failed to retrieve the IAlgManager interface." << endmsg;
326  return StatusCode::FAILURE;
327  }
328 
329  if ( !( m_incSvc = serviceLocator()->service( "IncidentSvc" ) ) ) // assignment meant
330  {
331  error() << "Failed to retrieve Incident service." << endmsg;
332  return StatusCode::FAILURE;
333  }
334  m_incSvc->addListener( this, m_trapType );
335 
336  if ( !( m_dataSvc = serviceLocator()->service( m_dataSvcName ) ) ) // assignment meant
337  {
338  error() << "Failed to retrieve the data provider interface of " << m_dataSvcName << endmsg;
339  return StatusCode::FAILURE;
340  }
341 
342  // No need to get the ToolSvc if we are not using tools
343  if ( !( m_nodeMapTools.empty() && m_algMapTools.empty() ) ) {
344  if ( !( m_toolSvc = serviceLocator()->service( "ToolSvc" ) ) ) // assignment meant
345  {
346  error() << "Failed to retrieve ToolSvc" << endmsg;
347  return StatusCode::FAILURE;
348  }
349 
350  // load the node mapping tools
351  IDODNodeMapper* nodetool = nullptr;
352  for ( const auto& i : m_nodeMapTools ) {
353  const StatusCode sc = m_toolSvc->retrieveTool( i, nodetool );
354  if ( sc.isFailure() ) return sc;
355  m_nodeMappers.push_back( nodetool );
356  }
357  IDODAlgMapper* algtool = nullptr;
358  for ( const auto& i : m_algMapTools ) {
359  const StatusCode sc = m_toolSvc->retrieveTool( i, algtool );
360  if ( sc.isFailure() ) return sc;
361  m_algMappers.push_back( algtool );
362  }
363  }
364  return update();
365 }
366 // ============================================================================
367 // setup node handlers
368 // ============================================================================
370 {
371  std::string nam, typ, tag;
373  // Setup for node leafs, where simply a constructor is called...
374  for ( auto node : m_nodeMapping ) {
375  using Parser = Gaudi::Utils::AttribStringParser;
376  for ( auto attrib : Parser( node ) ) {
377  switch (::toupper( attrib.tag[0] ) ) {
378  case 'D':
379  tag = std::move( attrib.value );
380  break;
381  case 'T':
382  nam = std::move( attrib.value );
383  break;
384  }
385  }
386  if ( m_algMap.end() != m_algMap.find( tag ) || m_nodeMap.end() != m_nodeMap.find( tag ) ) {
387  warning() << "The obsolete property 'Nodes' redefines the action for '" + tag + "' to be '" + nam + "'" << endmsg;
388  }
389  m_nodeMap[tag] = nam;
390  }
391  //
392  m_updateRequired = true;
393  //
394  return sc;
395 }
396 // ============================================================================
397 // setup algorithm handlers
398 // ============================================================================
400 {
401  std::string typ, tag;
402 
403  for ( auto alg : m_algMapping ) {
404  using Parser = Gaudi::Utils::AttribStringParser;
405  for ( auto attrib : Parser( alg ) ) {
406  switch (::toupper( attrib.tag[0] ) ) {
407  case 'D':
408  tag = std::move( attrib.value );
409  break;
410  case 'T':
411  typ = std::move( attrib.value );
412  break;
413  }
414  }
415  Gaudi::Utils::TypeNameString item( typ );
416  if ( m_algMap.end() != m_algMap.find( tag ) || m_nodeMap.end() != m_nodeMap.find( tag ) ) {
417  warning() << "The obsolete property 'Algorithms' redefines the action for '" + tag + "' to be '" + item.type() +
418  "/" + item.name() + "'"
419  << endmsg;
420  }
421  m_algMap[tag] = item.type() + "/" + item.name();
422  }
423  m_updateRequired = true;
424  return StatusCode::SUCCESS;
425 }
426 // ============================================================================
428 // ============================================================================
430 {
431  if ( l.algorithm ) {
432  return StatusCode::SUCCESS;
433  }
434  if ( !m_algMgr ) {
435  return StatusCode::FAILURE;
436  }
437  l.algorithm = m_algMgr->algorithm( l.name, false );
438  if ( l.algorithm ) {
439  return StatusCode::SUCCESS;
440  }
441  // create it!
442  StatusCode sc = m_algMgr->createAlgorithm( l.type, l.name, l.algorithm, true );
443  if ( sc.isFailure() ) {
444  error() << "Failed to create algorithm " << l.type << "('" << l.name << "')" << endmsg;
445  l.algorithm = nullptr;
446  return sc; // RETURN
447  }
448  if ( l.algorithm->isInitialized() ) {
449  return StatusCode::SUCCESS;
450  }
451  // initialize it!
452  sc = l.algorithm->sysInitialize();
453  if ( sc.isFailure() ) {
454  error() << "Failed to initialize algorithm " << l.type << "('" << l.name << "')" << endmsg;
455  l.algorithm = nullptr;
456  return sc; // RETURN
457  }
458  if ( Gaudi::StateMachine::RUNNING == l.algorithm->FSMState() ) {
459  return StatusCode::SUCCESS;
460  }
461  // run it!
462  sc = l.algorithm->sysStart();
463  if ( sc.isFailure() ) {
464  error() << "Failed to 'run' algorithm " << l.type << "('" << l.name << "')" << endmsg;
465  l.algorithm = nullptr;
466  return sc; // RETURN
467  }
468  return StatusCode::SUCCESS;
469 }
470 
471 // local algorithms
472 namespace
473 {
476  struct ToolGetter {
480  ToolGetter( std::string _path ) : path( std::move( _path ) ) {}
482  inline std::string operator()( IDODNodeMapper* t ) const { return t->nodeTypeForPath( path ); }
484  inline Gaudi::Utils::TypeNameString operator()( IDODAlgMapper* t ) const { return t->algorithmForPath( path ); }
485  };
486 
489  inline bool isGood( const std::string& r ) { return !r.empty(); }
490  inline bool isGood( const Gaudi::Utils::TypeNameString& r ) { return !r.name().empty(); }
492 
495  class Finder
496  {
497  const ToolGetter getter;
498  const std::vector<IDODNodeMapper*>& nodes;
499  const std::vector<IDODAlgMapper*>& algs;
501  template <class R, class C>
502  R find( const C& l ) const
503  {
504  for ( auto& i : l ) {
505  auto result = getter( i );
506  if ( isGood( result ) ) return result;
507  }
508  return R{""};
509  }
510 
511  public:
513  Finder( std::string _path, const std::vector<IDODNodeMapper*>& _nodes, const std::vector<IDODAlgMapper*>& _algs )
514  : getter( std::move( _path ) ), nodes( _nodes ), algs( _algs )
515  {
516  }
518  inline std::string node() const { return find<std::string>( nodes ); }
520  inline Gaudi::Utils::TypeNameString alg() const { return find<Gaudi::Utils::TypeNameString>( algs ); }
521  };
522 }
523 
524 // ===========================================================================
525 // IIncidentListener interfaces overrides: incident handling
526 // ===========================================================================
527 void DataOnDemandSvc::handle( const Incident& incident )
528 {
529 
531 
532  ++m_stat;
533  // proper incident type?
534  if ( incident.type() != m_trapType ) {
535  return;
536  } // RETURN
537  const DataIncident* inc = dynamic_cast<const DataIncident*>( &incident );
538  if ( !inc ) {
539  return;
540  } // RETURN
541  // update if needed!
542  if ( m_updateRequired ) {
543  update();
544  }
545 
546  if ( msgLevel( MSG::VERBOSE ) ) {
547  verbose() << "Incident: [" << incident.type() << "] "
548  << " = " << incident.source() << " Location:" << inc->tag() << endmsg;
549  }
550  // ==========================================================================
551  Gaudi::StringKey tag( inc->tag() );
552  // ==========================================================================
553  auto icl = m_nodes.find( tag );
554  if ( icl != m_nodes.end() ) {
555  StatusCode sc = execHandler( tag, icl->second );
556  if ( sc.isSuccess() ) {
557  ++m_statNode;
558  }
559  return; // RETURN
560  }
561  // ==========================================================================
562  auto ialg = m_algs.find( tag );
563  if ( ialg != m_algs.end() ) {
564  StatusCode sc = execHandler( tag, ialg->second );
565  if ( sc.isSuccess() ) {
566  ++m_statAlg;
567  }
568  return; // RETURN
569  }
570  // ==========================================================================
571  // Fall back on the tools
572  if ( m_toolSvc ) {
573  if ( msgLevel( MSG::VERBOSE ) ) verbose() << "Try to find mapping with mapping tools" << endmsg;
574  Finder finder( no_prefix( inc->tag(), m_prefix ), m_nodeMappers, m_algMappers );
575  // - try the node mappers
576  std::string node = finder.node();
577  if ( isGood( node ) ) {
578  // if one is found update the internal node mapping and try again.
579  if ( msgLevel( MSG::VERBOSE ) ) verbose() << "Found Node handler: " << node << endmsg;
580  i_setNodeHandler( inc->tag(), node );
581  handle( incident );
582  --m_stat; // avoid double counting because of recursion
583  return;
584  }
585  // - try alg mappings
586  Gaudi::Utils::TypeNameString alg = finder.alg();
587  if ( isGood( alg ) ) {
588  // we got an algorithm, update alg map and try to handle again
589  if ( msgLevel( MSG::VERBOSE ) ) verbose() << "Found Algorithm handler: " << alg << endmsg;
590  i_setAlgHandler( inc->tag(), alg ).ignore();
591  handle( incident );
592  --m_stat; // avoid double counting because of recursion
593  return;
594  }
595  }
596 }
597 // ===========================================================================
598 // execute the handler
599 // ===========================================================================
601 {
602 
604 
605  if ( n.executing ) {
606  return StatusCode::FAILURE;
607  } // RETURN
608 
609  Protection p( n.executing );
610 
612 
613  if ( n.dataObject ) {
614  object.reset( new DataObject() );
615  } else {
616  // try to recover the handler
617  if ( !n.clazz ) {
618  n.clazz = TClass::GetClass( n.name.c_str() );
619  }
620  if ( !n.clazz ) {
621  error() << "Failed to get dictionary for class '" << n.name << "' for location:" << tag << endmsg;
622  return StatusCode::FAILURE; // RETURN
623  }
624 
625  object.reset( reinterpret_cast<DataObject*>( n.clazz->New() ) );
626 
627  if ( !object ) {
628  error() << "Failed to create an object of type:" << n.clazz->GetName() << " for location:" << tag << endmsg;
629  return StatusCode::FAILURE; // RETURN
630  }
631  }
632  //
633  StatusCode sc = m_dataSvc->registerObject( tag, object.release() );
634  if ( sc.isFailure() ) {
635  error() << "Failed to register an object of type:" << n.name << " at location:" << tag << endmsg;
636  return sc; // RETURN
637  }
638  ++n.num;
639  //
640  return StatusCode::SUCCESS;
641 }
642 // ===========================================================================
643 // execute the handler
644 // ===========================================================================
646 {
648  //
649  if ( l.executing ) {
650  return StatusCode::FAILURE;
651  } // RETURN
652  //
653  if ( !l.algorithm ) {
654  StatusCode sc = configureHandler( l );
655  if ( sc.isFailure() ) {
656  error() << "Failed to configure handler for: " << l.name << "[" << l.type << "] " << tag << endmsg;
657  return sc; // RETURN
658  }
659  }
660  //
661  Chrono atimer( m_total );
662  //
663  Protection p( l.executing );
664  // FIXME: this will cause problems for Hive, as we need to set
665  // the EventContext of the called Algorithm.
666  // if (!l.algorithm->getContext()) {
667  // l.algorithm->setContext( &Gaudi::Hive::currentContext() );
668  // }
670  if ( sc.isFailure() ) {
671  error() << "Failed to execute the algorithm:" << l.algorithm->name() << " for location:" << tag << endmsg;
672  return sc; // RETURN
673  }
674  ++l.num;
675  //
676  return StatusCode::SUCCESS;
677 }
678 // ============================================================================
679 /* dump the content of DataOnDemand service
680  * @param level the printout level
681  * @param mode the printout mode
682  */
683 // ============================================================================
684 void DataOnDemandSvc::dump( const MSG::Level level, const bool mode ) const
685 {
686  if ( m_algs.empty() && m_nodes.empty() ) {
687  return;
688  }
689 
692  for ( auto& alg : m_algs ) {
693  auto check = _m.find( alg.first );
694  if ( _m.end() != check ) {
695  warning() << " The data item is activated for '" << check->first << "' as '" << check->second.first << "'"
696  << endmsg;
697  }
698  const Leaf& l = alg.second;
699  std::string nam = ( l.name == l.type ? l.type : ( l.type + "/" + l.name ) );
700  //
701  if ( !mode && 0 == l.num ) {
702  continue;
703  }
704  //
705  std::string val;
706  if ( mode ) {
707  val = ( !l.algorithm ) ? "F" : "T";
708  } else {
709  val = std::to_string( l.num );
710  }
711  //
712  _m[no_prefix( alg.first, m_prefix )] = {nam, val};
713  }
714  // nodes:
715  for ( const auto& node : m_nodes ) {
716  auto check = _m.find( node.first );
717  if ( _m.end() != check ) {
718  warning() << " The data item is already activated for '" << check->first << "' as '" << check->second.first << "'"
719  << endmsg;
720  }
721  const Node& n = node.second;
722  std::string nam = "'" + n.name + "'";
723  //
724  std::string val;
725 
726  if ( !mode && 0 == n.num ) {
727  continue;
728  }
729 
730  if ( mode ) {
731  val = ( 0 == n.clazz ) ? "F" : "T";
732  } else {
733  val = std::to_string( n.num );
734  }
735  //
736  _m[no_prefix( node.first, m_prefix )] = {nam, val};
737  }
738  //
739  if ( _m.empty() ) {
740  return;
741  }
742 
743  // find the correct formats
744  size_t n1 = 0;
745  size_t n2 = 0;
746  size_t n3 = 0;
747  for ( const auto& i : _m ) {
748  n1 = std::max( n1, i.first.size() );
749  n2 = std::max( n2, i.second.first.size() );
750  n3 = std::max( n3, i.second.second.size() );
751  }
752  if ( 10 > n1 ) {
753  n1 = 10;
754  }
755  if ( 10 > n2 ) {
756  n2 = 10;
757  }
758  if ( 60 < n1 ) {
759  n1 = 60;
760  }
761  if ( 60 < n2 ) {
762  n2 = 60;
763  }
764  //
765 
766  const std::string _f = " | %%1$-%1%.%1%s | %%2$-%2%.%2%s | %%3$%3%.%3%s |";
767  boost::format _ff( _f );
768  _ff % n1 % n2 % n3;
769 
770  const std::string _format = _ff.str();
771 
772  auto& msg = msgStream( level );
773 
774  if ( mode ) {
775  msg << "Data-On-Demand Actions enabled for:";
776  } else {
777  msg << "Data-On-Demand Actions has been used for:";
778  }
779 
780  boost::format fmt1( _format );
781  fmt1 % "Address" % "Creator" % ( mode ? "S" : "#" );
782  //
783  const std::string header = fmt1.str();
784  std::string line = std::string( header.size(), '-' );
785  line[0] = ' ';
786 
787  msg << '\n' << line << '\n' << header << '\n' << line;
788 
789  // make the actual printout:
790  for ( const auto& item : _m ) {
791  boost::format fmt( _format );
792  msg << '\n' << ( fmt % item.first % item.second.first % item.second.second );
793  }
794 
795  msg << '\n' << line << endmsg;
796 }
797 // ============================================================================
802 // ============================================================================
803 
804 // ============================================================================
805 // The END
806 // ============================================================================
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
Definition: StatusCode.h:88
ChronoEntity m_timer_all
StatusCode initialize() override
Definition: Service.cpp:63
MsgStream & msg() const
shortcut for the method msgStream(MSG::INFO)
T empty(T...args)
GAUDI_API std::string format(const char *,...)
MsgStream format utility "a la sprintf(...)".
Definition: MsgStream.cpp:120
const std::string & name() const override
Retrieve name of the service.
Definition: Service.cpp:288
const std::string & type() const
Access to the incident type.
Definition: Incident.h:41
The DataOnDemandSvc listens to incidents typically triggered by the data service of the configurable ...
StatusCode finalize() override
Definition: Service.cpp:173
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.
Definition: Incident.h:47
bool isSuccess() const
Definition: StatusCode.h:287
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.
T to_string(T...args)
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
T end(T...args)
Gaudi::Property< bool > m_init
A small utility class for chronometry of user codes.
Definition: Chrono.h:25
StatusCode initialize() override
Inherited Service overrides: Service initialization.
STL class.
bool isFailure() const
Definition: StatusCode.h:139
GAUDI_API std::string header(const int ID=Default)
get the recommended header by enum
StatusCode retrieveTool(const std::string &type, T *&tool, const IInterface *parent=nullptr, bool createIf=true)
Retrieve specified tool sub-type with tool dependent part of the name automatically assigned...
Definition: IToolSvc.h:139
The helper class to represent the efficient "key" for access.
Definition: StringKey.h:35
virtual StatusCode sysInitialize()=0
Initialization method invoked by the framework.
constexpr auto size(const C &c) noexcept(noexcept(c.size())) -> decltype(c.size())
STL class.
#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.
Definition: ISvcLocator.h:79
Gaudi::Property< std::vector< std::string > > m_algMapTools
ClassH clazz
the actual class
T push_back(T...args)
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
unsigned long long m_stat
Gaudi::Property< std::vector< std::string > > m_nodeMapTools
iterator end()
Definition: Map.h:134
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.
Definition: StatusCode.h:51
bool empty() const
Definition: Map.h:201
StatusCode setupNodeHandlers()
Initialize node handlers.
T erase(T...args)
iterator find(const key_type &key)
Definition: Map.h:151
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.
string prefix
Definition: gaudirun.py:268
StatusCode reinitialize() override
Definition: Service.cpp:249
void dump(const MSG::Level level, const bool mode=true) const
dump the content of DataOnDemand service
T clear(T...args)
T max(T...args)
T move(T...args)
constexpr static const auto SUCCESS
Definition: StatusCode.h:87
dictionary l
Definition: gaudirun.py:453
Gaudi::Property< bool > m_partialPath
std::vector< IDODNodeMapper * > m_nodeMappers
std::string outputUserTime() const
print the chrono ;
T find_if_not(T...args)
T size(T...args)
StatusCode registerObject(boost::string_ref fullPath, DataObject *pObject)
Register object with the data store.
Interface of tools used by the DataOnDemandSvc to choose the algorithm to be run to produce the data ...
Definition: IDODAlgMapper.h:17
SmartIF< IAlgManager > m_algMgr
Algorithm manager.
STL class.
SmartIF< IToolSvc > m_toolSvc
Data provider reference.
Helper object, useful for measurement of CPU-performance of highly-recursive structures, e.g.
Definition: LockedChrono.h:52
virtual Out operator()(const vector_of_const_< In > &inputs) const =0
AlgMap m_algs
Map of algorithms to handle incidents.
Gaudi::Property< Setup > m_nodeMapping
const std::string & type() const
ChronoEntity m_timer_nodes
const StatusCode & ignore() const
Ignore/check StatusCode.
Definition: StatusCode.h:165
Gaudi::Property< std::string > m_dataSvcName
T c_str(T...args)
Base class for all Incidents (computing events).
Definition: Incident.h:17
#define SET(x)
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?
StatusCode finalize() override
Inherited Service overrides: Service finalization.
MsgStream & msgStream() const
Return an uninitialized MsgStream.
Gaudi::StateMachine::State FSMState() const override
Definition: Service.h:53
T substr(T...args)
void clear()
Definition: Map.h:195
StatusCode service(const std::string &name, const T *&psvc, bool createIf=true) const
Access a service by name, creating it if it doesn&#39;t already exist.
Definition: Service.h:84
virtual StatusCode releaseTool(IAlgTool *tool)=0
Release the tool.
ChronoEntity m_total
void reset(TYPE *ptr=nullptr)
Set the internal pointer to the passed one disposing of the old one.
Definition: SmartIF.h:92
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.
Definition: Service.cpp:291
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.
Definition: MsgStream.h:209
unsigned long long m_statNode
unsigned long long m_statAlg
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)