| # Gaudi Framework, version v25r0 |

Home |  | Generated: Mon Feb 17 2014

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
GaudiCommon.icpp
Go to the documentation of this file.
1 // ============================================================================
2 // include files
3 // ============================================================================
4 // STL & STD
5 // ============================================================================
6 #include <algorithm>
7 #include <cstdlib>
8 // ============================================================================
9 /* @file GaudiCommon.cpp
10 *
11 * Implementation file for class : GaudiCommon
12 *
13 * @author Chris Jones Christopher.Rob.Jones@cern.ch
14 * @author Vanya BELYAEV Ivan.Belyaev@itep.ru
15 * @author Rob Lambert Rob.Lambert@cern.ch
16 * @date 2009-08-04
17 */
18 // GaudiKernel
19 // ============================================================================
20 #include "GaudiKernel/IDataProviderSvc.h"
21 #include "GaudiKernel/IToolSvc.h"
22 #include "GaudiKernel/IProperty.h"
23 #include "GaudiKernel/Property.h"
24 #include "GaudiKernel/ISvcLocator.h"
25 #include "GaudiKernel/MsgStream.h"
26 #include "GaudiKernel/ObjectVector.h"
27 #include "GaudiKernel/SmartDataPtr.h"
28 #include "GaudiKernel/SmartRef.h"
29 #include "GaudiKernel/Stat.h"
30 #include "GaudiKernel/System.h"
31 #include "GaudiKernel/IJobOptionsSvc.h"
32 #include "GaudiKernel/StatEntity.h"
33 #include "GaudiKernel/Algorithm.h"
34 #include "GaudiKernel/AlgTool.h"
35 // ============================================================================
36 // GaudiAlg
37 // ============================================================================
38 #include "GaudiAlg/Print.h"
39 #include "GaudiAlg/GaudiCommon.h"
40 #include "GaudiAlg/GaudiAlgorithm.h"
41 #include "GaudiAlg/GaudiTool.h"
42 // ============================================================================
43 // GaudiUtils
44 // ============================================================================
45 #include "GaudiUtils/RegEx.h"
46 // ============================================================================
47 // Boost
48 // ============================================================================
49 #include "boost/format.hpp"
50 #include "boost/lexical_cast.hpp"
51 // ============================================================================
52 // Disable warning on windows
53 #ifdef _WIN32
54 #pragma warning ( disable:4661 ) // incomplete explicit templates
55 #endif
56 // ============================================================================
57
58 // ============================================================================
59 // constructor initialisation
60 // ============================================================================
61 template <class PBASE>
62 void
63 GaudiCommon<PBASE>::initGaudiCommonConstructor( const IInterface * parent )
64 {
65 // initialise data members
66 m_msgLevel = MSG::NIL;
67 m_msgStream = 0;
68 m_updMgrSvc = 0;
69 m_typePrint = true;
70 m_propsPrint = false;
71 m_statPrint = true;
72 m_errorsPrint = true;
73 m_context = "" ;
74 m_rootInTES = "" ;
75 m_globalTimeOffset = 0.0 ;
76 //data members for the CounterSummarySvc
77 m_counterSummarySvc=NULL;
78 m_counterList=std::vector<std::string>(1,".*");
79 m_statEntityList=std::vector<std::string>(0);
80
81 // printout of counters:
82
83 // the header row for counters printout
84 m_header = " | Counter | # | sum | mean/eff^* | rms/err^* | min | max |" ;
85 // format for regular statistical printout rows
86 m_format1 = " | %|-48.48s|%|50t||%|10d| |%|11.7g| |%|#11.5g| |%|#11.5g| |%|#12.5g| |%|#12.5g| |" ;
87 // format for "efficiency" statistical printout rows
88 m_format2 = " |*%|-48.48s|%|50t||%|10d| |%|11.5g| |(%|#9.6g| +- %|-#9.6g|)%%| ------- | ------- |" ;
89 // flag to use the special "efficiency" format
90 m_useEffFormat = true ;
91
92 // job options
93 // print error counters at finalization ?
94 this->declareProperty
95 ( "ErrorsPrint" , m_errorsPrint ,
96 "Print the statistics of errors/warnings/exceptions")
97 -> declareUpdateHandler
98 ( &GaudiCommon<PBASE>::printErrorHandler, this ) ;
99 // print properties at initialization?
100 this->declareProperty
101 ( "PropertiesPrint" , m_propsPrint ,
102 "Print the properties of the component ")
103 -> declareUpdateHandler
104 ( &GaudiCommon<PBASE>::printPropsHandler, this ) ;
105 // print statistical counters at finalization ?
106 this->declareProperty
107 ( "StatPrint" , m_statPrint ,
108 "Print the table of counters" )
109 -> declareUpdateHandler
110 ( &GaudiCommon<PBASE>::printStatHandler, this ) ;
111 // insert the actual C++ type of the algorithm or tool in the messages?
112 this->declareProperty
113 ( "TypePrint" , m_typePrint ,
114 "Add the actal C++ component type into the messages" ) ;
115 // context
116 this->declareProperty ( "Context" , m_context ) ;
117 // root in TES
118 this->declareProperty ( "RootInTES" , m_rootInTES ) ;
119 // root on TES ( temporary )
120 this->declareProperty ( "RootOnTES" , m_rootOnTES ) ;
121 // global time offset
122 this->declareProperty ( "GlobalTimeOffset", m_globalTimeOffset ) ;
123
124
125 // the header row for counters printout
126 this->declareProperty
127 ( "StatTableHeader" , m_header ,
128 "The header row for the output Stat-table" ) ;
129 // format for regular statistical printout rows
130 this->declareProperty
131 ( "RegularRowFormat" , m_format1 ,
132 "The format for the regular row in the output Stat-table" ) ;
133 // format for "efficiency" statistical printout rows
134 this->declareProperty
135 ( "EfficiencyRowFormat" , m_format2 ,
136 "The format for the regular row in the output Stat-table" ) ;
137 // flag to use the special "efficiency" format
138 this->declareProperty
139 ( "UseEfficiencyRowFormat" , m_useEffFormat ,
140 "Use the special format for printout of efficiency counters" ) ;
141
142
143 //declare the list of simple counters to write.
144 this->declareProperty(
145 "CounterList",
146 m_counterList=std::vector<std::string>(1,".*"),
147 "RegEx list, of simple integer counters for CounterSummary.");
148 //declare the list of stat entities to write.
149 this->declareProperty(
150 "StatEntityList",
151 m_statEntityList=std::vector<std::string>(0),
152 "RegEx list, of StatEntity counters for CounterSummary.");
153
154 // add handler for message level changes
155 this->outputLevelProperty().declareUpdateHandler( &GaudiCommon<PBASE>::msgLevelHandler, this );
156
157 // setup context from parent if available
158 if ( parent )
159 {
160 if ( const GaudiAlgorithm* gAlg = dynamic_cast<const GaudiAlgorithm*>(parent) )
161 {
162 m_context = gAlg->context();
163 m_rootInTES = gAlg->rootInTES();
164 m_globalTimeOffset = gAlg->globalTimeOffset();
165 }
166 else if ( const GaudiTool* gTool = dynamic_cast<const GaudiTool*> (parent) )
167 {
168 m_context = gTool->context();
169 m_rootInTES = gTool->rootInTES();
170 m_globalTimeOffset = gTool->globalTimeOffset();
171 }
172 }
173
174 // Get the job option service
175 SmartIF<IJobOptionsSvc> jos(PBASE::service("JobOptionsSvc"));
176 if (!jos.isValid()) Exception("Cannot get JobOptionsSvc");
177
178 // Get the "Context" option if in the file...
179 const std::vector<const Property*>* myList = jos->getProperties( this->name() );
180 if ( 0 != myList )
181 {
182 // Iterate over the list to set the options
183 for ( std::vector<const Property*>::const_iterator iter = myList->begin();
184 iter != myList->end();
185 ++iter )
186 {
187 const StringProperty* sp = dynamic_cast<const StringProperty*>(*iter);
188 if ( 0 != sp )
189 {
190 if ( "Context" == (*iter)->name() )
191 {
192 m_context = sp->value();
193 } else if ( "RootInTES" == (*iter)->name() ) {
194 m_rootInTES = sp->value();
195 } else if ( "GlobalTimeOffset" == (*iter)->name() ) {
196 m_globalTimeOffset = atof( sp->value().c_str() );
197 }
198 }
199 }
200 }
201
202 }
203 //=============================================================================
204
205 //=============================================================================
206 // Initialise the common functionality
207 //=============================================================================
208 template < class PBASE >
209 StatusCode GaudiCommon<PBASE>::
210 #ifdef __ICC
211 i_gcInitialize
212 #else
213 initialize
214 #endif
215 ()
216 {
217
218 // initialize base class
219 const StatusCode sc = PBASE::initialize();
220 if ( sc.isFailure() )
221 { return Error ( "Failed to initialise base class PBASE", sc ) ; }
222
223
224 // some debug printout
225 if ( msgLevel(MSG::DEBUG) )
226 {
227 debug() << "Initialize base class GaudiCommon<" << System::typeinfoName(typeid(PBASE)) << ">" << endmsg;
228 if ( !context().empty() )
229 debug() << "Created with context = '" << context() << "'" << endmsg;
230 }
231
232 // some temporary checks to see if people are using RootOnTES and warn if so
233 // TO BE REMOVED ASAP ...
234 if ( m_rootInTES.empty() && !m_rootOnTES.empty() )
235 {
236 m_rootInTES = m_rootOnTES;
237 Warning( "RootOnTES option is OBSOLETE -> Use RootInTES instead. RootInTES has been updated to "
238 + m_rootInTES, StatusCode::SUCCESS ).ignore();
239 }
240 else if ( !m_rootInTES.empty() && !m_rootOnTES.empty() )
241 {
242 Warning( "Options RootOnTES AND RootInTES are defined ! Use RootInTES. RootOnTES is ignored",
243 StatusCode::SUCCESS ).ignore();
244 }
245
246 // Check rootInTES ends with a /
247 if ( !m_rootInTES.empty() &&
248 m_rootInTES.substr(m_rootInTES.size()-1) != "/" ) m_rootInTES += "/";
249
250 //Set up the CounterSummarySvc May need to be changed
251 this->svcLoc()->service("CounterSummarySvc",m_counterSummarySvc,false).ignore() ;
252 if (msgLevel(MSG::DEBUG))
253 {
254 if (m_counterSummarySvc==NULL )
255 debug() << "could not locate CounterSummarySvc, no counter summary will be made" << endmsg;
256 else debug() << "found CounterSummarySvc OK" << endmsg;
257 }
258
259 // properties will be printed if asked for or in "MSG::DEBUG" mode
260 if ( propsPrint() ) { printProps(MSG::ALWAYS); }
261 else if ( msgLevel(MSG::DEBUG) ) { printProps(MSG::DEBUG); }
262
263 return sc;
264 }
265 //=============================================================================
266
267 //=============================================================================
268 // Finalize the common functionality
269 //=============================================================================
270 template < class PBASE >
271 StatusCode GaudiCommon<PBASE>::
272 #ifdef __ICC
273 i_gcFinalize
274 #else
275 finalize
276 #endif
277 ()
278 {
279 StatusCode sc = StatusCode::SUCCESS;
280
281 // print the general information about statistical counters
282 if ( msgLevel(MSG::DEBUG) || (statPrint() && !counters().empty()) )
283 {
284 // print general statistical counters
285 printStat ( statPrint() ? MSG::ALWAYS : MSG::DEBUG ) ;
286 }
287 //add all counters to the CounterSummarySvc
288 if(m_counterSummarySvc && this->svcLoc()->existsService("CounterSummarySvc"))
289 {
290 if ( msgLevel(MSG::DEBUG) ) debug() << "adding counters to CounterSummarySvc" << endmsg;
291 for(Statistics::const_iterator i=this->counters().begin();
292 i!=this->counters().end();
293 i++)
294 {
295 if(Gaudi::Utils::RegEx::matchOr(i->first,m_statEntityList))
296 m_counterSummarySvc->addCounter(this->name(),i->first,i->second,
297 Gaudi::CounterSummary::SaveStatEntity);
298 else if(Gaudi::Utils::RegEx::matchOr(i->first,m_counterList))
299 m_counterSummarySvc->addCounter(this->name(),i->first,i->second);
300 }
301 }
302 // release all located tools and services
303 if ( msgLevel(MSG::DEBUG) )
304 {
305 debug() << "Tools to release :";
306 for ( AlgTools::const_iterator i = m_tools.begin();
307 i != m_tools.end(); ++i )
308 {
309 debug() << " " << (*i)->name();
310 }
311 debug() << endmsg;
312 }
313 while ( !m_tools.empty() ) { sc = sc && releaseTool( m_tools.back() ) ; }
314
315 // release all located services
316 if ( msgLevel(MSG::DEBUG) )
317 {
318 debug() << "Services to release :";
319 for ( Services::const_iterator i = m_services.begin();
320 i != m_services.end(); ++i )
321 {
322 debug() << " " << (*i).first;
323 }
324 debug() << endmsg;
325 }
326 while ( !m_services.empty() ) { sc = sc && releaseSvc( m_services.begin()->second ) ; }
327
328 //release the CounterSummarySvc manually
329 if(m_counterSummarySvc)
330 {
331 m_counterSummarySvc->release();
332 m_counterSummarySvc=NULL;
333 }
334
335 // format printout
336 if ( !m_errors.empty() || !m_warnings.empty() || !m_exceptions.empty() )
337 {
338 always() << "Exceptions/Errors/Warnings/Infos Statistics : "
339 << m_exceptions .size () << "/"
340 << m_errors .size () << "/"
341 << m_warnings .size () << "/"
342 << m_infos .size () << endmsg ;
343 if ( errorsPrint() ) { printErrors () ; }
344 }
345
346 // delete the MsgStream
347 resetMsgStream();
348
349 // clear *ALL* counters explicitly
350 m_counters .clear() ;
351 m_exceptions .clear() ;
352 m_infos .clear() ;
353 m_warnings .clear() ;
354 m_errors .clear() ;
355 m_counterList.clear() ;
356 m_statEntityList.clear() ;
357
358 // finalize base class
359 return sc && PBASE::finalize();
360 }
361 //=============================================================================
362
363 //=============================================================================
364 // Methods related to tools and services
365 //=============================================================================
366
367 // ============================================================================
368 // manual forced (and 'safe') release of the active tool or service
369 // ============================================================================
370 template < class PBASE >
371 StatusCode GaudiCommon<PBASE>::release ( const IInterface* interface ) const
372 {
373 if ( 0 == interface )
374 { return Error ( "release(IInterface):: IInterface* points to NULL!" ) ; }
375 // dispatch between tools and services
376 const IAlgTool* algTool = dynamic_cast<const IAlgTool*>( interface ) ;
377 // perform the actual release
378 return 0 != algTool ? releaseTool( algTool ) : releaseSvc( interface ) ;
379 }
380 // ============================================================================
381
382 // ============================================================================
383 // manual forced (and 'save') release of the tool
384 // ============================================================================
385 template < class PBASE >
386 StatusCode GaudiCommon<PBASE>::releaseTool ( const IAlgTool* algTool ) const
387 {
388 if( 0 == algTool )
389 { return Error ( "releaseTool(IAlgTool):: IAlgTool* points to NULL!" ) ; }
390 if( this->toolSvc() == 0 )
391 { return Error ( "releaseTool(IAlgTool):: IToolSvc* points to NULL!" ) ; }
392 // find a tool in the list of active tools
393 AlgTools::reverse_iterator it =
394 std::find( m_tools.rbegin() , m_tools.rend() , algTool ) ;
395 if( m_tools.rend() == it )
396 { return Warning("releaseTool(IAlgTool):: IAlgTool* is not active" ) ; }
397 // get the tool
398 IAlgTool* t = *it ;
399 // cache name
400 const std::string name = t->name();
401 if ( msgLevel(MSG::DEBUG) )
402 { debug() << "Releasing tool '" << name << "'" << endmsg; }
403 // remove the tool from the lists
404 m_tools.erase( --it.base() ) ;
405 // release tool
406 if ( msgLevel(MSG::DEBUG) ) {
407 this->debug() << "The tool '" << t->name() << "' of type '"
408 << System::typeinfoName(typeid(*t))
409 << "' is released" << endmsg;
410 }
411 const StatusCode sc = this->toolSvc()->releaseTool( t ) ;
412 if ( sc.isFailure() )
413 { return Warning ( "releaseTool(IAlgTool):: error from IToolSvc whilst releasing "+name , sc ) ; }
414 // return final status code
415 return sc ;
416 }
417 // ============================================================================
418
419 // ============================================================================
420 // manual forced (and 'safe') release of the service
421 // ============================================================================
422 template < class PBASE >
423 StatusCode GaudiCommon<PBASE>::releaseSvc ( const IInterface* Svc ) const
424 {
425 if( 0 == Svc ) {
426 return Error ( "releaseSvc(IInterface):: IInterface* points to NULL!" ) ;
427 }
428 SmartIF<IService> svc(const_cast<IInterface*>(Svc));
429 if (svc.isValid()) {
430 Services::iterator it = m_services.find(svc->name());
431 if (it == m_services.end()) {
432 return Warning( "releaseSvc(IInterface):: IInterface* is not active" );
433 }
434 if ( msgLevel(MSG::DEBUG) ) {
435 debug() << "Releasing service '" << it->first << "'" << endmsg;
436 }
437 m_services.erase(it);
438 return StatusCode::SUCCESS;
439 }
440 return Warning( "releaseSvc(IInterface):: IInterface* is not a service" );
441 }
442 // ============================================================================
443
444 // ============================================================================
445 // Add the given tool to the list of active tools
446 // ============================================================================
447 template < class PBASE >
448 void GaudiCommon<PBASE>::addToToolList( IAlgTool * tool ) const
449 {
450 if( 0 != tool ) {
451 if ( this->msgLevel ( MSG::DEBUG ) ) {
452 this->debug() << "The tool of type '"
453 << System::typeinfoName(typeid(*tool))
454 << "' has been added with the name '"
455 << tool->name() << "'" << endmsg ;
456 }
457 m_tools.push_back( tool ) ;
458 }
459 }
460 // ============================================================================
461
462 // ============================================================================
463 // Add the given service to the list of active services
464 // ============================================================================
465 template < class PBASE >
466 void GaudiCommon<PBASE>::addToServiceList( const SmartIF<IService>& svc ) const
467 {
468 if (svc.isValid()) {
469 m_services[svc->name()] = svc;
470 }
471 }
472 // ============================================================================
473
474 //=============================================================================
475 // Methods related to messaging
476 //=============================================================================
477
478 // ============================================================================
479 // Print the error message and return status code
480 // ============================================================================
481 template < class PBASE >
482 StatusCode GaudiCommon<PBASE>::Error( const std::string& msg ,
483 const StatusCode st ,
484 const size_t mx ) const
485 {
486 // increase local counter of errors
487 const size_t num = ++m_errors[msg] ;
488 // If suppressed, just return
489 if ( num > mx ) { return st ; }
490 else if ( num == mx ) // issue one-time suppression message
491 { return Print ( "The ERROR message is suppressed : '" +
492 msg + "'" , st , MSG::ERROR ) ; }
493 // return message
494 return Print ( msg , st , MSG::ERROR ) ;
495 }
496 // ============================================================================
497
498 // ============================================================================
499 // Print the warning message and return status code
500 // ============================================================================
501 template < class PBASE >
502 StatusCode GaudiCommon<PBASE>::Warning
503 ( const std::string& msg ,
504 const StatusCode st ,
505 const size_t mx ) const
506 {
507 // increase local counter of warnings
508 const size_t num = ++m_warnings[msg] ;
509 // If suppressed, just return
510 if ( num > mx ) { return st ; }
511 else if ( num == mx ) // issue one-time suppression message
512 { return Print ( "The WARNING message is suppressed : '" +
513 msg + "'" , st , MSG::WARNING ) ; }
514 // return message
515 return Print ( msg , st , MSG::WARNING ) ;
516 }
517 // ============================================================================
518
519 // ============================================================================
520 // Print the info message and return status code
521 // ============================================================================
522 template < class PBASE >
523 StatusCode GaudiCommon<PBASE>::Info
524 ( const std::string& msg ,
525 const StatusCode st ,
526 const size_t mx ) const
527 {
528 // increase local counter of warnings
529 const size_t num = ++m_infos[msg] ;
530 // If suppressed, just return
531 if ( num > mx ) { return st ; }
532 else if ( num == mx ) // issue one-time suppression message
533 { return Print ( "The INFO message is suppressed : '" +
534 msg + "'" , st , MSG::INFO ) ; }
535 // return message
536 return Print ( msg , st , MSG::INFO ) ;
537 }
538 // ============================================================================
539
540 // ============================================================================
541 // Print the message and return status code
542 // ============================================================================
543 template < class PBASE >
544 StatusCode GaudiCommon<PBASE>::Print( const std::string& msg ,
545 const StatusCode st ,
546 const MSG::Level lvl ) const
547 {
548 // perform printout ?
549 if ( !msgLevel( lvl ) ) { return st ; } // RETURN
550
551 // use the predefined stream
552 MsgStream& str = msgStream( lvl ) ;
553 if ( typePrint() ) { str << System::typeinfoName(typeid(*this)) << ":: " ; }
554 // print the message
555 str << msg ;
556 // test status code
557 if ( st.isSuccess() ) { }
558 else if ( StatusCode::FAILURE != st.getCode() )
559 { str << " StatusCode=" << st.getCode() ; }
560 else
561 { str << " StatusCode=FAILURE" ; }
562 // perform print operation
563 str << endmsg ;
564 // return
565 return st;
566 }
567 // ============================================================================
568
569 // ============================================================================
570 // Create and (re)-throw the exception
571 // ============================================================================
572 template < class PBASE >
573 void GaudiCommon<PBASE>::Exception( const std::string & msg ,
574 const GaudiException & exc ,
575 const StatusCode sc ) const
576 {
577 // increase local counter of exceptions
578 ++m_exceptions[ msg ];
579 Print ( "Exception (re)throw: " + msg , sc , MSG::FATAL ).ignore();
580 throw GaudiException( this->name() + ":: " + msg , this->name() , sc, exc);
581 }
582 // ============================================================================
583
584 // ============================================================================
585 // Create and (re)-throw the exception
586 // ============================================================================
587 template < class PBASE >
588 void GaudiCommon<PBASE>::Exception( const std::string & msg ,
589 const std::exception & exc ,
590 const StatusCode sc ) const
591 {
592 // increase local counter of exceptions
593 ++m_exceptions[ msg ];
594 Print ( "Exception (re)throw: " + msg , sc , MSG::FATAL ).ignore();
595 throw GaudiException( this->name() + ":: " + msg+"("+exc.what()+")", "", sc );
596 }
597 // ============================================================================
598
599 // ============================================================================
600 // Create and throw the exception
601 // ============================================================================
602 template < class PBASE >
603 void GaudiCommon<PBASE>::Exception( const std::string & msg ,
604 const StatusCode sc ) const
605 {
606 // increase local counter of exceptions
607 ++m_exceptions[ msg ];
608 Print ( "Exception throw: " + msg , sc , MSG::FATAL ).ignore();
609 throw GaudiException( this->name() + ":: " + msg , "", sc );
610 }
611 // ============================================================================
612
613 // ============================================================================
614 // perform the actual printout of counters
615 // ============================================================================
616 template < class PBASE >
617 long GaudiCommon<PBASE>::printStat( const MSG::Level level ) const
618 {
619 // print statistics
620 if ( counters().empty() ) { return 0 ; }
621 MsgStream& msg = msgStream ( level ) ;
622 //
623 msg << "Number of counters : " << counters().size() ;
624 //
625 if ( !counters().empty() ) { msg << std::endl << m_header ; }
626 //
627 for ( Statistics::const_iterator entry = counters().begin() ;
628 counters().end() != entry ; ++entry )
629 {
630 msg << std::endl
631 << Gaudi::Utils::formatAsTableRow
632 ( entry -> first ,
633 entry -> second ,
634 m_useEffFormat ,
635 m_format1 , m_format2 );
636 }
637 //
638 msg << endmsg ;
639 //
640 return counters().size() ;
641 }
642 // ============================================================================
643
644 // ============================================================================
645 // perform the actual printout of error counters
646 // ============================================================================
647 template < class PBASE >
648 long GaudiCommon<PBASE>::printErrors ( const MSG::Level level ) const
649 {
650 // format for printout
651 boost::format ftm ( " %s = %|.8s| %|23t| Message = '%s'" );
652
653 { // print exceptions
654 for ( Counter::const_iterator excp = m_exceptions.begin() ;
655 excp != m_exceptions.end() ; ++excp )
656 {
657 msgStream(level)
658 << ( ftm % "#EXCEPTIONS" % excp->second % excp->first )
659 << endmsg;
660 }
661 }
662 { // print errors
663 for ( Counter::const_iterator error = m_errors.begin() ;
664 error != m_errors.end() ; ++error )
665 {
666 msgStream(level)
667 << ( ftm % "#ERRORS " % error->second % error->first )
668 << endmsg;
669 }
670 }
671 { // print warnings
672 for ( Counter::const_iterator warning = m_warnings.begin() ;
673 warning != m_warnings.end() ; ++warning )
674 {
675 msgStream(level)
676 << ( ftm % "#WARNINGS " % warning->second % warning->first )
677 << endmsg;
678 }
679 }
680 { // print warnings
681 for ( Counter::const_iterator info = m_infos.begin() ;
682 info != m_infos.end() ; ++info )
683 {
684 msgStream(level)
685 << ( ftm % "#INFOS " % info->second % info->first )
686 << endmsg;
687 }
688 }
689
690 // return total number of errors+warnings+exceptions
691 return
692 m_exceptions .size () +
693 m_errors .size () +
694 m_warnings .size () +
695 m_infos .size () ;
696 }
697 // ============================================================================
698
699 // ============================================================================
703 // ============================================================================
704 template < class PBASE >
705 long GaudiCommon<PBASE>::printProps ( const MSG::Level level ) const
706 {
707
708 // print ALL properties
709 MsgStream& msg = msgStream ( level );
710 typedef std::vector<Property*> Properties;
711 const Properties& properties = this->getProperties() ;
712 msg << "List of ALL properties of "
713 << System::typeinfoName( typeid( *this ) ) << "/" << this->name()
714 << " #properties = " << properties.size() << endmsg ;
715 for ( Properties::const_reverse_iterator property
716 = properties.rbegin() ;
717 properties.rend() != property ; ++property )
718 {
719 msg << "Property ['Name': Value] = "
720 << ( **property)
721 << endmsg ;
722 }
723 return properties.size() ;
724 }
725 // ============================================================================
726
727 // ============================================================================
728 // Handle method for changes in the Messaging levels
729 // ============================================================================
730 template < class PBASE >
731 void GaudiCommon<PBASE>::msgLevelHandler ( Property & theProp )
732 {
733 // Force a new MsgStream object, to pick up the new settings
734 resetMsgStream();
735
736 // adjust internal message level
737 m_msgLevel =
738 this->outputLevel() < (int) MSG::NIL ? MSG::NIL :
739 this->outputLevel() >= (int) MSG::NUM_LEVELS ? MSG::ALWAYS :
740 MSG::Level( this->outputLevel() ) ;
741
742 // Keep MessageSvc up to date if needed
743 if ( this->msgSvc()->outputLevel(this->name()) != this->outputLevel() )
744 {
745 this->msgSvc()->setOutputLevel( this->name(), this->outputLevel() );
746 }
747
748 // printout message
749 if ( msgLevel(MSG::DEBUG) )
750 {
751 debug() << "Property update for "
752 << theProp.name() << " : new value = " << this->outputLevel() << endmsg;
753 }
754 }
755 // ============================================================================
756
757 // ============================================================================
758 // Methods for dealing with the TES and TDS
759 // ============================================================================
760
761 // ============================================================================
762 // put results into Gaudi Event Transient Store
763 // ============================================================================
764 template < class PBASE >
765 DataObject* GaudiCommon<PBASE>::put ( IDataProviderSvc* svc ,
766 DataObject* object ,
767 const std::string& location ,
768 const bool useRootInTES ) const
769 {
770 // check arguments
771 Assert ( 0 != svc , "put():: Invalid 'service'!" ) ;
772 Assert ( 0 != object , "put():: Invalid 'Object'!" ) ;
773 Assert ( !location.empty() , "put():: Invalid 'address' = '' " ) ;
774 // final data location
775 const std::string & fullLocation = fullTESLocation( location, useRootInTES );
776 // register the object!
777 const StatusCode status = '/' == fullLocation[0] ?
778 svc -> registerObject( fullLocation , object ) :
779 svc -> registerObject( "/Event/" + fullLocation , object ) ;
780 // check the result!
781 if ( status.isFailure() )
782 { Exception ( "put():: could not register '" +
783 System::typeinfoName( typeid( *object ) ) +
784 "' at address '" + fullLocation + "'" , status ) ; }
785 if ( msgLevel( MSG::DEBUG ) )
786 { Print( "The object of type '" +
787 System::typeinfoName( typeid( *object ) ) +
788 "' is registered in TS at address '"
789 + fullLocation + "'" , status , MSG::DEBUG ).ignore() ; }
790 return object;
791 }
792 // ============================================================================
793
794 // ============================================================================
795 // Handle method for changes in the 'ErrorsPrint'
796 // ============================================================================
797 template < class PBASE >
798 void GaudiCommon<PBASE>::printErrorHandler ( Property& /* theProp */ )
799 {
800 // no action if not yet initialized
801 if ( this -> FSMState() < Gaudi::StateMachine::INITIALIZED ) { return ; }
802 if ( this -> errorsPrint() ) { this -> printErrors () ; }
803 }
804 // ============================================================================
805 // Handle method for changes in the 'PropertiesPrint'
806 // ============================================================================
807 template < class PBASE >
808 void GaudiCommon<PBASE>::printPropsHandler ( Property& /* theProp */ )
809 {
810 // no action if not yet initialized
811 if ( this -> FSMState() < Gaudi::StateMachine::INITIALIZED ) { return ; }
812 if ( this -> propsPrint() ) { this -> printProps ( MSG::ALWAYS ) ; }
813 }
814 // ============================================================================
815 // Handle method for changes in the 'StatPrint'
816 // ============================================================================
817 template < class PBASE >
818 void GaudiCommon<PBASE>::printStatHandler ( Property& /* theProp */ )
819 {
820 // no action if not yet initialized
821 if ( this -> FSMState() < Gaudi::StateMachine::INITIALIZED ) { return ; }
822 if ( this -> statPrint() ) { this -> printStat ( MSG::ALWAYS ) ; }
823 }
824 // ============================================================================
825
826
827 // ============================================================================
828 // The END
829 // ============================================================================
830
831