|
bool | genComponent (const std::string &libName, 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 | 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) |
| handle the "marshalling" of Properties More...
|
|
Definition at line 175 of file genconf.cpp.
◆ configGenerator()
configGenerator::configGenerator |
( |
const string & |
pkgName, |
|
|
const string & |
outputDirName |
|
) |
| |
|
inline |
◆ genBody()
◆ genComponent()
Definition at line 679 of file genconf.cpp.
685 auto cname = pythonizeName( componentName );
686 const auto decl_loc = info.getprop(
"declaration_location" );
691 m_db2Buf <<
" '" << componentName <<
"': {\n";
692 m_db2Buf <<
" '__component_type__': '";
693 switch ( componentType ) {
694 case component_t::Algorithm:
697 case component_t::AlgTool:
700 case component_t::ApplicationMgr:
701 case component_t::Service:
704 case component_t::Auditor:
710 if ( !decl_loc.empty() ) {
m_db2Buf <<
"',\n '__declaration_location__': '" << decl_loc; }
711 m_db2Buf <<
"',\n '__interfaces__': (";
713 if ( ignored_interfaces.find( intf ) ==
end( ignored_interfaces ) ) {
m_db2Buf <<
'\'' << intf <<
"', "; }
715 m_db2Buf <<
"),\n 'properties': {\n";
718 m_pyBuf <<
" __slots__ = { \n";
720 const string&
pname = prop->name();
722 if ( !boost::regex_match(
pname, pythonIdentifier ) ) {
723 std::cout <<
"ERROR: invalid property name \"" <<
pname <<
"\" in component " << cname
724 <<
" (invalid Python identifier)" <<
std::endl;
726 m_pyBuf <<
" #ERROR-invalid identifier '" <<
pname <<
"'\n"
731 string pvalue, ptype;
735 m_db2Buf <<
" '" <<
pname <<
"': ('" << ptype <<
"', " << pvalue <<
", '''" << prop->documentation()
736 <<
" [" << prop->ownerTypeName() <<
"]'''";
737 auto sem = prop->semantics();
738 if ( !sem.empty() ) {
m_db2Buf <<
", '" << sem <<
'\''; }
741 if ( prop->documentation() !=
"none" ) {
742 propDoc.
emplace_back(
pname, prop->documentation() +
" [" + prop->ownerTypeName() +
"]" );
746 m_pyBuf <<
" _propertyDocDct = { \n";
747 for (
const auto& prop : propDoc ) {
749 <<
"\"\"\" " << prop.second <<
" \"\"\",\n";
753 if ( !decl_loc.empty() ) {
m_pyBuf <<
" __declaration_location__ = '" << decl_loc <<
"'\n"; }
754 m_pyBuf <<
" def __init__(self, name = " <<
m_configurable[component_t::DefaultName] <<
", **kwargs):\n"
755 <<
" super(" << cname <<
", self).__init__(name)\n"
756 <<
" for n,v in kwargs.items():\n"
757 <<
" setattr(self, n, v)\n"
758 <<
" def getDlls( self ):\n"
759 <<
" return '" << libName <<
"'\n"
760 <<
" def getType( self ):\n"
761 <<
" return '" << componentName <<
"'\n"
762 <<
" pass # class " << cname <<
"\n"
767 const string modName =
fs::path( pyName ).filename().stem().string();
◆ 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 441 of file genconf.cpp.
444 const auto endLib = libs.end();
446 static const std::string gaudiSvc =
"GaudiCoreSvc";
447 const bool isGaudiSvc =
449 return s.find( gaudiSvc ) != std::string::npos;
454 cout <<
"ERROR: ApplicationMgr can not be created. Check environment" <<
endl;
459 using Gaudi::PluginService::Details::Registry;
460 const Registry&
registry = Registry::instance();
462 auto bkgNames =
registry.loadedFactoryNames();
471 for (
const auto& iLib : libs ) {
473 if ( lib.
compare( 0, 3,
"lib" ) == 0 ) {
476 LOG_INFO <<
":::: processing library: " << iLib <<
"...";
495 for (
const auto& factoryName :
registry.loadedFactoryNames() ) {
496 if ( bkgNames.find( factoryName ) != bkgNames.end() ) {
498 LOG_INFO <<
"\t==> skipping [" << factoryName <<
"]...";
502 auto entry =
factories.find( factoryName );
504 LOG_ERROR <<
"inconsistency in component factories list: I cannot find anymore " << factoryName;
507 const auto& info = entry->second;
508 if ( !info.is_set() )
continue;
511 if ( !info.getprop(
"ReflexName" ).empty() )
continue;
517 if ( libNativeName( lib ) != info.library ) {
518 LOG_WARNING <<
"library [" << lib <<
"] exposes factory [" << factoryName <<
"] which is declared in ["
519 << info.library <<
"] !!";
523 component_t
type = component_t::Unknown;
525 const auto ft = allowedFactories.find( info.factory.type().name() );
526 if ( ft != allowedFactories.end() ) {
528 }
else if ( factoryName ==
"ApplicationMgr" ) {
529 type = component_t::ApplicationMgr;
537 const auto className = info.getprop(
"ClassName" );
541 string cname =
"DefaultName";
545 case component_t::Algorithm:
548 case component_t::Service:
551 case component_t::AlgTool:
557 case component_t::Auditor:
560 case component_t::ApplicationMgr:
567 LOG_ERROR <<
"Error instantiating " <<
name <<
" from " << iLib;
572 LOG_ERROR <<
"Error instantiating " <<
name <<
" from " << iLib;
577 if ( !
genComponent( lib,
name,
type, prop->getProperties(), prop->getInterfaceNames(), info ) ) {
582 LOG_ERROR <<
"could not cast IInterface* object to an IProperty* !";
583 LOG_ERROR <<
"NO Configurable will be generated for [" <<
name <<
"] !";
598 if ( !userModule.
empty() ) py <<
"from " << userModule <<
" import *" <<
endl;
613 return allGood ? EXIT_SUCCESS : EXIT_FAILURE;
◆ genHeader()
Definition at line 647 of file genconf.cpp.
653 <<
"\"\"\"Automatically generated. DO NOT EDIT please\"\"\"\n"
655 <<
"if sys.version_info >= (3,):\n"
656 <<
" # Python 2 compatibility\n"
663 genImport( py,
"from {}.Configurable import *" );
666 db <<
"## -*- ascii -*- \n"
667 <<
"# db file automatically generated by genconf on: " << now <<
"\n"
◆ genImport()
Definition at line 616 of file genconf.cpp.
618 std::string::size_type pos = 0, nxtpos = 0;
621 while ( std::string::npos != pos ) {
623 nxtpos =
m_configurable[component_t::Module].find_first_of(
',', pos );
632 if ( std::string::npos == nxtpos ) {
634 s << indent <<
import.str() <<
"\n" <<
flush;
635 pos = std::string::npos;
638 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 778 of file genconf.cpp.
785 if ( ti == typeIndex<bool>() ) {
786 pvalue = ( cvalue ==
"0" || cvalue ==
"False" || cvalue ==
"false" ) ?
"False" :
"True";
787 }
else if ( ti == typeIndex<char>() || ti == typeIndex<signed char>() || ti == typeIndex<unsigned char>() ||
788 ti == typeIndex<short>() || ti == typeIndex<unsigned short>() || ti == typeIndex<int>() ||
789 ti == typeIndex<unsigned int>() || ti == typeIndex<long>() || ti == typeIndex<unsigned long>() ||
790 ti == typeIndex<long long>() || ti == typeIndex<unsigned long long>() ) {
792 }
else if ( ti == typeIndex<float>() || ti == typeIndex<double>() ) {
794 pvalue = boost::to_lower_copy( cvalue );
795 if ( std::string::npos != pvalue.
find(
"nan" ) ) {
796 pvalue =
"float('nan')";
797 }
else if ( std::string::npos == pvalue.
find(
"." ) && std::string::npos == pvalue.
find(
"e" ) ) {
798 pvalue = cvalue +
".0";
800 }
else if ( ti == typeIndex<string>() ) {
801 pvalue = quote( cvalue );
802 }
else if ( ti == typeIndex<GaudiHandleBase>() ) {
809 }
else if ( ti == typeIndex<GaudiHandleArrayBase>() ) {
824 v_str.
setf( std::ios::showpoint );
825 p->toStream( v_str );
826 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 220 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 217 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 204 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 195 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 188 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 181 of file genconf.cpp.
◆ m_pkgName
string configGenerator::m_pkgName |
|
private |
name of the package we are processing
Definition at line 177 of file genconf.cpp.
◆ m_pyBuf
buffer of auto-generated configurables
Definition at line 184 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.
const T & runtime(const T &v)
DataHandleProperty.h GaudiKernel/DataHandleProperty.h.
bool genComponent(const std::string &libName, 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 * 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()
std::string format(bool local, std::string spec="%c") const
Format the time using strftime.
double * begin(CLHEP::HepVector &v)
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 pythonizeValue(const PropertyBase *prop, string &pvalue, string &ptype)
handle the "marshalling" of Properties
void genBody(std::ostream &pyOut, std::ostream &dbOut)
virtual unsigned long addRef()=0
Increment the reference count of Interface instance.