450{
451 const auto endLib = libs.end();
452
453 static const std::string gaudiSvc = "GaudiCoreSvc";
454 const bool isGaudiSvc =
455 std::find_if( libs.begin(), endLib, []( const auto& s ) {
456 return s.find( gaudiSvc ) != std::string::npos;
457 } ) != endLib;
458
459
461 cout << "ERROR: ApplicationMgr can not be created. Check environment" << endl;
462 return EXIT_FAILURE;
463 }
464
465
466 using Gaudi::PluginService::Details::Registry;
467 const Registry&
registry = Registry::instance();
468
469 auto bkgNames =
registry.loadedFactoryNames();
470
472 IInterface* dummySvc = new Service( "DummySvc", svcLoc );
474
475 bool allGood = true;
476
477
478 for ( const auto& iLib : libs ) {
479 std::string lib = fs::path( iLib ).stem().string();
480 if ( lib.compare( 0, 3, "lib" ) == 0 ) {
481 lib = lib.substr( 3 );
482 }
483 LOG_INFO <<
":::: processing library: " << iLib <<
"...";
484
485
491
492
493 if ( !
registry.loadPluginLibrary( iLib ) ) {
495 allGood = false;
496 continue;
497 }
498
500 for (
const auto& factoryName :
registry.loadedFactoryNames() ) {
501 if ( bkgNames.find( factoryName ) != bkgNames.end() ) {
502 if ( Gaudi::PluginService::Details::logger().
level() <= 1 ) {
503 LOG_INFO <<
"\t==> skipping [" << factoryName <<
"]...";
504 }
505 continue;
506 }
507 auto entry =
factories.find( factoryName );
508 if ( entry ==
end( factories ) ) {
509 LOG_ERROR <<
"inconsistency in component factories list: I cannot find anymore " << factoryName;
510 continue;
511 }
512 const auto& info = entry->second;
513 if ( !info.is_set() ) continue;
514
515
516 if ( !info.getprop( "ReflexName" ).empty() ) continue;
517
518
519
520
521
522 if ( libNativeName( lib ) != info.library ) {
523 LOG_WARNING <<
"library [" << lib <<
"] exposes factory [" << factoryName <<
"] which is declared in ["
524 << info.library << "] !!";
525 continue;
526 }
527
528 component_t
type = component_t::Unknown;
529 {
530 const auto ft = allowedFactories.find( info.factory.type().name() );
531 if ( ft != allowedFactories.end() ) {
533 } else if ( factoryName == "ApplicationMgr" ) {
534 type = component_t::ApplicationMgr;
535 } else
536 continue;
537 }
538
539
540 std::string
name = boost::trim_copy( factoryName );
541
542 const auto className = info.getprop( "ClassName" );
543 LOG_INFO <<
" - component: " << className <<
" (" << ( className !=
name ? (
name +
": " ) : std::string() )
544 << type << ")";
545
546 string cname = "DefaultName";
547 SmartIF<IProperty> prop;
548 try {
549 switch ( type ) {
550 case component_t::Algorithm:
551 prop = SmartIF<IAlgorithm>( Gaudi::Algorithm::Factory::create( factoryName, cname, svcLoc ).
release() );
552 break;
553 case component_t::Service:
554 prop = SmartIF<IService>( Service::Factory::create( factoryName, cname, svcLoc ).
release() );
555 break;
556 case component_t::AlgTool:
557 prop =
558 SmartIF<IAlgTool>( AlgTool::Factory::create( factoryName, cname,
toString( type ), dummySvc ).
release() );
559
560 prop->release();
561 break;
562 case component_t::Auditor:
563 prop = SmartIF<Gaudi::IAuditor>( Gaudi::Auditor::Factory::create( factoryName, cname, svcLoc ).
release() );
564 break;
565 case component_t::ApplicationMgr:
566 prop = SmartIF<ISvcLocator>( svcLoc );
567 break;
568 default:
569 continue;
570 }
571 } catch ( exception& e ) {
572 LOG_ERROR <<
"Error instantiating " <<
name <<
" from " << iLib;
573 LOG_ERROR <<
"Got exception: " << e.what();
574 allGood = false;
575 continue;
576 } catch ( ... ) {
577 LOG_ERROR <<
"Error instantiating " <<
name <<
" from " << iLib;
578 allGood = false;
579 continue;
580 }
581 if ( prop ) {
583 allGood = false;
584 }
586 !
genComponent2( name, type, prop->getProperties(), prop->getInterfaceNames(), info ) ) {
587 allGood = false;
588 }
590 } else {
591 LOG_ERROR <<
"could not cast IInterface* object to an IProperty* !";
592 LOG_ERROR <<
"NO Configurable will be generated for [" <<
name <<
"] !";
593 allGood = false;
594 }
595 }
596
601 const std::string pyName = ( fs::path(
m_outputDirName ) / fs::path( lib +
"Conf.py" ) ).
string();
602 const std::string dbName = ( fs::path(
m_outputDirName ) / fs::path( lib +
".confdb" ) ).
string();
603
604 std::fstream py( pyName, std::ios_base::out | std::ios_base::trunc );
605 std::fstream db( dbName, std::ios_base::out | std::ios_base::trunc );
606
608 if ( !userModule.empty() ) py << "from " << userModule << " import *" << endl;
611 }
613 const std::string db2Name = ( fs::path(
m_outputDirName ) / fs::path( lib +
".confdb2_part" ) ).
string();
614 std::fstream db2( db2Name, std::ios_base::out | std::ios_base::trunc );
615 db2 <<
"{\n" <<
m_db2Buf.str() <<
"}\n";
616 }
617
618 }
619
621 dummySvc = 0;
622
623 return allGood ? EXIT_SUCCESS : EXIT_FAILURE;
624}
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.