![]() |
|
|
Generated: 18 Jul 2008 |
00001 // $Id: GaudiCommon.icpp,v 1.20 2008/06/05 12:10:20 marcocle Exp $ 00002 00003 // ============================================================================ 00004 // CVS tag $Name: v11r1 $ version $Revision: 1.20 $ 00005 // ============================================================================ 00006 // ============================================================================ 00007 // include files 00008 // ============================================================================ 00009 // STL & STD 00010 // ============================================================================ 00011 #include <algorithm> 00012 #include <cstdlib> 00013 // ============================================================================ 00014 /* @file GaudiCommon.cpp 00015 * 00016 * Implementation file for class : GaudiCommon 00017 * 00018 * @author Chris Jones Christopher.Rob.Jones@cern.ch 00019 * @author Vanya BELYAEV Ivan.Belyaev@itep.ru 00020 * @date 2005-08-08 00021 */ 00022 // GaudiKernel 00023 // ============================================================================ 00024 #include "GaudiKernel/IDataProviderSvc.h" 00025 #include "GaudiKernel/IToolSvc.h" 00026 #include "GaudiKernel/IProperty.h" 00027 #include "GaudiKernel/Property.h" 00028 #include "GaudiKernel/ISvcLocator.h" 00029 #include "GaudiKernel/MsgStream.h" 00030 #include "GaudiKernel/ObjectVector.h" 00031 #include "GaudiKernel/SmartDataPtr.h" 00032 #include "GaudiKernel/SmartRef.h" 00033 #include "GaudiKernel/Stat.h" 00034 #include "GaudiKernel/System.h" 00035 #include "GaudiKernel/IJobOptionsSvc.h" 00036 #include "GaudiKernel/StatEntity.h" 00037 #include "GaudiKernel/Algorithm.h" 00038 #include "GaudiKernel/AlgTool.h" 00039 // ============================================================================ 00040 // GaudiAlg 00041 // ============================================================================ 00042 #include "GaudiAlg/Print.h" 00043 #include "GaudiAlg/GaudiCommon.h" 00044 #include "GaudiAlg/GaudiAlgorithm.h" 00045 #include "GaudiAlg/GaudiTool.h" 00046 // ============================================================================ 00047 // Boost 00048 // ============================================================================ 00049 #include "boost/format.hpp" 00050 #include "boost/lexical_cast.hpp" 00051 // ============================================================================ 00052 // Disable warning on windows 00053 #ifdef _WIN32 00054 #pragma warning ( disable:4661 ) // incomplete explicit templates 00055 #endif 00056 // ============================================================================ 00057 00058 //============================================================================= 00059 // Destructor 00060 //============================================================================= 00061 template < class PBASE > 00062 GaudiCommon<PBASE>::~GaudiCommon() { resetMsgStream(); } 00063 //========================================================================== 00064 00065 // ============================================================================ 00066 // constructor initialisation 00067 // ============================================================================ 00068 template <class PBASE> 00069 void 00070 GaudiCommon<PBASE>::initGaudiCommonConstructor( const IInterface * parent ) 00071 { 00072 // initialise data members 00073 m_msgLevel = MSG::NIL; 00074 m_msgStream = 0; 00075 m_updMgrSvc = 0; 00076 m_fastContainersSvc = 0; 00077 m_typePrint = true; 00078 m_propsPrint = false; 00079 m_statPrint = true; 00080 m_errorsPrint = true; 00081 m_context = "" ; 00082 m_rootInTES = "" ; 00083 m_globalTimeOffset = 0.0 ; 00084 00085 // printout of counters: 00086 00087 // the header row for counters printout 00088 m_header = " | Counter | # | sum | mean/eff^* | rms/err^* | min | max |" ; 00089 // format for regular statistical printout rows 00090 m_format1 = " | %|-48.48s|%|50t||%|10d| |%|11.7g| |%|#11.5g| |%|#11.5g| |%|#12.5g| |%|#12.5g| |" ; 00091 // format for "efficiency" statistical printout rows 00092 m_format2 = " |*%|-48.48s|%|50t||%|10d| |%|11.5g| |(%|#9.6g| +- %|-#9.6g|)%%| ------- | ------- |" ; 00093 // flag to use the special "efficiency" format 00094 m_useEffFormat = true ; 00095 00096 00097 // job options 00098 // print error counters at finalization ? 00099 this->declareProperty ( "ErrorsPrint" , m_errorsPrint ) ; 00100 // print properties at initalization? 00101 this->declareProperty ( "PropertiesPrint" , m_propsPrint ) ; 00102 // print statistical counters at finalization ? 00103 this->declareProperty ( "StatPrint" , m_statPrint ) ; 00104 // insert the actual C++ type of the algorithm or tool in the messages? 00105 this->declareProperty ( "TypePrint" , m_typePrint ) ; 00106 // context 00107 this->declareProperty ( "Context" , m_context ) ; 00108 // root in TES 00109 this->declareProperty ( "RootInTES" , m_rootInTES ) ; 00110 // root on TES ( temporary ) 00111 this->declareProperty ( "RootOnTES" , m_rootOnTES ) ; 00112 // global time offset 00113 this->declareProperty ( "GlobalTimeOffset", m_globalTimeOffset ) ; 00114 00115 00116 // the header row for counters printout 00117 this->declareProperty 00118 ( "StatTableHeader" , m_header , 00119 "The header row for the output Stat-table" ) ; 00120 // format for regular statistical printout rows 00121 this->declareProperty 00122 ( "RegularRowFormat" , m_format1 , 00123 "The format for the regular row in the output Stat-table" ) ; 00124 // format for "efficiency" statistical printout rows 00125 this->declareProperty 00126 ( "EfficiencyRowFormat" , m_format2 , 00127 "The format for the regular row in the outptu Stat-table" ) ; 00128 // flag to use the special "efficiency" format 00129 this->declareProperty 00130 ( "UseEfficiencyRowFormat" , m_useEffFormat , 00131 "Use the special format for printout of efficiency counters" ) ; 00132 00133 00134 // add handler for message level changes 00135 this->outputLevelProperty().declareUpdateHandler( &GaudiCommon<PBASE>::msgLevelHandler, this ); 00136 00137 // setup context from parent if available 00138 if ( parent ) 00139 { 00140 if ( const GaudiAlgorithm* gAlg = dynamic_cast<const GaudiAlgorithm*>(parent) ) 00141 { 00142 m_context = gAlg->context(); 00143 m_rootInTES = gAlg->rootInTES(); 00144 m_globalTimeOffset = gAlg->globalTimeOffset(); 00145 } 00146 else if ( const GaudiTool* gTool = dynamic_cast<const GaudiTool*> (parent) ) 00147 { 00148 m_context = gTool->context(); 00149 m_rootInTES = gTool->rootInTES(); 00150 m_globalTimeOffset = gTool->globalTimeOffset(); 00151 } 00152 } 00153 00154 // Get the job option service 00155 IJobOptionsSvc* jos = svc<IJobOptionsSvc>( "JobOptionsSvc" ); 00156 00157 // Get the "Context" option if in the file... 00158 const std::vector<const Property*>* myList = jos->getProperties( this->name() ); 00159 if ( 0 != myList ) 00160 { 00161 // Iterate over the list to set the options 00162 for ( std::vector<const Property*>::const_iterator iter = myList->begin(); 00163 iter != myList->end(); 00164 ++iter ) 00165 { 00166 const StringProperty* sp = dynamic_cast<const StringProperty*>(*iter); 00167 if ( 0 != sp ) 00168 { 00169 if ( "Context" == (*iter)->name() ) 00170 { 00171 m_context = sp->value(); 00172 } else if ( "RootInTES" == (*iter)->name() ) { 00173 m_rootInTES = sp->value(); 00174 } else if ( "GlobalTimeOffset" == (*iter)->name() ) { 00175 m_globalTimeOffset = atof( sp->value().c_str() ); 00176 } 00177 } 00178 } 00179 } 00180 00181 // release tool 00182 release( jos ).ignore(); 00183 00184 } 00185 //============================================================================= 00186 00187 //============================================================================= 00188 // Initialise the common functionality 00189 //============================================================================= 00190 template < class PBASE > 00191 StatusCode GaudiCommon<PBASE>::initialize() 00192 { 00193 00194 // initialize base class 00195 const StatusCode sc = PBASE::initialize(); 00196 if ( sc.isFailure() ) 00197 { return Error ( "Failed to initialise base class PBASE", sc ) ; } 00198 00199 00200 // some debug printout 00201 if ( msgLevel(MSG::DEBUG) ) 00202 { 00203 debug() << "Initialize base class GaudiCommon<PBASE>" << endreq; 00204 if ( !context().empty() ) 00205 debug() << "Created with context = '" << context() << "'" << endreq; 00206 } 00207 00208 // some temporary checks to see if people are using RootOnTES and warn if so 00209 // TO BE REMOVED ASAP ... 00210 if ( m_rootInTES.empty() && !m_rootOnTES.empty() ) 00211 { 00212 m_rootInTES = m_rootOnTES; 00213 Warning( "RootOnTES option is OBSOLETE -> Use RootInTES instead. RootInTES has been updated to " 00214 + m_rootInTES, StatusCode::SUCCESS ).ignore(); 00215 } 00216 else if ( !m_rootInTES.empty() && !m_rootOnTES.empty() ) 00217 { 00218 Warning( "Options RootOnTES AND RootInTES are defined ! Use RootInTES. RootOnTES is ignored", 00219 StatusCode::SUCCESS ).ignore(); 00220 } 00221 00222 // Check rootInTES ends with a / 00223 if ( !m_rootInTES.empty() && 00224 m_rootInTES.substr(m_rootInTES.size()-1) != "/" ) m_rootInTES += "/"; 00225 00226 // properties will be printed if asked for or in "MSG::DEBUG" mode 00227 if ( propsPrint() ) { printProps(MSG::ALWAYS); } 00228 else if ( msgLevel(MSG::DEBUG) ) { printProps(MSG::DEBUG); } 00229 00230 return sc; 00231 } 00232 //============================================================================= 00233 00234 //============================================================================= 00235 // Finalize the common functionality 00236 //============================================================================= 00237 template < class PBASE > 00238 StatusCode GaudiCommon<PBASE>::finalize() 00239 { 00240 StatusCode sc = StatusCode::SUCCESS; 00241 00242 // print the general information about statistical counters 00243 if ( msgLevel(MSG::DEBUG) || (statPrint() && !counters().empty()) ) 00244 { 00245 // print general statictical counters 00246 printStat ( statPrint() ? MSG::ALWAYS : MSG::DEBUG ) ; 00247 } 00248 00249 // release all located tools and services 00250 if ( msgLevel(MSG::DEBUG) ) 00251 { 00252 debug() << "Tools to release :"; 00253 for ( AlgTools::const_iterator i = m_tools.begin(); 00254 i != m_tools.end(); ++i ) 00255 { 00256 debug() << " " << (*i)->name(); 00257 } 00258 debug() << endreq; 00259 } 00260 while ( !m_tools.empty() ) { sc = sc && release( m_tools.back() ) ; } 00261 00262 // release all located services 00263 if ( msgLevel(MSG::DEBUG) ) 00264 { 00265 debug() << "Services to release :"; 00266 for ( Services::const_iterator i = m_services.begin(); 00267 i != m_services.end(); ++i ) 00268 { 00269 debug() << " " << (*i).second; 00270 } 00271 debug() << endreq; 00272 } 00273 while ( !m_services.empty() ) { sc = sc && release( m_services.back().first ); } 00274 00275 // format printout 00276 if ( !m_errors.empty() || !m_warnings.empty() || !m_exceptions.empty() ) 00277 { 00278 always() << "Exceptions/Errors/Warnings Statistics : " 00279 << m_exceptions .size () << "/" 00280 << m_errors .size () << "/" 00281 << m_warnings .size () << endreq ; 00282 if ( errorsPrint() ) { printErrors () ; } 00283 } 00284 00285 // delete the MsgStream 00286 resetMsgStream(); 00287 00288 // clear *ALL* counters explicitely 00289 m_counters .clear() ; 00290 m_exceptions .clear() ; 00291 m_warnings .clear() ; 00292 m_errors .clear() ; 00293 00294 // finalize base class 00295 return sc && PBASE::finalize(); 00296 } 00297 //============================================================================= 00298 00299 //============================================================================= 00300 // Methods related to tools and services 00301 //============================================================================= 00302 00303 // ============================================================================ 00304 // manual forced (and 'safe') release of the active tool or service 00305 // ============================================================================ 00306 template < class PBASE > 00307 StatusCode GaudiCommon<PBASE>::release ( const IInterface* interface ) const 00308 { 00309 if ( 0 == interface ) 00310 { return Error ( "release(IInterface):: IInterface* points to NULL!" ) ; } 00311 // dispatch between tools and services 00312 const IAlgTool* algTool = dynamic_cast<const IAlgTool*>( interface ) ; 00313 // perform teh actual release 00314 return 0 != algTool ? releaseTool( algTool ) : releaseSvc( interface ) ; 00315 } 00316 // ============================================================================ 00317 00318 // ============================================================================ 00319 // manual forced (and 'save') release of the tool 00320 // ============================================================================ 00321 template < class PBASE > 00322 StatusCode GaudiCommon<PBASE>::releaseTool ( const IAlgTool* algTool ) const 00323 { 00324 if( 0 == algTool ) 00325 { return Error ( "releaseTool(IAlgTool):: IAlgTool* points to NULL!" ) ; } 00326 if( 0 == this->toolSvc() ) 00327 { return Error ( "releaseTool(IAlgTool):: IToolSvc* points to NULL!" ) ; } 00328 // find a tool in the list of active tools 00329 AlgTools::reverse_iterator it = 00330 std::find( m_tools.rbegin() , m_tools.rend() , algTool ) ; 00331 if( m_tools.rend() == it ) 00332 { return Warning("releaseTool(IAlgTool):: IAlgTool* is not active" ) ; } 00333 // get the tool 00334 IAlgTool* t = *it ; 00335 // cache name 00336 const std::string name = t->name(); 00337 if ( msgLevel(MSG::DEBUG) ) 00338 { debug() << "Releasing tool '" << name << "'" << endreq; } 00339 // remove the tool from the lists 00340 m_tools.erase( --it.base() ) ; 00341 // release tool 00342 const StatusCode sc = this->toolSvc()->releaseTool( t ) ; 00343 // Check for more tools of the same name 00344 while ( (it = std::find(m_tools.rbegin(),m_tools.rend(),algTool)) != m_tools.rend() ) 00345 { 00346 Warning( "Removing additional reference(s) to '"+name+"' in active tool list", 00347 StatusCode::SUCCESS, 1 ).ignore(); 00348 m_tools.erase( --it.base() ) ; 00349 } 00350 if ( sc.isFailure() ) 00351 { return Warning ( "releaseTool(IAlgTool):: error from IToolSvc whilst releasing "+name , sc ) ; } 00352 // return final status code 00353 return sc ; 00354 } 00355 // ============================================================================ 00356 00357 // ============================================================================ 00358 // manual forced (and 'safe') release of the service 00359 // ============================================================================ 00360 template < class PBASE > 00361 StatusCode GaudiCommon<PBASE>::releaseSvc ( const IInterface* Svc ) const 00362 { 00363 if( 0 == Svc ) 00364 { return Error ( "releaseSvc(IInterface):: IInterface* points to NULL!" ) ; } 00365 // find a service in the list of active services 00366 Services::reverse_iterator iS = m_services.rbegin(); 00367 for ( ; iS != m_services.rend(); ++iS ) { if ( (*iS).first == Svc ) break; } 00368 if ( m_services.rend() == iS ) 00369 { return Warning( "releaseSvc(IInterface):: IInterface* is not active" ) ; } 00370 // get the service 00371 IInterface * s = (*iS).first ; 00372 if ( msgLevel(MSG::DEBUG) ) 00373 { debug() << "Releasing service '" << (*iS).second << "'" << endreq; } 00374 // remove the service from the list of active services 00375 m_services.erase( --iS.base() ) ; 00376 // release the service 00377 s->release() ; 00378 // return 00379 return StatusCode::SUCCESS ; 00380 } 00381 // ============================================================================ 00382 00383 // ============================================================================ 00384 // Add the given tool to the list of active tools 00385 // ============================================================================ 00386 template < class PBASE > 00387 void GaudiCommon<PBASE>::addToToolList( IAlgTool * tool ) const 00388 { 00389 AlgTools::const_iterator iTool = std::find( m_tools.begin(), 00390 m_tools.end(), 00391 tool ); 00392 if ( iTool != m_tools.end() ) 00393 { 00394 Warning( "Tool '" + tool->name() + "' already in list of active tools" ).ignore(); 00395 } 00396 m_tools.push_back( tool ) ; 00397 } 00398 // ============================================================================ 00399 00400 // ============================================================================ 00401 // Add the given service to the list of active services 00402 // ============================================================================ 00403 template < class PBASE > 00404 void GaudiCommon<PBASE>::addToServiceList( IInterface * svc, 00405 const std::string & name ) const 00406 { 00407 const ServiceEntry sEntry( svc , name ); 00408 Services::const_iterator iSvc = std::find( m_services.begin(), 00409 m_services.end(), 00410 sEntry ); 00411 if ( iSvc != m_services.end() ) 00412 { 00413 Warning( "Service '" + name + "' already in list of active services" ).ignore(); 00414 } 00415 m_services.push_back( sEntry ) ; 00416 } 00417 // ============================================================================ 00418 00419 //============================================================================= 00420 // Methods related to messaging 00421 //============================================================================= 00422 00423 // ============================================================================ 00424 // Print the error message and return status code 00425 // ============================================================================ 00426 template < class PBASE > 00427 StatusCode GaudiCommon<PBASE>::Error( const std::string& msg , 00428 const StatusCode st , 00429 const size_t mx ) const 00430 { 00431 // increase local counter of errors 00432 const size_t num = ++m_errors[msg] ; 00433 // If suppressed, just return 00434 if ( num > mx ) { return st ; } 00435 else if ( num == mx ) // issue one-time suppresion message 00436 { return Print ( "The ERROR message is suppressed : '" + 00437 msg + "'" , st , MSG::ERROR ) ; } 00438 // return message 00439 return Print ( msg , st , MSG::ERROR ) ; 00440 } 00441 // ============================================================================ 00442 00443 // ============================================================================ 00444 // Print the warning message and return status code 00445 // ============================================================================ 00446 template < class PBASE > 00447 StatusCode GaudiCommon<PBASE>::Warning 00448 ( const std::string& msg , 00449 const StatusCode st , 00450 const size_t mx ) const 00451 { 00452 // increase local counter of warnings 00453 const size_t num = ++m_warnings[msg] ; 00454 // If suppressed, just return 00455 if ( num > mx ) { return st ; } 00456 else if ( num == mx ) // issue one-time suppresion message 00457 { return Print ( "The WARNING message is suppressed : '" + 00458 msg + "'" , st , MSG::WARNING ) ; } 00459 // return message 00460 return Print ( msg , st , MSG::WARNING ) ; 00461 } 00462 // ============================================================================ 00463 00464 // ============================================================================ 00465 // Print the message and return status code 00466 // ============================================================================ 00467 template < class PBASE > 00468 StatusCode GaudiCommon<PBASE>::Print( const std::string& msg , 00469 const StatusCode st , 00470 const MSG::Level lvl ) const 00471 { 00472 // perform printout ? 00473 if ( !msgLevel( lvl ) ) { return st ; } // RETURN 00474 00475 // use the predefined stream 00476 MsgStream& str = msgStream( lvl ) ; 00477 if ( typePrint() ) { str << System::typeinfoName(typeid(*this)) << ":: " ; } 00478 // print the message 00479 str << msg ; 00480 // test status code 00481 if ( st.isSuccess() ) { } 00482 else if ( StatusCode::FAILURE != st.getCode() ) 00483 { str << " StatusCode=" << st.getCode() ; } 00484 else 00485 { str << " StatusCode=FAILURE" ; } 00486 // perform print operation 00487 str << endreq ; 00488 // return 00489 return st; 00490 } 00491 // ============================================================================ 00492 00493 // ============================================================================ 00494 // Create and (re)-throw the exception 00495 // ============================================================================ 00496 template < class PBASE > 00497 StatusCode GaudiCommon<PBASE>::Exception( const std::string & msg , 00498 const GaudiException & exc , 00499 const StatusCode sc ) const 00500 { 00501 // increase local counter of exceptions 00502 ++m_exceptions[ msg ]; 00503 Print ( "Exception (re)throw: " + msg , sc , MSG::FATAL ); 00504 throw GaudiException( this->name() + ":: " + msg , this->name() , sc, exc); 00505 return sc ; 00506 } 00507 // ============================================================================ 00508 00509 // ============================================================================ 00510 // Create and (re)-throw the exception 00511 // ============================================================================ 00512 template < class PBASE > 00513 StatusCode GaudiCommon<PBASE>::Exception( const std::string & msg , 00514 const std::exception & exc , 00515 const StatusCode sc ) const 00516 { 00517 // increase local counter of exceptions 00518 ++m_exceptions[ msg ]; 00519 Print ( "Exception (re)throw: " + msg , sc , MSG::FATAL ); 00520 throw GaudiException( this->name() + ":: " + msg+"("+exc.what()+")", "", sc ); 00521 return sc ; 00522 } 00523 // ============================================================================ 00524 00525 // ============================================================================ 00526 // Create and throw the exception 00527 // ============================================================================ 00528 template < class PBASE > 00529 StatusCode GaudiCommon<PBASE>::Exception( const std::string & msg , 00530 const StatusCode sc ) const 00531 { 00532 // increase local counter of exceptions 00533 ++m_exceptions[ msg ]; 00534 Print ( "Exception throw: " + msg , sc , MSG::FATAL ); 00535 throw GaudiException( this->name() + ":: " + msg , "", sc ); 00536 return sc ; 00537 } 00538 // ============================================================================ 00539 00540 // ============================================================================ 00541 // perform the actual printout of counters 00542 // ============================================================================ 00543 template < class PBASE > 00544 long GaudiCommon<PBASE>::printStat( const MSG::Level level ) const 00545 { 00546 // print statistics 00547 if ( counters().empty() ) { return 0 ; } 00548 MsgStream& msg = msgStream ( level ) ; 00549 // 00550 msg << "Number of counters : " << counters().size() ; 00551 // 00552 if ( !counters().empty() ) { msg << std::endl << m_header ; } 00553 // 00554 for ( Statistics::const_iterator entry = counters().begin() ; 00555 counters().end() != entry ; ++entry ) 00556 { 00557 msg << std::endl 00558 << Gaudi::Utils::formatAsTableRow 00559 ( entry -> first , 00560 entry -> second , 00561 m_useEffFormat , 00562 m_format1 , m_format2 ); 00563 } 00564 // 00565 msg << endreq ; 00566 // 00567 return counters().size() ; 00568 } 00569 // ============================================================================ 00570 00571 // ============================================================================ 00572 // perform the actual printout of error counters 00573 // ============================================================================ 00574 template < class PBASE > 00575 long GaudiCommon<PBASE>::printErrors ( const MSG::Level level ) const 00576 { 00577 // format for printout 00578 boost::format ftm ( " %s = %|.8s| %|23t| Message = '%s'" ); 00579 00580 { // print exceptions 00581 for ( Counter::const_iterator excp = m_exceptions.begin() ; 00582 excp != m_exceptions.end() ; ++excp ) 00583 { 00584 msgStream(level) 00585 << ( ftm % "#EXCEPTIONS" % excp->second % excp->first ) 00586 << endreq; 00587 } 00588 } 00589 { // print errors 00590 for ( Counter::const_iterator error = m_errors.begin() ; 00591 error != m_errors.end() ; ++error ) 00592 { 00593 msgStream(level) 00594 << ( ftm % "#ERRORS " % error->second % error->first ) 00595 << endreq; 00596 } 00597 } 00598 { // print warnings 00599 for ( Counter::const_iterator warning = m_warnings.begin() ; 00600 warning != m_warnings.end() ; ++warning ) 00601 { 00602 msgStream(level) 00603 << ( ftm % "#WARNINGS " % warning->second % warning->first ) 00604 << endreq; 00605 } 00606 } 00607 00608 // return total number of errors+warnings+exceptions 00609 return 00610 m_exceptions .size () + 00611 m_errors .size () + 00612 m_warnings .size () ; 00613 } 00614 // ============================================================================ 00615 00616 // ============================================================================ 00620 // ============================================================================ 00621 template < class PBASE > 00622 long GaudiCommon<PBASE>::printProps ( const MSG::Level level ) const 00623 { 00624 00625 // print ALL properties 00626 MsgStream& msg = msgStream ( level ); 00627 typedef std::vector<Property*> Properties; 00628 const Properties& properties = this->getProperties() ; 00629 msg << "List of ALL properties of " 00630 << System::typeinfoName( typeid( *this ) ) << "/" << this->name() 00631 << " #properties = " << properties.size() << endreq ; 00632 for ( Properties::const_reverse_iterator property 00633 = properties.rbegin() ; 00634 properties.rend() != property ; ++property ) 00635 { 00636 msg << "Property ['Name': Value] = " 00637 << ( **property) 00638 << endreq ; 00639 } 00640 return properties.size() ; 00641 } 00642 // ============================================================================ 00643 00644 // ============================================================================ 00645 // Handle method for changes in the Messaging levels 00646 // ============================================================================ 00647 template < class PBASE > 00648 void GaudiCommon<PBASE>::msgLevelHandler ( Property & theProp ) 00649 { 00650 // Force a new MsgStream object, to pick up the new settings 00651 resetMsgStream(); 00652 00653 // adjust internal message level 00654 m_msgLevel = 00655 this->outputLevel() < (int) MSG::NIL ? MSG::NIL : 00656 this->outputLevel() >= (int) MSG::NUM_LEVELS ? MSG::ALWAYS : 00657 MSG::Level( this->outputLevel() ) ; 00658 00659 // Keep MessageSvc up to date if needed 00660 if ( this->msgSvc()->outputLevel(this->name()) != this->outputLevel() ) 00661 { 00662 this->msgSvc()->setOutputLevel( this->name(), this->outputLevel() ); 00663 } 00664 00665 // printout message 00666 if ( msgLevel(MSG::DEBUG) ) 00667 { 00668 debug() << "Property update for " 00669 << theProp.name() << " : new value = " << this->outputLevel() << endreq; 00670 } 00671 } 00672 // ============================================================================ 00673 00674 // ============================================================================ 00675 // Methods for dealing with the TES and TDS 00676 // ============================================================================ 00677 00678 // ============================================================================ 00679 // put results into Gaudi Event Transient Store 00680 // ============================================================================ 00681 template < class PBASE > 00682 void GaudiCommon<PBASE>::put ( IDataProviderSvc* svc , 00683 DataObject* object , 00684 const std::string& location , 00685 const bool useRootInTES ) const 00686 { 00687 // check arguments 00688 Assert ( 0 != svc , "put():: Invalid 'service'!" ) ; 00689 Assert ( 0 != object , "put():: Invalid 'Object'!" ) ; 00690 Assert ( !location.empty() , "put():: Invalid 'address' = '' " ) ; 00691 // final data location 00692 const std::string & fullLocation = fullTESLocation( location, useRootInTES ); 00693 // register the object! 00694 const StatusCode status = '/' == fullLocation[0] ? 00695 svc -> registerObject( fullLocation , object ) : 00696 svc -> registerObject( "/Event/" + fullLocation , object ) ; 00697 // check the result! 00698 if ( status.isFailure() ) 00699 { Exception ( "put():: could not register '" + 00700 System::typeinfoName( typeid( *object ) ) + 00701 "' at address '" + fullLocation + "'" , status ) ; } 00702 if ( msgLevel( MSG::DEBUG ) ) 00703 { Print( "The object of type '" + 00704 System::typeinfoName( typeid( *object ) ) + 00705 "' is registered in TS at address '" 00706 + fullLocation + "'" , status , MSG::DEBUG ) ; } 00707 } 00708 // ============================================================================