449{
450 const auto endLib = libs.end();
451
452 static const std::string gaudiSvc = "GaudiCoreSvc";
453 const bool isGaudiSvc =
454 std::find_if( libs.begin(), endLib, []( const auto& s ) {
455 return s.find( gaudiSvc ) != std::string::npos;
456 } ) != endLib;
457
458
460 cout << "ERROR: ApplicationMgr can not be created. Check environment" << endl;
461 return EXIT_FAILURE;
462 }
463
464
465 using Gaudi::PluginService::Details::Registry;
466 const Registry&
registry = Registry::instance();
467
468 auto bkgNames =
registry.loadedFactoryNames();
469
471 IInterface* dummySvc = new Service( "DummySvc", svcLoc );
473
474 bool allGood = true;
475
476
477 for ( const auto& iLib : libs ) {
478 std::string lib = fs::path( iLib ).stem().string();
479 if ( lib.compare( 0, 3, "lib" ) == 0 ) {
480 lib = lib.substr( 3 );
481 }
482 LOG_INFO <<
":::: processing library: " << iLib <<
"...";
483
484
490
491
492 if ( !
registry.loadPluginLibrary( iLib ) ) {
494 allGood = false;
495 continue;
496 }
497
499 for (
const auto& factoryName :
registry.loadedFactoryNames() ) {
500 if ( bkgNames.find( factoryName ) != bkgNames.end() ) {
501 if ( Gaudi::PluginService::Details::logger().
level() <= 1 ) {
502 LOG_INFO <<
"\t==> skipping [" << factoryName <<
"]...";
503 }
504 continue;
505 }
506 auto entry =
factories.find( factoryName );
507 if ( entry ==
end( factories ) ) {
508 LOG_ERROR <<
"inconsistency in component factories list: I cannot find anymore " << factoryName;
509 continue;
510 }
511 const auto& info = entry->second;
512 if ( !info.is_set() ) continue;
513
514
515 if ( !info.getprop( "ReflexName" ).empty() ) continue;
516
517
518
519
520
521 if ( libNativeName( lib ) != info.library ) {
522 LOG_WARNING <<
"library [" << lib <<
"] exposes factory [" << factoryName <<
"] which is declared in ["
523 << info.library << "] !!";
524 continue;
525 }
526
527 component_t
type = component_t::Unknown;
528 {
529 const auto ft = allowedFactories.find( info.factory.type().name() );
530 if ( ft != allowedFactories.end() ) {
532 } else if ( factoryName == "ApplicationMgr" ) {
533 type = component_t::ApplicationMgr;
534 } else
535 continue;
536 }
537
538
539 std::string
name = boost::trim_copy( factoryName );
540
541 const auto className = info.getprop( "ClassName" );
542 LOG_INFO <<
" - component: " << className <<
" (" << ( className !=
name ? (
name +
": " ) : std::string() )
543 << type << ")";
544
545 string cname = "DefaultName";
546 SmartIF<IProperty> prop;
547 try {
548 switch ( type ) {
549 case component_t::Algorithm:
550 prop = SmartIF<IAlgorithm>( Gaudi::Algorithm::Factory::create( factoryName, cname, svcLoc ).
release() );
551 break;
552 case component_t::Service:
553 prop = SmartIF<IService>( Service::Factory::create( factoryName, cname, svcLoc ).
release() );
554 break;
555 case component_t::AlgTool:
556 prop =
557 SmartIF<IAlgTool>( AlgTool::Factory::create( factoryName, cname,
toString( type ), dummySvc ).
release() );
558
559 prop->release();
560 break;
561 case component_t::Auditor:
562 prop = SmartIF<Gaudi::IAuditor>( Gaudi::Auditor::Factory::create( factoryName, cname, svcLoc ).
release() );
563 break;
564 case component_t::ApplicationMgr:
565 prop = SmartIF<ISvcLocator>( svcLoc );
566 break;
567 default:
568 continue;
569 }
570 } catch ( exception& e ) {
571 LOG_ERROR <<
"Error instantiating " <<
name <<
" from " << iLib;
572 LOG_ERROR <<
"Got exception: " << e.what();
573 allGood = false;
574 continue;
575 } catch ( ... ) {
576 LOG_ERROR <<
"Error instantiating " <<
name <<
" from " << iLib;
577 allGood = false;
578 continue;
579 }
580 if ( prop ) {
582 allGood = false;
583 }
585 !
genComponent2( name, type, prop->getProperties(), prop->getInterfaceNames(), info ) ) {
586 allGood = false;
587 }
589 } else {
590 LOG_ERROR <<
"could not cast IInterface* object to an IProperty* !";
591 LOG_ERROR <<
"NO Configurable will be generated for [" <<
name <<
"] !";
592 allGood = false;
593 }
594 }
595
600 const std::string pyName = ( fs::path(
m_outputDirName ) / fs::path( lib +
"Conf.py" ) ).
string();
601 const std::string dbName = ( fs::path(
m_outputDirName ) / fs::path( lib +
".confdb" ) ).
string();
602
603 std::fstream py( pyName, std::ios_base::out | std::ios_base::trunc );
604 std::fstream db( dbName, std::ios_base::out | std::ios_base::trunc );
605
607 if ( !userModule.empty() ) py << "from " << userModule << " import *" << endl;
610 }
612 const std::string db2Name = ( fs::path(
m_outputDirName ) / fs::path( lib +
".confdb2_part" ) ).
string();
613 std::fstream db2( db2Name, std::ios_base::out | std::ios_base::trunc );
614 db2 <<
"{\n" <<
m_db2Buf.str() <<
"}\n";
615 }
616
617 }
618
620 dummySvc = 0;
621
622 return allGood ? EXIT_SUCCESS : EXIT_FAILURE;
623}
virtual unsigned long addRef() const =0
Increment the reference count of Interface instance.
virtual unsigned long release() const =0
Release Interface instance.
void reset(TYPE *ptr=nullptr)
Set the internal pointer to the passed one disposing of the old one.
void genHeader(std::ostream &pyOut, std::ostream &dbOut)
std::set< conf_t > m_confTypes
Types of configurables to generate.
bool m_importGaudiHandles
switch to decide if the generated configurables need to import GaudiHandles (ie: if one of the compon...
void genTrailer(std::ostream &pyOut, std::ostream &dbOut)
bool genComponent2(const std::string &componentName, component_t componentType, const vector< PropertyBase * > &properties, const std::vector< std::string > &interfaces, const Gaudi::PluginService::Details::Registry::FactoryInfo &info)
void genBody(std::ostream &pyOut, std::ostream &dbOut)
bool genComponent(const std::string &libName, const std::string &componentName, component_t componentType, const vector< PropertyBase * > &properties, const Gaudi::PluginService::Details::Registry::FactoryInfo &info)
std::string toString(const TYPE &obj)
the generic implementation of the type conversion to the string
GAUDI_API ISvcLocator * svcLocator()
GAUDI_API const std::string getLastErrorString()
Get last system error as string.