|
bool | genComponent (const std::string &libName, const std::string &componentName, component_t componentType, const vector< PropertyBase * > &properties, const std::vector< std::string > &interfaces) |
|
void | genImport (std::ostream &s, std::string_view 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, string &ptype2) |
| handle the "marshalling" of Properties More...
|
|
Definition at line 166 of file genconf.cpp.
◆ configGenerator()
configGenerator::configGenerator |
( |
const string & |
pkgName, |
|
|
const string & |
outputDirName |
|
) |
| |
|
inline |
◆ genBody()
◆ genComponent()
Definition at line 667 of file genconf.cpp.
672 auto cname = pythonizeName( componentName );
677 m_db2Buf <<
" '" << componentName <<
"': {\n";
678 m_db2Buf <<
" '__component_type__': '";
679 switch ( componentType ) {
680 case component_t::Algorithm:
683 case component_t::AlgTool:
686 case component_t::ApplicationMgr:
687 case component_t::Service:
690 case component_t::Auditor:
696 m_db2Buf <<
"',\n '__interfaces__': (";
698 if ( ignored_interfaces.find( intf ) ==
end( ignored_interfaces ) ) {
m_db2Buf <<
'\'' << intf <<
"', "; }
700 m_db2Buf <<
"),\n 'properties': {\n";
703 m_pyBuf <<
" __slots__ = { \n";
705 const string&
pname = prop->name();
707 if ( !boost::regex_match(
pname, pythonIdentifier ) ) {
708 std::cout <<
"ERROR: invalid property name \"" <<
pname <<
"\" in component " << cname
709 <<
" (invalid Python identifier)" <<
std::endl;
711 m_pyBuf <<
" #ERROR-invalid identifier '" <<
pname <<
"'\n"
716 string pvalue, ptype, ptype2;
718 m_pyBuf <<
" '" <<
pname <<
"' : " << pvalue <<
", # " << ptype <<
"\n";
720 m_db2Buf <<
" '" <<
pname <<
"': ('" << ptype2 <<
"', " << pvalue <<
", '''" << prop->documentation()
721 <<
" [" << prop->ownerTypeName() <<
"]'''";
722 auto sem = prop->semantics();
723 if ( !sem.empty() ) {
m_db2Buf <<
", '" << sem <<
'\''; }
726 if ( prop->documentation() !=
"none" ) {
727 propDoc.
emplace_back(
pname, prop->documentation() +
" [" + prop->ownerTypeName() +
"]" );
731 m_pyBuf <<
" _propertyDocDct = { \n";
732 for (
const auto& prop : propDoc ) {
734 <<
"\"\"\" " << prop.second <<
" \"\"\",\n";
738 m_pyBuf <<
" def __init__(self, name = " <<
m_configurable[component_t::DefaultName] <<
", **kwargs):\n"
739 <<
" super(" << cname <<
", self).__init__(name)\n"
740 <<
" for n,v in kwargs.items():\n"
741 <<
" setattr(self, n, v)\n"
742 <<
" def getDlls( self ):\n"
743 <<
" return '" << libName <<
"'\n"
744 <<
" def getType( self ):\n"
745 <<
" return '" << componentName <<
"'\n"
746 <<
" pass # class " << cname <<
"\n"
751 const string modName = fs::basename(
fs::path( pyName ).leaf() );
◆ genConfig()
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
write-out files for this library
Definition at line 431 of file genconf.cpp.
434 const auto endLib = libs.end();
436 static const std::string gaudiSvc =
"GaudiCoreSvc";
437 const bool isGaudiSvc =
439 return s.find( gaudiSvc ) != std::string::npos;
444 cout <<
"ERROR: ApplicationMgr can not be created. Check environment" <<
endl;
449 using Gaudi::PluginService::Details::Registry;
450 const Registry&
registry = Registry::instance();
452 auto bkgNames =
registry.loadedFactoryNames();
461 for (
const auto& iLib : libs ) {
463 if ( lib.
compare( 0, 3,
"lib" ) == 0 ) {
466 LOG_INFO <<
":::: processing library: " << iLib <<
"...";
485 for (
const auto& factoryName :
registry.loadedFactoryNames() ) {
486 if ( bkgNames.find( factoryName ) != bkgNames.end() ) {
488 LOG_INFO <<
"\t==> skipping [" << factoryName <<
"]...";
492 auto entry =
factories.find( factoryName );
494 LOG_ERROR <<
"inconsistency in component factories list: I cannot find anymore " << factoryName;
497 const auto& info = entry->second;
498 if ( !info.is_set() )
continue;
501 if ( !info.getprop(
"ReflexName" ).empty() )
continue;
507 if ( libNativeName( lib ) != info.library ) {
508 LOG_WARNING <<
"library [" << lib <<
"] exposes factory [" << factoryName <<
"] which is declared in ["
509 << info.library <<
"] !!";
513 component_t
type = component_t::Unknown;
515 const auto ft = allowedFactories.find( info.factory.type().name() );
516 if ( ft != allowedFactories.end() ) {
518 }
else if ( factoryName ==
"ApplicationMgr" ) {
519 type = component_t::ApplicationMgr;
527 const auto className = info.getprop(
"ClassName" );
531 string cname =
"DefaultName";
535 case component_t::Algorithm:
538 case component_t::Service:
541 case component_t::AlgTool:
547 case component_t::Auditor:
550 case component_t::ApplicationMgr:
557 LOG_ERROR <<
"Error instantiating " <<
name <<
" from " << iLib;
562 LOG_ERROR <<
"Error instantiating " <<
name <<
" from " << iLib;
567 if ( !
genComponent( lib,
name,
type, prop->getProperties(), prop->getInterfaceNames() ) ) { allGood =
false; }
570 LOG_ERROR <<
"could not cast IInterface* object to an IProperty* !";
571 LOG_ERROR <<
"NO Configurable will be generated for [" <<
name <<
"] !";
586 if ( !userModule.
empty() ) py <<
"from " << userModule <<
" import *" <<
endl;
601 return allGood ? EXIT_SUCCESS : EXIT_FAILURE;
◆ genHeader()
Definition at line 635 of file genconf.cpp.
641 <<
"\"\"\"Automatically generated. DO NOT EDIT please\"\"\"\n"
643 <<
"if sys.version_info >= (3,):\n"
644 <<
" # Python 2 compatibility\n"
651 genImport( py,
"from {}.Configurable import *" );
654 db <<
"## -*- ascii -*- \n"
655 <<
"# db file automatically generated by genconf on: " << now <<
"\n"
◆ genImport()
Definition at line 604 of file genconf.cpp.
606 std::string::size_type pos = 0, nxtpos = 0;
609 while ( std::string::npos != pos ) {
611 nxtpos =
m_configurable[component_t::Module].find_first_of(
',', pos );
620 if ( std::string::npos == nxtpos ) {
622 s << indent <<
import.str() <<
"\n" <<
flush;
623 pos = std::string::npos;
626 s << indent <<
"try:\n" << indent << py_tab <<
import.str() <<
"\n" << indent <<
"except ImportError:\n" <<
flush;
◆ genTrailer()
◆ pythonizeValue()
handle the "marshalling" of Properties
Definition at line 762 of file genconf.cpp.
769 if ( ti == typeIndex<bool>() ) {
770 pvalue = ( cvalue ==
"0" || cvalue ==
"False" || cvalue ==
"false" ) ?
"False" :
"True";
772 }
else if ( ti == typeIndex<char>() || ti == typeIndex<signed char>() || ti == typeIndex<unsigned char>() ||
773 ti == typeIndex<short>() || ti == typeIndex<unsigned short>() || ti == typeIndex<int>() ||
774 ti == typeIndex<unsigned int>() || ti == typeIndex<long>() || ti == typeIndex<unsigned long>() ||
775 ti == typeIndex<long long>() || ti == typeIndex<unsigned long long>() ) {
778 }
else if ( ti == typeIndex<float>() || ti == typeIndex<double>() ) {
780 pvalue = boost::to_lower_copy( cvalue );
781 if ( std::string::npos != pvalue.
find(
"nan" ) ) {
782 pvalue =
"float('nan')";
783 std::cout <<
"WARNING: default value for [" << p->name() <<
"] is NaN !!" <<
std::endl;
784 }
else if ( std::string::npos == pvalue.
find(
"." ) && std::string::npos == pvalue.
find(
"e" ) ) {
785 pvalue = cvalue +
".0";
788 }
else if ( ti == typeIndex<string>() ) {
789 pvalue = quote( cvalue );
791 }
else if ( ti == typeIndex<GaudiHandleBase>() ) {
796 ptype =
"GaudiHandle";
799 }
else if ( ti == typeIndex<GaudiHandleArrayBase>() ) {
804 ptype =
"GaudiHandleArray";
812 ptype =
"DataHandle";
816 v_str.
setf( std::ios::showpoint );
817 p->toStream( v_str );
818 pvalue = v_str.
str();
◆ setConfigurableAlgorithm()
void configGenerator::setConfigurableAlgorithm |
( |
const std::string & |
cfgAlgorithm | ) |
|
|
inline |
◆ setConfigurableAlgTool()
void configGenerator::setConfigurableAlgTool |
( |
const std::string & |
cfgAlgTool | ) |
|
|
inline |
◆ setConfigurableAuditor()
void configGenerator::setConfigurableAuditor |
( |
const std::string & |
cfgAuditor | ) |
|
|
inline |
◆ setConfigurableDefaultName()
void configGenerator::setConfigurableDefaultName |
( |
const std::string & |
defaultName | ) |
|
|
inline |
customize the default name for configurable instances
Definition at line 211 of file genconf.cpp.
◆ setConfigurableModule()
void configGenerator::setConfigurableModule |
( |
const std::string & |
moduleName | ) |
|
|
inline |
customize the Module name where configurable base classes are defined
Definition at line 208 of file genconf.cpp.
◆ setConfigurableService()
void configGenerator::setConfigurableService |
( |
const std::string & |
cfgService | ) |
|
|
inline |
◆ m_configurable
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 195 of file genconf.cpp.
◆ m_db2Buf
◆ 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,...
Definition at line 186 of file genconf.cpp.
◆ m_importDataHandles
bool configGenerator::m_importDataHandles = false |
|
private |
◆ m_importGaudiHandles
bool configGenerator::m_importGaudiHandles = false |
|
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 179 of file genconf.cpp.
◆ m_outputDirName
string configGenerator::m_outputDirName |
|
private |
absolute path to the directory where genconf will store auto-generated files (Configurables and ConfigurableDb)
Definition at line 172 of file genconf.cpp.
◆ m_pkgName
string configGenerator::m_pkgName |
|
private |
name of the package we are processing
Definition at line 168 of file genconf.cpp.
◆ m_pyBuf
buffer of auto-generated configurables
Definition at line 175 of file genconf.cpp.
The documentation for this class was generated from the following file:
void genTrailer(std::ostream &pyOut, std::ostream &dbOut)
std::string pythonRepr() const override
Python representation of array of handles, i.e.
GAUDI_API unsigned long loadDynamicLib(const std::string &name, ImageHandle *handle)
Load dynamic link library.
const GaudiHandleArrayBase & value() const
void reset(TYPE *ptr=nullptr)
Set the internal pointer to the passed one disposing of the old one.
DataHandleProperty.h GaudiKernel/DataHandleProperty.h.
void * ImageHandle
Definition of an image handle.
GAUDI_API const std::string typeinfoName(const std::type_info &)
Get platform independent information about the class type.
stringstream m_dbBuf
buffer of generated configurables informations for the "Db" file The "Db" file is holding information...
bool m_importGaudiHandles
switch to decide if the generated configurables need to import GaudiHandles (ie: if one of the compon...
stringstream m_pyBuf
buffer of auto-generated configurables
GAUDI_API ISvcLocator * svcLocator()
bool genComponent(const std::string &libName, const std::string &componentName, component_t componentType, const vector< PropertyBase * > &properties, const std::vector< std::string > &interfaces)
std::string format(bool local, std::string spec="%c") const
Format the time using strftime.
double * begin(CLHEP::HepVector &v)
void pythonizeValue(const PropertyBase *prop, string &pvalue, string &ptype, string &ptype2)
handle the "marshalling" of Properties
std::string pythonRepr() const override
Python representation of handle, i.e.
GAUDI_API std::string format(const char *,...)
MsgStream format utility "a la sprintf(...)".
const GaudiHandleBase & value() const
string m_pkgName
name of the package we are processing
void genImport(std::ostream &s, std::string_view frmt, std::string indent)
std::map< component_t, std::string > m_configurable
Configurable customization.
GAUDI_API const std::string & moduleName()
Get the name of the (executable/DLL) file without file-type.
Base class of array's of various gaudihandles.
std::string toString(const TYPE &obj)
the generic implementation of the type conversion to the string
T emplace_back(T... args)
std::string pythonPropertyClassName() const override
Name of the componentType with "Handle" appended.
GAUDIPS_API Logger & logger()
Return the current logger instance.
void genHeader(std::ostream &pyOut, std::ostream &dbOut)
static Time current()
Returns the current time.
virtual std::string pythonRepr() const
string m_outputDirName
absolute path to the directory where genconf will store auto-generated files (Configurables and Confi...
std::string pythonPropertyClassName() const override
Name of the componentType with "HandleArray" appended.
virtual unsigned long release()=0
Release Interface instance.
GAUDI_API const std::string getLastErrorString()
Get last system error as string.
void genBody(std::ostream &pyOut, std::ostream &dbOut)
virtual unsigned long addRef()=0
Increment the reference count of Interface instance.