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