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
497 if ( err != 1 ) {
499 allGood = false;
500 continue;
501 }
502
504 for (
const auto& factoryName :
registry.loadedFactoryNames() ) {
505 if ( bkgNames.find( factoryName ) != bkgNames.end() ) {
506 if ( Gaudi::PluginService::Details::logger().
level() <= 1 ) {
507 LOG_INFO <<
"\t==> skipping [" << factoryName <<
"]...";
508 }
509 continue;
510 }
511 auto entry =
factories.find( factoryName );
512 if ( entry ==
end( factories ) ) {
513 LOG_ERROR <<
"inconsistency in component factories list: I cannot find anymore " << factoryName;
514 continue;
515 }
516 const auto& info = entry->second;
517 if ( !info.is_set() ) continue;
518
519
520 if ( !info.getprop( "ReflexName" ).empty() ) continue;
521
522
523
524
525
526 if ( libNativeName( lib ) != info.library ) {
527 LOG_WARNING <<
"library [" << lib <<
"] exposes factory [" << factoryName <<
"] which is declared in ["
528 << info.library << "] !!";
529 continue;
530 }
531
532 component_t
type = component_t::Unknown;
533 {
534 const auto ft = allowedFactories.find( info.factory.type().name() );
535 if ( ft != allowedFactories.end() ) {
537 } else if ( factoryName == "ApplicationMgr" ) {
538 type = component_t::ApplicationMgr;
539 } else
540 continue;
541 }
542
543
544 std::string
name = boost::trim_copy( factoryName );
545
546 const auto className = info.getprop( "ClassName" );
547 LOG_INFO <<
" - component: " << className <<
" (" << ( className !=
name ? (
name +
": " ) : std::string() )
548 << type << ")";
549
550 string cname = "DefaultName";
551 SmartIF<IProperty> prop;
552 try {
553 switch ( type ) {
554 case component_t::Algorithm:
555 prop = SmartIF<IAlgorithm>( Gaudi::Algorithm::Factory::create( factoryName, cname, svcLoc ).
release() );
556 break;
557 case component_t::Service:
558 prop = SmartIF<IService>( Service::Factory::create( factoryName, cname, svcLoc ).
release() );
559 break;
560 case component_t::AlgTool:
561 prop =
562 SmartIF<IAlgTool>( AlgTool::Factory::create( factoryName, cname,
toString( type ), dummySvc ).
release() );
563
564 prop->release();
565 break;
566 case component_t::Auditor:
567 prop = SmartIF<Gaudi::IAuditor>( Gaudi::Auditor::Factory::create( factoryName, cname, svcLoc ).
release() );
568 break;
569 case component_t::ApplicationMgr:
570 prop = SmartIF<ISvcLocator>( svcLoc );
571 break;
572 default:
573 continue;
574 }
575 } catch ( exception& e ) {
576 LOG_ERROR <<
"Error instantiating " <<
name <<
" from " << iLib;
577 LOG_ERROR <<
"Got exception: " << e.what();
578 allGood = false;
579 continue;
580 } catch ( ... ) {
581 LOG_ERROR <<
"Error instantiating " <<
name <<
" from " << iLib;
582 allGood = false;
583 continue;
584 }
585 if ( prop ) {
587 allGood = false;
588 }
590 !
genComponent2( name, type, prop->getProperties(), prop->getInterfaceNames(), info ) ) {
591 allGood = false;
592 }
594 } else {
595 LOG_ERROR <<
"could not cast IInterface* object to an IProperty* !";
596 LOG_ERROR <<
"NO Configurable will be generated for [" <<
name <<
"] !";
597 allGood = false;
598 }
599 }
600
605 const std::string pyName = ( fs::path(
m_outputDirName ) / fs::path( lib +
"Conf.py" ) ).
string();
606 const std::string dbName = ( fs::path(
m_outputDirName ) / fs::path( lib +
".confdb" ) ).
string();
607
608 std::fstream py( pyName, std::ios_base::out | std::ios_base::trunc );
609 std::fstream db( dbName, std::ios_base::out | std::ios_base::trunc );
610
612 if ( !userModule.empty() ) py << "from " << userModule << " import *" << endl;
615 }
617 const std::string db2Name = ( fs::path(
m_outputDirName ) / fs::path( lib +
".confdb2_part" ) ).
string();
618 std::fstream db2( db2Name, std::ios_base::out | std::ios_base::trunc );
619 db2 <<
"{\n" <<
m_db2Buf.str() <<
"}\n";
620 }
621
622 }
623
625 dummySvc = 0;
626
627 return allGood ? EXIT_SUCCESS : EXIT_FAILURE;
628}
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.