| The Gaudi Framework v29r1 (5cd95fa2)

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Member Functions | Private Member Functions | Private Attributes | List of all members
configGenerator Class Reference
Collaboration diagram for configGenerator:
[legend]

## Public Member Functions
| configGenerator (const string &pkgName, const string &outputDirName)
int | genConfig (const Strings_t &modules, const string &userModule)
| main entry point of this class: More...
void | setConfigurableModule (const std::string &moduleName)
| customize the Module name where configurable base classes are defined More...
void | setConfigurableDefaultName (const std::string &defaultName)
| customize the default name for configurable instances More...
void | setConfigurableAlgorithm (const std::string &cfgAlgorithm)
| customize the configurable base class for Algorithm component More...
void | setConfigurableAlgTool (const std::string &cfgAlgTool)
| customize the configurable base class for AlgTool component More...
void | setConfigurableAuditor (const std::string &cfgAuditor)
| customize the configurable base class for AlgTool component More...
void | setConfigurableService (const std::string &cfgService)
| customize the configurable base class for Service component More...

## Private Member Functions
int | genComponent (const std::string &libName, const std::string &componentName, const std::string &componentType, const vector< PropertyBase * > &properties)
void | genImport (std::ostream &s, const boost::format &frmt, std::string indent)
void | genHeader (std::ostream &pyOut, std::ostream &dbOut)
void | genBody (std::ostream &pyOut, std::ostream &dbOut)
void | genTrailer (std::ostream &pyOut, std::ostream &dbOut)
void | pythonizeValue (const PropertyBase *prop, string &pvalue, string &ptype)
| handle the "marshalling" of Properties More...
void | pythonizeName (string &name)
| Translates a valid C++ typename into a valid python one. More...

## Private Attributes
string | m_pkgName
| name of the package we are processing More...
string | m_outputDirName
| absolute path to the directory where genconf will store auto-generated files (Configurables and ConfigurableDb) More...
stringstream | m_pyBuf
| buffer of auto-generated configurables More...
bool | m_importGaudiHandles
| switch to decide if the generated configurables need to import GaudiHandles (ie: if one of the components has a XyzHandle<T>) More...
bool | m_importDataObjectHandles
stringstream | m_dbBuf
| buffer of generated configurables informations for the "Db" file The "Db" file is holding informations about the generated configurables This file is later one used by the PropertyProxy.py to locate Configurables and know their default values, host module,... More...
GaudiUtils::HashMap< std::string, std::string > | m_configurable
| Configurable customization. More...

## Detailed Description

Definition at line 97 of file genconf.cpp.

## Constructor & Destructor Documentation

configGenerator::configGenerator | ( | const string & | pkgName,
|  | const string & | outputDirName
| ) |  |
| inline

Definition at line 129 of file genconf.cpp.

130 : m_pkgName( pkgName )
131 , m_outputDirName( outputDirName )
132 , m_pyBuf()
133 , m_importGaudiHandles( false )
134 , m_importDataObjectHandles( false )
135 , m_dbBuf()
136 , m_configurable()
137 {
138 }
configGenerator::m_configurable
GaudiUtils::HashMap< std::string, std::string > m_configurable
Configurable customization.
Definition: genconf.cpp:126
configGenerator::m_pyBuf
stringstream m_pyBuf
buffer of auto-generated configurables
Definition: genconf.cpp:107
configGenerator::m_importDataObjectHandles
bool m_importDataObjectHandles
Definition: genconf.cpp:113
configGenerator::m_dbBuf
stringstream m_dbBuf
buffer of generated configurables informations for the "Db" file The "Db" file is holding information...
Definition: genconf.cpp:119
configGenerator::m_outputDirName
string m_outputDirName
absolute path to the directory where genconf will store auto-generated files (Configurables and Confi...
Definition: genconf.cpp:104
configGenerator::m_importGaudiHandles
bool m_importGaudiHandles
switch to decide if the generated configurables need to import GaudiHandles (ie: if one of the compon...
Definition: genconf.cpp:111
configGenerator::m_pkgName
string m_pkgName
name of the package we are processing
Definition: genconf.cpp:100

## Member Function Documentation

void configGenerator::genBody | ( | std::ostream & | pyOut,
|  | std::ostream & | dbOut
| ) |  |
| inline private

Definition at line 173 of file genconf.cpp.

174 {
175 pyOut << m_pyBuf.str() << flush;
176 dbOut << m_dbBuf.str() << flush;
177 }
configGenerator::m_pyBuf
stringstream m_pyBuf
buffer of auto-generated configurables
Definition: genconf.cpp:107
std::stringstream::str
T str(T...args)
configGenerator::m_dbBuf
stringstream m_dbBuf
buffer of generated configurables informations for the "Db" file The "Db" file is holding information...
Definition: genconf.cpp:119
std::flush
T flush(T...args)

int configGenerator::genComponent | ( | const std::string & | libName,
|  | const std::string & | componentName,
|  | const std::string & | componentType,
|  | const vector< PropertyBase * > & | properties
| ) |  |
| private

Definition at line 645 of file genconf.cpp.

648 {
649 string cname = componentName;
650 pythonizeName( cname );
651
652 typedef GaudiUtils::HashMap<std::string, std::string> PropertyDoc_t;
653 PropertyDoc_t propDoc;
654
655 m_pyBuf << "\n";
656 m_pyBuf << "class " << cname << "( " << m_configurable[componentType] << " ) :"
657 << "\n";
658 m_pyBuf << " __slots__ = { \n";
659 for ( vector<PropertyBase*>::const_iterator it = properties.begin(); it != properties.end(); ++it ) {
660
661 const string pname = ( *it )->name();
662 // Validate property name (it must be a valid Python identifier)
663 if ( !boost::regex_match( pname, pythonIdentifier ) ) {
664 std::cout << "ERROR: invalid property name \"" << pname << "\" in component " << cname
665 << " (invalid Python identifier)" << std::endl;
666 // try to make the buffer at least more or less valid python code.
667 m_pyBuf << " #ERROR-invalid identifier '" << pname << "'\n"
668 << " }\n";
669 return 1;
670 }
671
672 string pvalue, ptype;
673 pythonizeValue( ( *it ), pvalue, ptype );
674 m_pyBuf << " '" << pname << "' : " << pvalue << ", # " << ptype << "\n";
675
676 if ( ( *it )->documentation() != "none" ) {
677 propDoc[pname] = ( *it )->documentation() + " [" + ( *it )->ownerTypeName() + "]";
678 }
679 }
680 m_pyBuf << " }\n";
681 m_pyBuf << " _propertyDocDct = { \n";
682 for ( PropertyDoc_t::const_iterator iProp = propDoc.begin(); iProp != propDoc.end(); ++iProp ) {
683 m_pyBuf << std::setw( 5 ) << "'" << iProp->first << "' : "
684 << "\"\"\" " << iProp->second << " \"\"\",\n";
685 }
686 m_pyBuf << " }\n";
687
688 m_pyBuf << " def __init__(self, name = " << m_configurable["DefaultName"] << ", **kwargs):\n"
689 << " super(" << cname << ", self).__init__(name)\n"
690 << " for n,v in kwargs.items():\n"
691 << " setattr(self, n, v)\n"
692 << " def getDlls( self ):\n"
693 << " return '" << libName << "'\n"
694 << " def getType( self ):\n"
695 << " return '" << componentName << "'\n"
696 << " pass # class " << cname << "\n"
697 << flush;
698
699 // name of the auto-generated module
700 const string pyName = ( fs::path( m_outputDirName ) / fs::path( libName + "Conf.py" ) ).string();
701 const string modName = fs::basename( fs::path( pyName ).leaf() );
702
703 // now the db part
704 m_dbBuf << m_pkgName << "." << modName << " " << libName << " " << cname << "\n" << flush;
705
706 return 0;
707 }
GaudiPython.HistoUtils.path
path
Definition: HistoUtils.py:895
configGenerator::pythonizeName
void pythonizeName(string &name)
Translates a valid C++ typename into a valid python one.
Definition: genconf.cpp:709
std::endl
T endl(T...args)
std::vector::end
T end(T...args)
configGenerator::m_configurable
GaudiUtils::HashMap< std::string, std::string > m_configurable
Configurable customization.
Definition: genconf.cpp:126
configGenerator::m_pyBuf
stringstream m_pyBuf
buffer of auto-generated configurables
Definition: genconf.cpp:107
std::setw
T setw(T...args)
configGenerator::m_dbBuf
stringstream m_dbBuf
buffer of generated configurables informations for the "Db" file The "Db" file is holding information...
Definition: genconf.cpp:119
compareOutputFiles.pname
pname
Definition: compareOutputFiles.py:442
std::flush
T flush(T...args)
configGenerator::m_outputDirName
string m_outputDirName
absolute path to the directory where genconf will store auto-generated files (Configurables and Confi...
Definition: genconf.cpp:104
std::vector
STL class.
configGenerator::pythonizeValue
void pythonizeValue(const PropertyBase *prop, string &pvalue, string &ptype)
handle the "marshalling" of Properties
Definition: genconf.cpp:721
std::vector::begin
T begin(T...args)
GaudiUtils::HashMap< std::string, std::string >
configGenerator::m_pkgName
string m_pkgName
name of the package we are processing
Definition: genconf.cpp:100
std::cout
svn_tag_release.basename
def basename(url)
Definition: svn_tag_release.py:28

int configGenerator::genConfig | ( | const Strings_t & | modules,
|  | const string & | userModule
| ) |  |

main entry point of this class:

- iterate over all the modules (ie: library names)
- for each module extract component informations
- eventually generate the header/body/trailer python file and "Db" file

not enough information... skip it

no Properties, so don't bother create Configurables...

write-out files for this library

Definition at line 399 of file genconf.cpp.

401 {
402 //--- Disable checking StatusCode -------------------------------------------
403 StatusCode::disableChecking();
404
405 const Strings_t::const_iterator endLib = libs.end();
406
407 const std::string gaudiSvc = "GaudiCoreSvc";
408 const bool isGaudiSvc = ( std::find( libs.begin(), endLib, gaudiSvc ) != endLib );
409
410 //--- Instantiate ApplicationMgr --------------------------------------------
411 if ( !isGaudiSvc && createAppMgr() ) {
412 cout << "ERROR: ApplicationMgr can not be created. Check environment" << endl;
413 return EXIT_FAILURE;
414 }
415
416 //--- Iterate over component factories --------------------------------------
417 using Gaudi::PluginService::Details::Registry;
418 Registry& registry = Registry::instance();
419
420 std::set<std::string> bkgNames = registry.loadedFactories();
421
422 ISvcLocator* svcLoc = Gaudi::svcLocator();
423 IInterface* dummySvc = new Service( "DummySvc", svcLoc );
424 dummySvc->addRef();
425
426 bool allGood = true;
427
428 // iterate over all the requested libraries
429 for ( Strings_t::const_iterator iLib = libs.begin(); iLib != endLib; ++iLib ) {
430
431 LOG_INFO << ":::: processing library: " << *iLib << "...";
432
433 // reset state
434 m_importGaudiHandles = false;
435 m_importDataObjectHandles = false;
436 m_pyBuf.str( "" );
437 m_dbBuf.str( "" );
438
439 //--- Load component library ----------------------------------------------
440 System::ImageHandle handle;
441 unsigned long err = System::loadDynamicLib( *iLib, &handle );
442 if ( err != 1 ) {
443 LOG_ERROR << System::getLastErrorString();
444 allGood = false;
445 continue;
446 }
447
448 std::set<std::string> factories = registry.loadedFactories();
449
450 for ( std::set<std::string>::iterator it = factories.begin(); it != factories.end(); ++it ) {
451 const string ident = *it;
452 if ( bkgNames.find( ident ) != bkgNames.end() ) {
453 if ( Gaudi::PluginService::Details::logger().level() <= 1 ) {
454 LOG_INFO << "\t==> skipping [" << ident << "]...";
455 }
456 continue;
457 }
458
459 const Registry::FactoryInfo info = registry.getInfo( *it );
460 const string rtype = info.rtype;
461
462 // do not generate configurables for the Reflex-compatible aliases
463 if ( info.properties.find( "ReflexName" ) != info.properties.end() ) continue;
464
465 // Atlas contributed code (patch #1247)
466 // Skip the generation of configurables if the component does not come
467 // from the same library we are processing (i.e. we found a symbol that
468 // is coming from a library loaded by the linker).
469 if ( !DsoUtils::inDso( info.ptr, DsoUtils::libNativeName( *iLib ) ) ) {
470 LOG_WARNING << "library [" << *iLib << "] exposes factory [" << ident << "] which is declared in ["
471 << DsoUtils::dsoName( info.ptr ) << "] !!";
472 continue;
473 }
474
475 string type;
476 bool known = true;
477 if ( ident == "ApplicationMgr" )
478 type = "ApplicationMgr";
479 else if ( rtype == typeid( IInterface* ).name() )
480 type = "IInterface";
481 else if ( rtype == typeid( IAlgorithm* ).name() )
482 type = "Algorithm";
483 else if ( rtype == typeid( IService* ).name() )
484 type = "Service";
485 else if ( rtype == typeid( IAlgTool* ).name() )
486 type = "AlgTool";
487 else if ( rtype == typeid( IAuditor* ).name() )
488 type = "Auditor";
489 else if ( rtype == typeid( IConverter* ).name() )
490 type = "Converter";
491 else if ( rtype == typeid( DataObject* ).name() )
492 type = "DataObject";
493 else
494 type = "Unknown", known = false;
495 string name = ident;
496 // handle possible problems with templated components
497 boost::trim( name );
498
499 if ( type == "IInterface" ) {
502 continue;
503 }
504
505 if ( type == "Converter" || type == "DataObject" ) {
507 continue;
508 }
509
510 if ( !known ) {
511 LOG_WARNING << "Unknown (return) type [" << System::typeinfoName( rtype.c_str() ) << "] !!"
512 << " Component [" << ident << "] is skipped !";
513 continue;
514 }
515
516 LOG_INFO << " - component: " << info.className << " ("
517 << ( info.className != name ? ( name + ": " ) : std::string() ) << type << ")";
518
519 string cname = "DefaultName";
520 SmartIF<IProperty> prop;
521 try {
522 if ( type == "Algorithm" ) {
523 prop = SmartIF<IAlgorithm>( Algorithm::Factory::create( ident, cname, svcLoc ) );
524 } else if ( type == "Service" ) {
525 prop = SmartIF<IService>( Service::Factory::create( ident, cname, svcLoc ) );
526 } else if ( type == "AlgTool" ) {
527 prop = SmartIF<IAlgTool>( AlgTool::Factory::create( ident, cname, type, dummySvc ) );
528 // FIXME: AlgTool base class increase artificially by 1 the refcount.
529 prop->release();
530 } else if ( type == "Auditor" ) {
531 prop = SmartIF<IAuditor>( Auditor::Factory::create( ident, cname, svcLoc ) );
532 } else if ( type == "ApplicationMgr" ) {
533 prop = SmartIF<ISvcLocator>( svcLoc );
534 } else {
535 continue; // unknown
536 }
537 } catch ( exception& e ) {
538 LOG_ERROR << "Error instantiating " << name << " from " << *iLib;
539 LOG_ERROR << "Got exception: " << e.what();
540 allGood = false;
541 continue;
542 } catch ( ... ) {
543 LOG_ERROR << "Error instantiating " << name << " from " << *iLib;
544 allGood = false;
545 continue;
546 }
547 if ( prop ) {
548 if ( genComponent( *iLib, name, type, prop->getProperties() ) ) {
549 allGood = false;
550 }
551 prop.reset();
552 } else {
553 LOG_ERROR << "could not cast IInterface* object to an IProperty* !";
554 LOG_ERROR << "return type from PluginSvc is [" << rtype << "]...";
555 LOG_ERROR << "NO Configurable will be generated for [" << name << "] !";
556 allGood = false;
557 }
558 } //> end loop over factories
559
563 const std::string pyName = ( fs::path( m_outputDirName ) / fs::path( *iLib + "Conf.py" ) ).string();
564 const std::string dbName = ( fs::path( m_outputDirName ) / fs::path( *iLib + ".confdb" ) ).string();
565
566 std::fstream py( pyName, std::ios_base::out | std::ios_base::trunc );
567 std::fstream db( dbName, std::ios_base::out | std::ios_base::trunc );
568
569 genHeader( py, db );
570 if ( !userModule.empty() ) py << "from " << userModule << " import *" << endl;
571 genBody( py, db );
572 genTrailer( py, db );
573
574 } //> end loop over libraries
575
576 dummySvc->release();
577 dummySvc = 0;
578
579 return allGood ? EXIT_SUCCESS : EXIT_FAILURE;
580 }
SmartIF< IProperty >
std::string::empty
T empty(T...args)
ISvcLocator
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
Definition: ISvcLocator.h:25
IConverter
The data converters are responsible to translate data from one representation into another...
Definition: IConverter.h:58
GaudiPython.HistoUtils.path
path
Definition: HistoUtils.py:895
gaudiComponentHelp.name
name
Definition: gaudiComponentHelp.py:32
System::typeinfoName
GAUDI_API const std::string typeinfoName(const std::type_info &)
Get platform independent information about the class type.
Definition: System.cpp:329
Gaudi::PluginService::Details::Logger::level
Level level() const
Definition: PluginServiceDetails.h:230
LOG_ERROR
#define LOG_ERROR
Definition: genconf.cpp:74
std::endl
T endl(T...args)
std::set::end
T end(T...args)
System::ImageHandle
void * ImageHandle
Definition of an image handle.
Definition: ModuleInfo.h:31
configGenerator::m_pyBuf
stringstream m_pyBuf
buffer of auto-generated configurables
Definition: genconf.cpp:107
Gaudi::PluginService::Details::logger
GAUDIPS_API Logger & logger()
Return the current logger instance.
Definition: PluginService.cpp:345
configGenerator::genComponent
int genComponent(const std::string &libName, const std::string &componentName, const std::string &componentType, const vector< PropertyBase * > &properties)
Definition: genconf.cpp:645
std::string
STL class.
configGenerator::m_importDataObjectHandles
bool m_importDataObjectHandles
Definition: genconf.cpp:113
Gaudi::svcLocator
GAUDI_API ISvcLocator * svcLocator()
std::exception::what
T what(T...args)
LOG_INFO
#define LOG_INFO
Definition: genconf.cpp:76
IService
General service interface definition.
Definition: IService.h:18
IInterface
Definition of the basic interface.
Definition: IInterface.h:277
gaudirun.type
type
Definition: gaudirun.py:133
std::fstream
STL class.
configGenerator::genHeader
void genHeader(std::ostream &pyOut, std::ostream &dbOut)
Definition: genconf.cpp:614
std::stringstream::str
T str(T...args)
GaudiPluginService.cpluginsvc.registry
def registry()
Definition: cpluginsvc.py:70
configGenerator::m_dbBuf
stringstream m_dbBuf
buffer of generated configurables informations for the "Db" file The "Db" file is holding information...
Definition: genconf.cpp:119
std::exception
STL class.
IAlgorithm
The IAlgorithm is the interface implemented by the Algorithm base class.
Definition: IAlgorithm.h:28
IProperty::getProperties
virtual const std::vector< Gaudi::Details::PropertyBase * > & getProperties() const =0
Get list of properties.
std::find
T find(T...args)
std::set< std::string >
configGenerator::m_outputDirName
string m_outputDirName
absolute path to the directory where genconf will store auto-generated files (Configurables and Confi...
Definition: genconf.cpp:104
IInterface::release
virtual unsigned long release()=0
Release Interface instance.
LOG_WARNING
#define LOG_WARNING
Definition: genconf.cpp:75
std::set::begin
T begin(T...args)
configGenerator::m_importGaudiHandles
bool m_importGaudiHandles
switch to decide if the generated configurables need to import GaudiHandles (ie: if one of the compon...
Definition: genconf.cpp:111
std::string::c_str
T c_str(T...args)
IAlgTool
The interface implemented by the AlgTool base class.
Definition: IAlgTool.h:23
Gaudi::PluginService::Details::Registry
In-memory database of the loaded factories.
Definition: PluginServiceDetails.h:112
GaudiPluginService.cpluginsvc.factories
def factories()
Definition: cpluginsvc.py:80
IInterface::addRef
virtual unsigned long addRef()=0
Increment the reference count of Interface instance.
StatusCode::disableChecking
static GAUDI_API void disableChecking()
Definition: StatusCode.cpp:21
SmartIF::reset
void reset(TYPE *ptr=nullptr)
Set the internal pointer to the passed one disposing of the old one.
Definition: SmartIF.h:92
configGenerator::genTrailer
void genTrailer(std::ostream &pyOut, std::ostream &dbOut)
Definition: genconf.cpp:637
System::getLastErrorString
GAUDI_API const std::string getLastErrorString()
Get last system error as string.
Definition: System.cpp:291
Service
Base class for all services.
Definition: Service.h:36
DataObject
A DataObject is the base class of any identifiable object on any data store.
Definition: DataObject.h:29
createAppMgr
int createAppMgr()
Definition: genconf.cpp:782
IAuditor
The IAuditor is the interface implmented by the AlgAuditor base class.
Definition: IAuditor.h:18
std::cout
DsoUtils::libNativeName
std::string libNativeName(const std::string &libName)
Definition: DsoUtils.h:19
configGenerator::genBody
void genBody(std::ostream &pyOut, std::ostream &dbOut)
Definition: genconf.cpp:173
System::loadDynamicLib
GAUDI_API unsigned long loadDynamicLib(const std::string &name, ImageHandle *handle)
Load dynamic link library.
Definition: System.cpp:147

void configGenerator::genHeader | ( | std::ostream & | pyOut,
|  | std::ostream & | dbOut
| ) |  |
| private

Definition at line 614 of file genconf.cpp.

616 {
617 // python file part
618 std::string now = Gaudi::Time::current().format( true );
619 py << "#" << now //<< "\n"
620 << "\"\"\"Automatically generated. DO NOT EDIT please\"\"\"\n";
621 if ( m_importGaudiHandles ) {
622 py << "from GaudiKernel.GaudiHandles import *\n";
623 }
624
625 if ( m_importDataObjectHandles ) {
626 py << "from GaudiKernel.DataObjectHandleBase import *\n";
627 }
628
629 genImport( py, boost::format( "from %1%.Configurable import *" ) );
630
631 // db file part
632 db << "## -*- ascii -*- \n"
633 << "# db file automatically generated by genconf on: " << now << "\n"
634 << flush;
635 }
format
GAUDI_API std::string format(const char *,...)
MsgStream format utility "a la sprintf(...)".
Definition: MsgStream.cpp:120
Gaudi::Time::current
static Time current()
Returns the current time.
Definition: Time.cpp:112
std::string
STL class.
configGenerator::m_importDataObjectHandles
bool m_importDataObjectHandles
Definition: genconf.cpp:113
std::flush
T flush(T...args)
configGenerator::genImport
void genImport(std::ostream &s, const boost::format &frmt, std::string indent)
Definition: genconf.cpp:582
configGenerator::m_importGaudiHandles
bool m_importGaudiHandles
switch to decide if the generated configurables need to import GaudiHandles (ie: if one of the compon...
Definition: genconf.cpp:111
Gaudi::Time::format
std::string format(bool local, std::string spec="%c") const
Format the time using strftime.
Definition: Time.cpp:260

void configGenerator::genImport | ( | std::ostream & | s,
|  | const boost::format & | frmt,
|  | std::string | indent = `""`
| ) |  |
| private

Definition at line 582 of file genconf.cpp.

583 {
584
585 std::string::size_type pos = 0, nxtpos = 0;
586 std::string mod;
587
588 while ( std::string::npos != pos ) {
589 // find end of module name
590 nxtpos = m_configurable["Module"].find_first_of( ',', pos );
591
592 // Prepare import string
593 mod = m_configurable["Module"].substr( pos, nxtpos - pos );
594 std::ostringstream import;
595 import << boost::format( frmt ) % mod;
596
597 // append a normal import or a try/except enclosed one depending
598 // on availability of a fall-back module (next in the list)
599 if ( std::string::npos == nxtpos ) {
600 // last possible module
601 s << indent << import.str() << "\n" << flush;
602 pos = std::string::npos;
603 } else {
604 // we have a fallback for this
605 s << indent << "try:\n" << indent << py_tab << import.str() << "\n" << indent << "except ImportError:\n" << flush;
606 pos = nxtpos + 1;
607 }
608 // increase indentation level for next iteration
609 indent += py_tab;
610 }
611 }
format
GAUDI_API std::string format(const char *,...)
MsgStream format utility "a la sprintf(...)".
Definition: MsgStream.cpp:120
Gaudi.CommonGaudiConfigurables.mod
mod
Definition: CommonGaudiConfigurables.py:22
configGenerator::m_configurable
GaudiUtils::HashMap< std::string, std::string > m_configurable
Configurable customization.
Definition: genconf.cpp:126
std::string
STL class.
std::ostringstream
STL class.
std::flush
T flush(T...args)

void configGenerator::genTrailer | ( | std::ostream & | pyOut,
|  | std::ostream & | dbOut
| ) |  |
| private

Definition at line 637 of file genconf.cpp.

639 {
640 // db file part
641 db << "## " << m_pkgName << "\n" << std::flush;
642 }
std::flush
T flush(T...args)
configGenerator::m_pkgName
string m_pkgName
name of the package we are processing
Definition: genconf.cpp:100

void configGenerator::pythonizeName | ( | string & | name | ) |
| private

Translates a valid C++ typename into a valid python one.

Definition at line 709 of file genconf.cpp.

711 {
712 static string in( "<>&*,: ()." );
713 static string out( "__rp__s___" );
714 boost::algorithm::replace_all( name, ", ", "," );
715 for ( string::iterator i = name.begin(); i != name.end(); ++i ) {
716 if ( in.find( *i ) != string::npos ) *i = out[in.find( *i )];
717 }
718 }
std::string::end
T end(T...args)
std::string::begin
T begin(T...args)

void configGenerator::pythonizeValue | ( | const PropertyBase * | prop,
|  | string & | pvalue,
|  | string & | ptype
| ) |  |
| private

handle the "marshalling" of Properties

Definition at line 721 of file genconf.cpp.

723 {
724 const std::string cvalue = p->toString();
725 const type_info& ti = *p->type_info();
726 if ( ti == typeid( bool ) ) {
727 pvalue = ( cvalue == "0" || cvalue == "False" || cvalue == "false" ) ? "False" : "True";
728 ptype = "bool";
729 } else if ( ti == typeid( char ) || ti == typeid( signed char ) || ti == typeid( unsigned char ) ||
730 ti == typeid( short ) || ti == typeid( unsigned short ) || ti == typeid( int ) ||
731 ti == typeid( unsigned int ) || ti == typeid( long ) || ti == typeid( unsigned long ) ) {
732 pvalue = cvalue;
733 ptype = "int";
734 } else if ( ti == typeid( long long ) || ti == typeid( unsigned long long ) ) {
735 pvalue = cvalue + "L";
736 ptype = "long";
737 } else if ( ti == typeid( float ) || ti == typeid( double ) ) {
738 // forces python to handle this as a float: put a dot in there...
739 pvalue = boost::to_lower_copy( cvalue );
740 if ( pvalue == "nan" ) {
741 pvalue = "float('nan')";
742 std::cout << "WARNING: default value for [" << p->name() << "] is NaN !!" << std::endl;
743 } else if ( std::string::npos == pvalue.find( "." ) && std::string::npos == pvalue.find( "e" ) ) {
744 pvalue = cvalue + ".0";
745 }
746 ptype = "float";
747 } else if ( ti == typeid( string ) ) {
748
749 pvalue = "'" + cvalue + "'";
750 ptype = "str";
751 } else if ( ti == typeid( GaudiHandleBase ) ) {
752 m_importGaudiHandles = true;
753 const GaudiHandleProperty& hdl = dynamic_cast<const GaudiHandleProperty&>( *p );
754 const GaudiHandleBase& base = hdl.value();
755
756 pvalue = base.pythonRepr();
757 ptype = "GaudiHandle";
758 } else if ( ti == typeid( GaudiHandleArrayBase ) ) {
759 m_importGaudiHandles = true;
760 const GaudiHandleArrayProperty& hdl = dynamic_cast<const GaudiHandleArrayProperty&>( *p );
761 const GaudiHandleArrayBase& base = hdl.value();
762
763 pvalue = base.pythonRepr();
764 ptype = "GaudiHandleArray";
765 } else if ( ti == typeid( DataObjectHandleBase ) ) {
766 m_importDataObjectHandles = true;
767 const DataObjectHandleProperty& hdl = dynamic_cast<const DataObjectHandleProperty&>( *p );
768 const DataObjectHandleBase& base = hdl.value();
769
770 pvalue = base.pythonRepr();
771 ptype = "DataObjectHandleBase";
772 } else {
773 std::ostringstream v_str;
774 v_str.setf( std::ios::showpoint ); // to correctly display floats
775 p->toStream( v_str );
776 pvalue = v_str.str();
777 ptype = "list";
778 }
779 }
std::ostringstream::setf
T setf(T...args)
std::endl
T endl(T...args)
GaudiHandleProperty
Definition: Property.h:829
DataObjectHandleProperty
DataObjectHandleProperty.h GaudiKernel/DataObjectHandleProperty.h.
Definition: DataObjectHandleProperty.h:23
std::type_info
std::string
STL class.
configGenerator::m_importDataObjectHandles
bool m_importDataObjectHandles
Definition: genconf.cpp:113
std::ostringstream
STL class.
GaudiHandleProperty::value
const GaudiHandleBase & value() const
Definition: Property.h:852
std::ostringstream::str
T str(T...args)
GaudiHandleArrayProperty::value
const GaudiHandleArrayBase & value() const
Definition: Property.h:892
GaudiHandleArrayBase::pythonRepr
std::string pythonRepr() const override
Python representation of array of handles, i.e.
Definition: GaudiHandle.cpp:86
std::string::find
T find(T...args)
GaudiHandleArrayBase
Base class of array&#39;s of various gaudihandles.
Definition: GaudiHandle.h:348
DataObjectHandleBase
DataObjectHandleBase GaudiKernel/DataObjectHandleBase.h.
Definition: DataObjectHandleBase.h:25
GaudiHandleBase::pythonRepr
std::string pythonRepr() const override
Python representation of handle, i.e.
Definition: GaudiHandle.cpp:53
configGenerator::m_importGaudiHandles
bool m_importGaudiHandles
switch to decide if the generated configurables need to import GaudiHandles (ie: if one of the compon...
Definition: genconf.cpp:111
DataObjectHandleBase::pythonRepr
std::string pythonRepr() const override
Definition: DataObjectHandleBase.cpp:118
DataObjectHandleProperty::value
const DataObjectHandleBase & value() const
Definition: DataObjectHandleProperty.cpp:94
GaudiHandleBase
Base class to handles to be used in lieu of naked pointers to various Gaudi components.
Definition: GaudiHandle.h:83
GaudiHandleArrayProperty
Definition: Property.h:869
std::cout

void configGenerator::setConfigurableAlgorithm | ( | const std::string & | cfgAlgorithm | ) |
| inline

customize the configurable base class for Algorithm component

Definition at line 153 of file genconf.cpp.

153 { m_configurable["Algorithm"] = cfgAlgorithm; }
configGenerator::m_configurable
GaudiUtils::HashMap< std::string, std::string > m_configurable
Configurable customization.
Definition: genconf.cpp:126

void configGenerator::setConfigurableAlgTool | ( | const std::string & | cfgAlgTool | ) |
| inline

customize the configurable base class for AlgTool component

Definition at line 156 of file genconf.cpp.

156 { m_configurable["AlgTool"] = cfgAlgTool; }
configGenerator::m_configurable
GaudiUtils::HashMap< std::string, std::string > m_configurable
Configurable customization.
Definition: genconf.cpp:126

void configGenerator::setConfigurableAuditor | ( | const std::string & | cfgAuditor | ) |
| inline

customize the configurable base class for AlgTool component

Definition at line 159 of file genconf.cpp.

159 { m_configurable["Auditor"] = cfgAuditor; }
configGenerator::m_configurable
GaudiUtils::HashMap< std::string, std::string > m_configurable
Configurable customization.
Definition: genconf.cpp:126

void configGenerator::setConfigurableDefaultName | ( | const std::string & | defaultName | ) |
| inline

customize the default name for configurable instances

Definition at line 150 of file genconf.cpp.

150 { m_configurable["DefaultName"] = defaultName; }
configGenerator::m_configurable
GaudiUtils::HashMap< std::string, std::string > m_configurable
Configurable customization.
Definition: genconf.cpp:126

void configGenerator::setConfigurableModule | ( | const std::string & | moduleName | ) |
| inline

customize the Module name where configurable base classes are defined

Definition at line 147 of file genconf.cpp.

147 { m_configurable["Module"] = moduleName; }
configGenerator::m_configurable
GaudiUtils::HashMap< std::string, std::string > m_configurable
Configurable customization.
Definition: genconf.cpp:126
System::moduleName
GAUDI_API const std::string & moduleName()
Get the name of the (executable/DLL) file without file-type.
Definition: ModuleInfo.cpp:54

void configGenerator::setConfigurableService | ( | const std::string & | cfgService | ) |
| inline

customize the configurable base class for Service component

Definition at line 162 of file genconf.cpp.

163 {
164 m_configurable["Service"] = cfgService;
165 m_configurable["ApplicationMgr"] = cfgService;
166 }
configGenerator::m_configurable
GaudiUtils::HashMap< std::string, std::string > m_configurable
Configurable customization.
Definition: genconf.cpp:126

## Member Data Documentation

GaudiUtils::HashMap<std::string, std::string> configGenerator::m_configurable
| private

Configurable customization.

Contains customization for:

- Name of the module where configurable base classes are defined
- Name of the configurable base class for the Algorithm component
- Name of the configurable base class for the AlgTool component
- Name of the configurable base class for the Service component

Definition at line 126 of file genconf.cpp.

stringstream configGenerator::m_dbBuf
| private

buffer of generated configurables informations for the "Db" file The "Db" file is holding informations about the generated configurables This file is later one used by the PropertyProxy.py to locate Configurables and know their default values, host module,...

Definition at line 119 of file genconf.cpp.

bool configGenerator::m_importDataObjectHandles
| private

Definition at line 113 of file genconf.cpp.

bool configGenerator::m_importGaudiHandles
| private

switch to decide if the generated configurables need to import GaudiHandles (ie: if one of the components has a XyzHandle<T>)

Definition at line 111 of file genconf.cpp.

string configGenerator::m_outputDirName
| private

absolute path to the directory where genconf will store auto-generated files (Configurables and ConfigurableDb)

Definition at line 104 of file genconf.cpp.

string configGenerator::m_pkgName
| private

name of the package we are processing

Definition at line 100 of file genconf.cpp.

stringstream configGenerator::m_pyBuf
| private

buffer of auto-generated configurables

Definition at line 107 of file genconf.cpp.

The documentation for this class was generated from the following file:

- GaudiKernel/src/Util/genconf.cpp