|
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, 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 670 of file genconf.cpp.
676 auto cname = pythonizeName( componentName );
677 const auto decl_loc = info.getprop(
"declaration_location" );
682 m_db2Buf <<
" '" << componentName <<
"': {\n";
683 m_db2Buf <<
" '__component_type__': '";
684 switch ( componentType ) {
685 case component_t::Algorithm:
688 case component_t::AlgTool:
691 case component_t::ApplicationMgr:
692 case component_t::Service:
695 case component_t::Auditor:
701 if ( !decl_loc.empty() ) {
m_db2Buf <<
"',\n '__declaration_location__': '" << decl_loc; }
702 m_db2Buf <<
"',\n '__interfaces__': (";
704 if ( ignored_interfaces.find( intf ) ==
end( ignored_interfaces ) ) {
m_db2Buf <<
'\'' << intf <<
"', "; }
706 m_db2Buf <<
"),\n 'properties': {\n";
709 m_pyBuf <<
" __slots__ = { \n";
711 const string&
pname = prop->name();
713 if ( !boost::regex_match(
pname, pythonIdentifier ) ) {
714 std::cout <<
"ERROR: invalid property name \"" <<
pname <<
"\" in component " << cname
715 <<
" (invalid Python identifier)" <<
std::endl;
717 m_pyBuf <<
" #ERROR-invalid identifier '" <<
pname <<
"'\n"
722 string pvalue, ptype, ptype2;
724 m_pyBuf <<
" '" <<
pname <<
"' : " << pvalue <<
", # " << ptype <<
"\n";
726 m_db2Buf <<
" '" <<
pname <<
"': ('" << ptype2 <<
"', " << pvalue <<
", '''" << prop->documentation()
727 <<
" [" << prop->ownerTypeName() <<
"]'''";
728 auto sem = prop->semantics();
729 if ( !sem.empty() ) {
m_db2Buf <<
", '" << sem <<
'\''; }
732 if ( prop->documentation() !=
"none" ) {
733 propDoc.
emplace_back(
pname, prop->documentation() +
" [" + prop->ownerTypeName() +
"]" );
737 m_pyBuf <<
" _propertyDocDct = { \n";
738 for (
const auto& prop : propDoc ) {
740 <<
"\"\"\" " << prop.second <<
" \"\"\",\n";
744 if ( !decl_loc.empty() ) {
m_pyBuf <<
" __declaration_location__ = '" << decl_loc <<
"'\n"; }
745 m_pyBuf <<
" def __init__(self, name = " <<
m_configurable[component_t::DefaultName] <<
", **kwargs):\n"
746 <<
" super(" << cname <<
", self).__init__(name)\n"
747 <<
" for n,v in kwargs.items():\n"
748 <<
" setattr(self, n, v)\n"
749 <<
" def getDlls( self ):\n"
750 <<
" return '" << libName <<
"'\n"
751 <<
" def getType( self ):\n"
752 <<
" return '" << componentName <<
"'\n"
753 <<
" pass # class " << cname <<
"\n"
758 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 432 of file genconf.cpp.
435 const auto endLib = libs.end();
437 static const std::string gaudiSvc =
"GaudiCoreSvc";
438 const bool isGaudiSvc =
440 return s.find( gaudiSvc ) != std::string::npos;
445 cout <<
"ERROR: ApplicationMgr can not be created. Check environment" <<
endl;
450 using Gaudi::PluginService::Details::Registry;
451 const Registry&
registry = Registry::instance();
453 auto bkgNames =
registry.loadedFactoryNames();
462 for (
const auto& iLib : libs ) {
464 if ( lib.
compare( 0, 3,
"lib" ) == 0 ) {
467 LOG_INFO <<
":::: processing library: " << iLib <<
"...";
486 for (
const auto& factoryName :
registry.loadedFactoryNames() ) {
487 if ( bkgNames.find( factoryName ) != bkgNames.end() ) {
489 LOG_INFO <<
"\t==> skipping [" << factoryName <<
"]...";
493 auto entry =
factories.find( factoryName );
495 LOG_ERROR <<
"inconsistency in component factories list: I cannot find anymore " << factoryName;
498 const auto& info = entry->second;
499 if ( !info.is_set() )
continue;
502 if ( !info.getprop(
"ReflexName" ).empty() )
continue;
508 if ( libNativeName( lib ) != info.library ) {
509 LOG_WARNING <<
"library [" << lib <<
"] exposes factory [" << factoryName <<
"] which is declared in ["
510 << info.library <<
"] !!";
514 component_t
type = component_t::Unknown;
516 const auto ft = allowedFactories.find( info.factory.type().name() );
517 if ( ft != allowedFactories.end() ) {
519 }
else if ( factoryName ==
"ApplicationMgr" ) {
520 type = component_t::ApplicationMgr;
528 const auto className = info.getprop(
"ClassName" );
532 string cname =
"DefaultName";
536 case component_t::Algorithm:
539 case component_t::Service:
542 case component_t::AlgTool:
548 case component_t::Auditor:
551 case component_t::ApplicationMgr:
558 LOG_ERROR <<
"Error instantiating " <<
name <<
" from " << iLib;
563 LOG_ERROR <<
"Error instantiating " <<
name <<
" from " << iLib;
568 if ( !
genComponent( lib,
name,
type, prop->getProperties(), prop->getInterfaceNames(), info ) ) {
573 LOG_ERROR <<
"could not cast IInterface* object to an IProperty* !";
574 LOG_ERROR <<
"NO Configurable will be generated for [" <<
name <<
"] !";
589 if ( !userModule.
empty() ) py <<
"from " << userModule <<
" import *" <<
endl;
604 return allGood ? EXIT_SUCCESS : EXIT_FAILURE;
◆ genHeader()
Definition at line 638 of file genconf.cpp.
644 <<
"\"\"\"Automatically generated. DO NOT EDIT please\"\"\"\n"
646 <<
"if sys.version_info >= (3,):\n"
647 <<
" # Python 2 compatibility\n"
654 genImport( py,
"from {}.Configurable import *" );
657 db <<
"## -*- ascii -*- \n"
658 <<
"# db file automatically generated by genconf on: " << now <<
"\n"
◆ genImport()
Definition at line 607 of file genconf.cpp.
609 std::string::size_type pos = 0, nxtpos = 0;
612 while ( std::string::npos != pos ) {
614 nxtpos =
m_configurable[component_t::Module].find_first_of(
',', pos );
623 if ( std::string::npos == nxtpos ) {
625 s << indent <<
import.str() <<
"\n" <<
flush;
626 pos = std::string::npos;
629 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 769 of file genconf.cpp.
776 if ( ti == typeIndex<bool>() ) {
777 pvalue = ( cvalue ==
"0" || cvalue ==
"False" || cvalue ==
"false" ) ?
"False" :
"True";
779 }
else if ( ti == typeIndex<char>() || ti == typeIndex<signed char>() || ti == typeIndex<unsigned char>() ||
780 ti == typeIndex<short>() || ti == typeIndex<unsigned short>() || ti == typeIndex<int>() ||
781 ti == typeIndex<unsigned int>() || ti == typeIndex<long>() || ti == typeIndex<unsigned long>() ||
782 ti == typeIndex<long long>() || ti == typeIndex<unsigned long long>() ) {
785 }
else if ( ti == typeIndex<float>() || ti == typeIndex<double>() ) {
787 pvalue = boost::to_lower_copy( cvalue );
788 if ( std::string::npos != pvalue.
find(
"nan" ) ) {
789 pvalue =
"float('nan')";
790 }
else if ( std::string::npos == pvalue.
find(
"." ) && std::string::npos == pvalue.
find(
"e" ) ) {
791 pvalue = cvalue +
".0";
794 }
else if ( ti == typeIndex<string>() ) {
795 pvalue = quote( cvalue );
797 }
else if ( ti == typeIndex<GaudiHandleBase>() ) {
802 ptype =
"GaudiHandle";
805 }
else if ( ti == typeIndex<GaudiHandleArrayBase>() ) {
810 ptype =
"GaudiHandleArray";
818 ptype =
"DataHandle";
822 v_str.
setf( std::ios::showpoint );
823 p->toStream( v_str );
824 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.
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)
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.