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