00001
00002
00003
00004 #include "ApplicationMgr.h"
00005 #include "ServiceFactory.h"
00006 #include "AlgorithmFactory.h"
00007 #include "ConverterFactory.h"
00008 #include "ObjectManager.h"
00009 #include "DLLClassManager.h"
00010 #include "ListItem.h"
00011
00012 #include "GaudiKernel/IService.h"
00013 #include "GaudiKernel/IRunable.h"
00014 #include "GaudiKernel/IMessageSvc.h"
00015 #include "GaudiKernel/IJobOptionsSvc.h"
00016
00017 #include "GaudiKernel/SmartIF.h"
00018 #include "GaudiKernel/MsgStream.h"
00019 #include "GaudiKernel/PropertyMgr.h"
00020 #include "GaudiKernel/ObjectFactory.h"
00021
00022 static ObjectFactory<ApplicationMgr> s_factory;
00023 const IFactory& ApplicationMgrFactory = s_factory;
00024
00025 static const char* s_eventloop = "EventLoop";
00026 static const char* s_runable = "Runable";
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 ApplicationMgr::ApplicationMgr(IInterface*) {
00037
00038 m_refcount = 1;
00039
00040
00041 m_objFactory = new ObjectManager(this);
00042 m_svcFactory = new ServiceFactory(this);
00043 m_algFactory = new AlgorithmFactory(this);
00044 m_cnvFactory = new ConverterFactory(this);
00045 m_classManager = new DLLClassManager(this);
00046 m_propertyMgr = new PropertyMgr();
00047
00048
00049 m_messageSvc = 0;
00050 m_svcLocator = (ISvcLocator*)this;
00051
00052 m_name = "ApplicationMgr";
00053 m_state = OFFLINE;
00054 m_stateName.push_back("Offline");
00055 m_stateName.push_back("Configured");
00056 m_stateName.push_back("Finalized");
00057 m_stateName.push_back("Initialized");
00058
00059 m_propertyMgr->declareProperty("Go", m_SIGo = 0 );
00060 m_propertyMgr->declareProperty("Exit", m_SIExit = 0 );
00061 m_propertyMgr->declareProperty("Dlls", m_dllNameList );
00062 m_propertyMgr->declareProperty("ExtSvc", m_extSvcNameList );
00063 m_propertyMgr->declareProperty("DefSvc", m_defServices );
00064
00065 m_propertyMgr->declareProperty("TopAlg", m_topAlgNameList );
00066 m_propertyMgr->declareProperty("OutStream", m_outStreamNameList );
00067 m_propertyMgr->declareProperty( s_runable, m_runableType = "AppMgrRunable");
00068 m_propertyMgr->declareProperty( s_eventloop,m_eventLoopMgr = "GaudiEventLoopMgr");
00069
00070 m_propertyMgr->declareProperty("HistogramPersistency", m_histPersName="NONE");
00071
00072
00073 m_propertyMgr->declareProperty("JobOptionsType", m_jobOptionsType = "FILE");
00074 m_propertyMgr->declareProperty("JobOptionsPath", m_jobOptionsPath = "jobOptions.txt");
00075 m_propertyMgr->declareProperty("EvtMax", m_evtMax = -1);
00076 m_propertyMgr->declareProperty("EvtSel", m_evtsel );
00077
00078
00079 m_SIGo.declareUpdateHandler ( &ApplicationMgr::SIGoHandler , this );
00080 m_SIExit.declareUpdateHandler( &ApplicationMgr::SIExitHandler , this );
00081 m_topAlgNameList.declareUpdateHandler ( &ApplicationMgr::evtLoopPropertyHandler, this );
00082 m_outStreamNameList.declareUpdateHandler( &ApplicationMgr::evtLoopPropertyHandler, this );
00083 m_extSvcNameList.declareUpdateHandler ( &ApplicationMgr::extSvcNameListHandler , this );
00084 m_dllNameList.declareUpdateHandler ( &ApplicationMgr::dllNameListHandler , this );
00085 m_processingMgr = 0;
00086 m_runable = 0;
00087 }
00088
00089
00090
00091
00092 ApplicationMgr::~ApplicationMgr() {
00093 delete m_objFactory;
00094 delete m_cnvFactory;
00095 delete m_svcFactory;
00096 delete m_algFactory;
00097 delete m_classManager;
00098 delete m_propertyMgr;
00099 }
00100
00101
00102
00103
00104 unsigned long ApplicationMgr::addRef() {
00105 m_refcount++;
00106 return m_refcount;
00107 }
00108
00109
00110
00111
00112 unsigned long ApplicationMgr::release() {
00113 long count = --m_refcount;
00114 if( count <= 0) {
00115 delete this;
00116 }
00117 return count;
00118 }
00119
00120
00121
00122
00123 StatusCode ApplicationMgr::queryInterface(const InterfaceID& iid, void** ppvInterface){
00124
00125 if( iid == IID_IInterface ) {
00126 *ppvInterface = (IInterface*)this;
00127 }
00128 else if ( iid == IID_ISvcLocator ) {
00129 *ppvInterface = (ISvcLocator*)this;
00130 }
00131 else if ( iid == IID_IAppMgrUI ) {
00132 *ppvInterface = (IAppMgrUI*)this;
00133 }
00134 else if ( iid == IID_ISvcManager ) {
00135 *ppvInterface = (ISvcManager*)this;
00136 }
00137 else if ( iid == IID_IObjManager ) {
00138 *ppvInterface = (IObjManager*)this;
00139 }
00140 else if ( iid == IID_IAlgManager ) {
00141 *ppvInterface = (IAlgManager*)this;
00142 }
00143 else if ( iid == IID_IClassManager ) {
00144 *ppvInterface = (IClassManager*)this;
00145 }
00146 else if ( iid == IID_ICnvManager ) {
00147 *ppvInterface = (ICnvManager*)this;
00148 }
00149 else if ( iid == IID_IProperty ) {
00150 *ppvInterface = (IProperty*)this;
00151 }
00152 else {
00153 return StatusCode::FAILURE;
00154 }
00155 addRef();
00156 return StatusCode::SUCCESS;
00157 }
00158
00159
00160
00161
00162 IService* ApplicationMgr::i_connectService(const std::string& typ, const std::string& nam) {
00163 MsgStream log(m_messageSvc, name());
00164 if ( 0 != m_messageSvc ) {
00165 log << MSG::DEBUG << "Creating service " << nam << " of type " << typ << endreq;
00166 }
00167 IService* svc = 0;
00168 StatusCode sc = getService(nam, svc);
00169 if( sc.isSuccess() ) {
00170 log << MSG::WARNING << "Service with name " << nam << " already existing" << endreq;
00171 }
00172 else {
00173 StatusCode sc = m_svcFactory->createService( typ, nam, svc );
00174 if( !sc.isSuccess() ) {
00175 log << MSG::ERROR << "Unable to create Service " << nam << " of type " << typ << endreq;
00176 return 0;
00177 }
00178 m_topSvcList.push_back( svc );
00179 }
00180 return svc;
00181 }
00182
00183
00184
00185
00186 StatusCode ApplicationMgr::i_startup() {
00187 MsgStream tlog( m_messageSvc, name() );
00188 IService *msgsvc = 0, *jobsvc = 0;
00189 IProperty* jobOptsIProp = 0;
00190 StatusCode sc;
00191
00192
00193 m_classManager->loadModule("");
00194
00195
00196 sc = m_svcFactory->createService( "MessageSvc", "MessageSvc", msgsvc );
00197 if( !sc.isSuccess() ) {
00198 tlog << MSG::FATAL << "Error creating MessageSvc" << endreq;
00199 return sc;
00200 }
00201
00202 sc = m_svcFactory->createService( "JobOptionsSvc", "JobOptionsSvc", jobsvc );
00203 if( !sc.isSuccess() ) {
00204 tlog << MSG::FATAL << "Error creating JobOptionsSvc" << endreq;
00205 return sc;
00206 }
00207
00208 sc = m_svcLocator->service( "JobOptionsSvc", jobOptsIProp);
00209 if( !sc.isSuccess() ) {
00210 tlog << MSG::FATAL << "Error retrieving JobOptionsSvc." << endreq;
00211 return sc;
00212 }
00213
00214 jobOptsIProp->setProperty( StringProperty("TYPE", m_jobOptionsType) );
00215 if ( 0 != getenv("JOBOPTPATH") ) {
00216 jobOptsIProp->setProperty( StringProperty("PATH", getenv("JOBOPTPATH")));
00217 }
00218 else {
00219 jobOptsIProp->setProperty( StringProperty("PATH", m_jobOptionsPath ));
00220 }
00221
00222 sc = jobsvc->initialize();
00223 if( !sc.isSuccess() ) {
00224 tlog << MSG::FATAL << "Error initializing JobOptionsSvc" << endreq;
00225 return sc;
00226 }
00227 sc = msgsvc->initialize();
00228 if( !sc.isSuccess() ) {
00229 tlog << MSG::FATAL << "Error initializing MessageSvc" << endreq;
00230 return sc;
00231 }
00232 return sc;
00233 }
00234
00235
00236
00237
00238 StatusCode ApplicationMgr::configure() {
00239 MsgStream tlog( m_messageSvc, name() );
00240 IJobOptionsSvc* jobOptionsSvc = 0;
00241 StatusCode sc;
00242
00243 if( m_state == CONFIGURED ) {
00244 tlog << MSG::INFO << "Already Configured" << endreq;
00245 return StatusCode::SUCCESS;
00246 }
00247 else if( m_state != OFFLINE && m_state != FINALIZED ) {
00248 tlog << MSG::FATAL << "Invalid initial state" << endreq;
00249 return StatusCode::FAILURE;
00250 }
00251 else if( m_state == OFFLINE ) {
00252 sc = i_startup();
00253 if ( !sc.isSuccess() ) {
00254 return sc;
00255 }
00256 }
00257
00258 sc = m_svcLocator->service( "MessageSvc", m_messageSvc);
00259 if( !sc.isSuccess() ) {
00260 tlog << MSG::FATAL << "Error retrieving MessageSvc." << endreq;
00261 return sc;
00262 }
00263 sc = m_svcLocator->service( "JobOptionsSvc", jobOptionsSvc);
00264 if( !sc.isSuccess() ) {
00265 tlog << MSG::FATAL << "Error retrieving MessageSvc." << endreq;
00266 return sc;
00267 }
00268
00269 MsgStream log( m_messageSvc, name() );
00270 m_topSvcNameList.erase(m_topSvcNameList.begin(), m_topSvcNameList.end());
00271 m_defServices.erase(m_defServices.begin(), m_defServices.end());
00272
00273 m_defServices.push_back("EvtDataSvc/EventDataSvc");
00274 m_defServices.push_back("EvtPersistencySvc/EventPersistencySvc");
00275
00276
00277 m_defServices.push_back("DetPersistencySvc/DetectorPersistencySvc");
00278 m_defServices.push_back("DetDataSvc/DetectorDataSvc");
00279 m_defServices.push_back("HistogramSvc/HistogramDataSvc");
00280 m_defServices.push_back("NTupleSvc/NTupleSvc");
00281 m_defServices.push_back("IncidentSvc/IncidentSvc");
00282 m_defServices.push_back("ToolSvc/ToolSvc");
00283
00284
00285 m_defServices.push_back("ChronoStatSvc/ChronoStatSvc");
00286 m_defServices.push_back("RndmGenSvc/RndmGenSvc");
00287 m_defServices.push_back("AuditorSvc/AuditorSvc");
00288
00289
00290 log << MSG::DEBUG << "Getting my own properties" << endreq;
00291 sc = jobOptionsSvc->setMyProperties( name(), this );
00292 if( !sc.isSuccess() ) {
00293 log << MSG::WARNING << "Problems getting my properties from JobOptionsSvc" << endreq;
00294 return sc;
00295 }
00296
00297 if ( m_histPersName == "ROOT" ) {
00298 m_defServices.push_back("RootHistCnv::PersSvc/HistogramPersistencySvc");
00299 }
00300 else if ( m_histPersName == "HBOOK" ) {
00301 m_defServices.push_back("HbookCnv::PersSvc/HistogramPersistencySvc");
00302 }
00303 else if ( m_histPersName == "NONE" ) {
00304 }
00305 else {
00306 log << MSG::WARNING << "Unknown Histogram Persistency Mechanism " << m_histPersName << endreq;
00307 }
00308
00309
00310
00311 State oldState = m_state;
00312 m_state = CONFIGURED;
00313 sc = decodeDllNameList( );
00314 m_state = oldState;
00315
00316
00317 m_topSvcNameList.insert( m_topSvcNameList.end(), m_defServices.begin(), m_defServices.end());
00318
00319
00320
00321
00322 for ( ListName::iterator its = m_topSvcNameList.begin(); its != m_topSvcNameList.end(); its++ ) {
00323 ListItem item(*its);
00324 if ( !i_connectService(item.type(), item.name()) ) {
00325 return StatusCode::FAILURE;
00326 }
00327 }
00328
00329
00330
00331
00332
00333 oldState = m_state;
00334 m_state = CONFIGURED;
00335 sc = decodeExtSvcNameList();
00336 m_state = oldState;
00337 if ( sc.isFailure( ) ) {
00338 log << MSG::ERROR << "Failure during external service creation" << endreq;
00339 return sc;
00340 }
00341
00342
00343
00344 i_connectService(m_runableType, m_runableType);
00345 sc = m_svcLocator->service( m_runableType, m_runable);
00346 if( !sc.isSuccess() ) {
00347 log << MSG::FATAL << "Error retrieving Runable:" << m_runableType << endreq;
00348 log << MSG::FATAL << "Check option ApplicationMgr." << s_runable << endreq;
00349 return sc;
00350 }
00351 i_connectService(m_eventLoopMgr, m_eventLoopMgr);
00352 sc = m_svcLocator->service( m_eventLoopMgr, m_processingMgr);
00353 if( !sc.isSuccess() ) {
00354 log << MSG::FATAL << "Error retrieving Processing manager:" << m_eventLoopMgr << endreq;
00355 log << MSG::FATAL << "Check option ApplicationMgr." << s_eventloop << endreq;
00356 log << MSG::ERROR << "Not events will be processed." << endreq;
00357 return sc;
00358 }
00359 sc = m_processingMgr->configure();
00360 if( !sc.isSuccess() ) {
00361 log << MSG::FATAL << "Error configuring Processing manager:" << m_eventLoopMgr << endreq;
00362 return sc;
00363 }
00364 log << MSG::INFO << "Application Manager Configured successfully" << endreq;
00365 m_state = CONFIGURED;
00366 return StatusCode::SUCCESS;
00367 }
00368
00369
00370
00371
00372 StatusCode ApplicationMgr::initialize() {
00373 MsgStream log( m_messageSvc, name() );
00374 StatusCode sc;
00375
00376 if( m_state == INITIALIZED ) {
00377 log << MSG::INFO << "Already Initialized!" << endreq;
00378 return StatusCode::SUCCESS;
00379 }
00380 else if( m_state != CONFIGURED ) {
00381 return StatusCode::FAILURE;
00382 }
00383
00384
00385
00386 for (ListSvc::iterator it = m_topSvcList.begin(); it != m_topSvcList.end(); it++ ) {
00387 sc = (*it)->initialize();
00388 if( !sc.isSuccess() ) {
00389 log << MSG::ERROR << "Unable to initialize Service: " << (*it)->name() << endreq;
00390 return sc;
00391 }
00392 }
00393
00394
00395
00396
00397
00398
00399 log << MSG::INFO << "Application Manager Initialized successfully" << endreq;
00400 m_state = INITIALIZED;
00401 return sc;
00402 }
00403
00404
00405
00406
00407 StatusCode ApplicationMgr::nextEvent(int maxevt) {
00408 if( m_state != INITIALIZED ) {
00409 MsgStream log( m_messageSvc, name() );
00410 log << MSG::FATAL << "Invalid initial state:" << state() << endreq;
00411 return StatusCode::FAILURE;
00412 }
00413 if ( 0 == m_processingMgr ) {
00414 MsgStream log( m_messageSvc, name() );
00415 log << MSG::FATAL << "No event processing manager specified. Check option:" << s_eventloop << endreq;
00416 return StatusCode::FAILURE;
00417 }
00418 return m_processingMgr->nextEvent(maxevt);
00419 }
00420
00421
00422
00423
00424 StatusCode ApplicationMgr::finalize() {
00425 MsgStream log( m_messageSvc, name() );
00426 StatusCode sc;
00427 if( m_state == FINALIZED ) {
00428 log << MSG::INFO << "Already Finalized" << endreq;
00429 return StatusCode::SUCCESS;
00430 }
00431 else if( m_state != INITIALIZED ) {
00432 log << MSG::FATAL << "Invalid initial state" << endreq;
00433 return StatusCode::FAILURE;
00434 }
00435
00436
00437
00438 ListSvc::reverse_iterator its;
00439 for ( its = m_topSvcList.rbegin(); its != m_topSvcList.rend(); its++ ) {
00440 sc = (*its)->finalize();
00441 if( !sc.isSuccess() ) {
00442 log << MSG::WARNING << "Finalization of service " << (*its)->name() << " failed" << endreq;
00443 }
00444 }
00445 sc = m_processingMgr->terminate();
00446 if( !sc.isSuccess() ) {
00447 log << MSG::FATAL << "Error terminating Processing manager:" << s_eventloop << endreq;
00448 return sc;
00449 }
00450
00451
00452
00453 for ( its = m_topSvcList.rbegin(); its != m_topSvcList.rend(); its++ ) {
00454 (*its)->release();
00455 }
00456 m_topSvcList.erase(m_topSvcList.begin(), m_topSvcList.end() );
00457 m_processingMgr = 0;
00458
00459 log << MSG::INFO << "Application Manager Finalized successfully" << endreq;
00460 m_state = FINALIZED;
00461 return StatusCode::SUCCESS;
00462 }
00463
00464
00465
00466
00467 StatusCode ApplicationMgr::terminate() {
00468 MsgStream log( m_messageSvc, name() );
00469
00470 if( m_state == OFFLINE ) {
00471 log << MSG::INFO << "Already Offline" << endreq;
00472 return StatusCode::SUCCESS;
00473 }
00474 else if( m_state != FINALIZED ) {
00475 log << MSG::FATAL << "Invalid initial state" << endreq;
00476 return StatusCode::FAILURE;
00477 }
00478
00479 log << MSG::INFO << "Application Manager Terminated successfully" << endreq;
00480 m_state = OFFLINE;
00481 return StatusCode::SUCCESS;
00482 }
00483
00484
00485
00486
00487 StatusCode ApplicationMgr::run() {
00488 StatusCode sc = configure();
00489 if( sc.isSuccess() ) {
00490 MsgStream log(m_messageSvc, name());
00491 sc = initialize();
00492 if( sc.isSuccess() ) {
00493 if ( 0 != m_runable ) {
00494 sc = m_runable->run();
00495 if( sc.isSuccess() ) {
00496 sc = finalize();
00497 if( sc.isSuccess() ) {
00498 return terminate();
00499 }
00500 log << MSG::FATAL << "Application finalization failed. Ending the job." << endreq;
00501 terminate();
00502 return sc;
00503 }
00504 log << MSG::FATAL << "Application execution failed. Ending the job." << endreq;
00505 finalize();
00506 terminate();
00507 return sc;
00508 }
00509 finalize();
00510 log << MSG::FATAL << "Application has no runable object. Check option:" << s_runable << endreq;
00511 }
00512 terminate();
00513 log << MSG::FATAL << "Application initilization failed" << endreq;
00514 return sc;
00515 }
00516 MsgStream elog( m_messageSvc, name() );
00517 elog << MSG::FATAL << "Application configuration failed" << endreq;
00518 return sc;
00519 }
00520
00521
00522
00523
00524 const std::string& ApplicationMgr::state() const {
00525 return m_stateName[m_state];
00526 }
00527
00528
00529
00530
00531 StatusCode ApplicationMgr::executeEvent(void* par) {
00532 if( m_state == INITIALIZED ) {
00533 SmartIF<IEventProcessor> processor(IID_IEventProcessor, m_processingMgr);
00534 if ( processor.isValid() ) {
00535 return processor->executeEvent(par);
00536 }
00537 }
00538 MsgStream log( m_messageSvc, name() );
00539 log << MSG::FATAL << "Invalid initial state:" << state() << endreq;
00540 return StatusCode::FAILURE;
00541 }
00542
00543
00544 StatusCode ApplicationMgr::getService( const std::string& name, IService*& svc) {
00545 return m_svcFactory->getService(name, svc);
00546 }
00547
00548
00549 StatusCode ApplicationMgr::getService( const std::string& name, const IID& iid, IInterface*& pinterface) {
00550 return m_svcFactory->getService(name, iid, pinterface);
00551 }
00552
00553
00554 StatusCode ApplicationMgr::getService( const std::string& name, IService*& svc, bool createIf) {
00555 return m_svcFactory->getService(name, svc, createIf);
00556 }
00557
00558
00559 std::list<IService*>& ApplicationMgr::getServices( ) const {
00560 return m_svcFactory->getServices( );
00561 }
00562
00563
00564 bool ApplicationMgr::existsService( const std::string& name) const {
00565 return m_svcFactory->existsService(name);
00566 }
00567
00568
00569 StatusCode ApplicationMgr::addService( IService* svc) {
00570 return m_svcFactory->addService(svc);
00571 }
00572
00573
00574 StatusCode ApplicationMgr::removeService( IService* svc) {
00575 return m_svcFactory->removeService(svc);
00576 }
00577
00578
00579 StatusCode ApplicationMgr::declareSvcCreator( ISvcManager::SvcCreator creator,
00580 const std::string& svctype ) {
00581 return m_svcFactory->declareSvcCreator( creator, svctype );
00582 }
00583
00584
00585 StatusCode ApplicationMgr::declareSvcModule( const std::string& module,
00586 const std::string& svctype ) {
00587 return m_svcFactory->declareSvcModule( module, svctype );
00588 }
00589
00590
00591 StatusCode ApplicationMgr::declareSvcFactory( const ISvcFactory& factory,
00592 const std::string& svctype ) {
00593 return m_svcFactory->declareSvcFactory( factory, svctype );
00594 }
00595
00596
00597 StatusCode ApplicationMgr::createService( const std::string& svctype,
00598 const std::string& svcname,
00599 IService*& svc) {
00600 return m_svcFactory->createService( svctype, svcname, svc );
00601 }
00602
00603
00604 const std::string& ApplicationMgr::name() const {
00605 return m_name;
00606 }
00607
00608
00609 StatusCode ApplicationMgr::setProperty(const Property& p) {
00610 return m_propertyMgr->setProperty( p );
00611 }
00612
00613 StatusCode ApplicationMgr::setProperty( std::istream& s ) {
00614 return m_propertyMgr->setProperty( s );
00615 }
00616
00617
00618 StatusCode ApplicationMgr::setProperty( const std::string& n, const std::string& v ) {
00619 return m_propertyMgr->setProperty( n, v );
00620 }
00621
00622
00623 StatusCode ApplicationMgr::getProperty(Property* p ) const {
00624 return m_propertyMgr->getProperty( p );
00625 }
00626
00627
00628 const Property& ApplicationMgr::getProperty( const std::string& name ) const{
00629 return m_propertyMgr->getProperty( name );
00630 }
00631
00632
00633 StatusCode ApplicationMgr::getProperty( const std::string& n, std::string& v ) const {
00634 return m_propertyMgr->getProperty( n, v );
00635 }
00636
00637
00638 const std::vector<Property*>& ApplicationMgr::getProperties( ) const {
00639 return m_propertyMgr->getProperties( );
00640 }
00641
00642
00643
00644
00645
00646 StatusCode ApplicationMgr::getAlgorithm( const std::string& name, IAlgorithm*& alg) const {
00647 return m_algFactory->getAlgorithm(name, alg);
00648 }
00649
00650
00651 bool ApplicationMgr::existsAlgorithm( const std::string& name) const {
00652 return m_algFactory->existsAlgorithm(name);
00653 }
00654
00655
00656 StatusCode ApplicationMgr::addAlgorithm( IAlgorithm* alg) {
00657 return m_algFactory->addAlgorithm(alg);
00658 }
00659
00660
00661 StatusCode ApplicationMgr::removeAlgorithm( IAlgorithm* alg) {
00662 return m_algFactory->removeAlgorithm(alg);
00663 }
00664
00665
00666 StatusCode ApplicationMgr::declareAlgCreator( IAlgManager::AlgCreator creator,
00667 const std::string& algtype ) {
00668 return m_algFactory->declareAlgCreator( creator, algtype );
00669 }
00670
00671
00672 StatusCode ApplicationMgr::declareAlgModule( const std::string& module,
00673 const std::string& algtype ) {
00674 return m_algFactory->declareAlgModule( module, algtype );
00675 }
00676
00677
00678 StatusCode ApplicationMgr::declareAlgFactory( const IAlgFactory& factory,
00679 const std::string& algtype ) {
00680 return m_algFactory->declareAlgFactory( factory, algtype );
00681 }
00682
00683
00684 StatusCode ApplicationMgr::createAlgorithm( const std::string& algtype,
00685 const std::string& algname,
00686 IAlgorithm*& alg) {
00687 return m_algFactory->createAlgorithm( algtype, algname, alg );
00688 }
00689
00690
00691 std::list<IAlgorithm*>& ApplicationMgr::getAlgorithms( ) const
00692 {
00693 return m_algFactory->getAlgorithms( );
00694 }
00695
00696
00697 StatusCode ApplicationMgr::declareCnvFactory( const ICnvFactory& factory ) {
00698 return m_cnvFactory->declareCnvFactory(factory);
00699 }
00700
00701
00702 bool ApplicationMgr::existsConverter( const unsigned char repSvcType,
00703 const CLID& objtype
00704 ) const {
00705 return m_cnvFactory->existsConverter( repSvcType, objtype);
00706 }
00707
00708
00709 const ICnvFactory* ApplicationMgr::factory( const unsigned char repSvctype,
00710 const CLID& objtype
00711 ) const
00712 {
00713 return m_cnvFactory->factory(repSvctype, objtype);
00714 }
00715
00716
00717 ICnvManager::CnvIterator ApplicationMgr::cnvBegin() {
00718 return m_cnvFactory->cnvBegin();
00719 }
00720
00721
00722 ICnvManager::CnvIterator ApplicationMgr::cnvEnd() {
00723 return m_cnvFactory->cnvEnd();
00724 }
00725
00726
00727 bool ApplicationMgr::existsObjFactory(const std::string& objtype) const {
00728 return m_objFactory->existsObjFactory( objtype);
00729 }
00730
00731
00732 const IFactory* ApplicationMgr::objFactory(const std::string& objtype) const {
00733 return m_objFactory->objFactory(objtype);
00734 }
00735
00736
00737 IObjManager::ObjIterator ApplicationMgr::objBegin() {
00738 return m_objFactory->objBegin();
00739 }
00740
00741
00742 IObjManager::ObjIterator ApplicationMgr::objEnd() {
00743 return m_objFactory->objEnd();
00744 }
00745
00746
00747 StatusCode ApplicationMgr::declareObjFactory( const IFactory& factory ) {
00748 return m_objFactory->declareObjFactory( factory );
00749 }
00750
00751
00752 StatusCode ApplicationMgr::declareFactory( const IFactory& factory ) {
00753 return m_classManager->declareFactory( factory );
00754 }
00755
00756
00757 StatusCode ApplicationMgr::loadModule( const std::string& module ) {
00758 return m_classManager->loadModule( module );
00759 }
00760
00761
00762
00763
00764 void ApplicationMgr::SIGoHandler( Property& ) {
00765 if ( 0 != m_runable ) {
00766 m_runable->run();
00767 return;
00768 }
00769 MsgStream log (m_messageSvc, name());
00770 log << MSG::FATAL << "Application has no runable object. Check option:" << s_runable << endreq;
00771 }
00772
00773
00774
00775
00776 void ApplicationMgr::SIExitHandler( Property& ) {
00777 StatusCode status;
00778 status = finalize();
00779 status = terminate();
00780 ::exit( 0 );
00781 }
00782
00783
00784
00785
00786 void ApplicationMgr::evtLoopPropertyHandler( Property& p ) {
00787 if ( m_processingMgr ) {
00788 SmartIF<IProperty> props(IID_IProperty, m_processingMgr);
00789 if ( props.isValid() ) {
00790 props->setProperty( p );
00791 }
00792 }
00793 }
00794
00795
00796
00797
00798 void ApplicationMgr::extSvcNameListHandler( Property& ) {
00799 decodeExtSvcNameList( );
00800 }
00801
00802
00803
00804
00805 StatusCode ApplicationMgr::decodeExtSvcNameList( ) {
00806 StatusCode result = StatusCode::SUCCESS;
00807 if ( CONFIGURED == m_state || INITIALIZED == m_state ) {
00808 ListSvc extSvcList;
00809 MsgStream log( m_messageSvc, m_name );
00810 const std::vector<std::string>& theNames = m_extSvcNameList.value( );
00811 for (VectorName::const_iterator it = theNames.begin(); it != theNames.end(); it++) {
00812 ListItem item(*it);
00813 if ( m_svcFactory->existsService(item.name()) ) {
00814 log << MSG::DEBUG << "Service " << item.name() << " Already exists" << endreq;
00815 }
00816 else {
00817 IService* svc = i_connectService(item.type(), item.name());
00818 if( !svc ) {
00819 return StatusCode::FAILURE;
00820 }
00821 extSvcList.push_back( svc );
00822 }
00823 }
00824 if ( INITIALIZED == m_state ) {
00825
00826 for (ListSvc::iterator its = extSvcList.begin(); its != extSvcList.end(); its++ ) {
00827 result = (*its)->initialize();
00828 if( result.isFailure() ) {
00829 log << MSG::ERROR << "Unable to initialize Service: " << (*its)->name() << endreq;
00830 return result;
00831 }
00832 }
00833 }
00834 }
00835 return result;
00836 }
00837
00838
00839
00840
00841 void ApplicationMgr::dllNameListHandler( Property& ) {
00842 decodeDllNameList();
00843 }
00844
00845
00846
00847
00848 StatusCode ApplicationMgr::decodeDllNameList() {
00849 StatusCode result = StatusCode::SUCCESS;
00850 if ( CONFIGURED == m_state || INITIALIZED == m_state ) {
00851 MsgStream log( m_messageSvc, m_name );
00852 log << MSG::DEBUG << "Loading declared DLL's" << endreq;
00853 const std::vector<std::string>& theNames = m_dllNameList.value( );
00854 std::vector<std::string>::const_iterator it;
00855 std::vector<std::string>::const_iterator itend = theNames.end( );
00856 for (it = theNames.begin(); it != itend; it++) {
00857 StatusCode status = m_classManager->loadModule( (*it) );
00858 if( status.isFailure() ) {
00859 log << MSG::WARNING << "Unable to load DLL " << (*it) << endreq;
00860 }
00861 }
00862 }
00863 return result;
00864 }
00865