|
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 174 of file genconf.cpp.
◆ configGenerator()
configGenerator::configGenerator |
( |
const string & |
pkgName, |
|
|
const string & |
outputDirName |
|
) |
| |
|
inline |
◆ genBody()
◆ genComponent()
Definition at line 678 of file genconf.cpp.
684 auto cname = pythonizeName( componentName );
685 const auto decl_loc = info.getprop(
"declaration_location" );
690 m_db2Buf <<
" '" << componentName <<
"': {\n";
691 m_db2Buf <<
" '__component_type__': '";
692 switch ( componentType ) {
693 case component_t::Algorithm:
696 case component_t::AlgTool:
699 case component_t::ApplicationMgr:
700 case component_t::Service:
703 case component_t::Auditor:
709 if ( !decl_loc.empty() ) {
m_db2Buf <<
"',\n '__declaration_location__': '" << decl_loc; }
710 m_db2Buf <<
"',\n '__interfaces__': (";
712 if ( ignored_interfaces.find( intf ) ==
end( ignored_interfaces ) ) {
m_db2Buf <<
'\'' << intf <<
"', "; }
714 m_db2Buf <<
"),\n 'properties': {\n";
717 m_pyBuf <<
" __slots__ = { \n";
719 const string&
pname = prop->name();
721 if ( !boost::regex_match(
pname, pythonIdentifier ) ) {
722 std::cout <<
"ERROR: invalid property name \"" <<
pname <<
"\" in component " << cname
723 <<
" (invalid Python identifier)" <<
std::endl;
725 m_pyBuf <<
" #ERROR-invalid identifier '" <<
pname <<
"'\n"
730 string pvalue, ptype;
734 m_db2Buf <<
" '" <<
pname <<
"': ('" << ptype <<
"', " << pvalue <<
", '''" << prop->documentation()
735 <<
" [" << prop->ownerTypeName() <<
"]'''";
736 auto sem = prop->semantics();
737 if ( !sem.empty() ) {
m_db2Buf <<
", '" << sem <<
'\''; }
740 if ( prop->documentation() !=
"none" ) {
741 propDoc.
emplace_back(
pname, prop->documentation() +
" [" + prop->ownerTypeName() +
"]" );
745 m_pyBuf <<
" _propertyDocDct = { \n";
746 for (
const auto& prop : propDoc ) {
748 <<
"\"\"\" " << prop.second <<
" \"\"\",\n";
752 if ( !decl_loc.empty() ) {
m_pyBuf <<
" __declaration_location__ = '" << decl_loc <<
"'\n"; }
753 m_pyBuf <<
" def __init__(self, name = " <<
m_configurable[component_t::DefaultName] <<
", **kwargs):\n"
754 <<
" super(" << cname <<
", self).__init__(name)\n"
755 <<
" for n,v in kwargs.items():\n"
756 <<
" setattr(self, n, v)\n"
757 <<
" def getDlls( self ):\n"
758 <<
" return '" << libName <<
"'\n"
759 <<
" def getType( self ):\n"
760 <<
" return '" << componentName <<
"'\n"
761 <<
" pass # class " << cname <<
"\n"
766 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 440 of file genconf.cpp.
443 const auto endLib = libs.end();
445 static const std::string gaudiSvc =
"GaudiCoreSvc";
446 const bool isGaudiSvc =
448 return s.find( gaudiSvc ) != std::string::npos;
453 cout <<
"ERROR: ApplicationMgr can not be created. Check environment" <<
endl;
458 using Gaudi::PluginService::Details::Registry;
459 const Registry&
registry = Registry::instance();
461 auto bkgNames =
registry.loadedFactoryNames();
464 IInterface* dummySvc =
new Service(
"DummySvc", svcLoc );
470 for (
const auto& iLib : libs ) {
472 if ( lib.
compare( 0, 3,
"lib" ) == 0 ) {
475 LOG_INFO <<
":::: processing library: " << iLib <<
"...";
494 for (
const auto& factoryName :
registry.loadedFactoryNames() ) {
495 if ( bkgNames.find( factoryName ) != bkgNames.end() ) {
497 LOG_INFO <<
"\t==> skipping [" << factoryName <<
"]...";
501 auto entry =
factories.find( factoryName );
503 LOG_ERROR <<
"inconsistency in component factories list: I cannot find anymore " << factoryName;
506 const auto& info = entry->second;
507 if ( !info.is_set() )
continue;
510 if ( !info.getprop(
"ReflexName" ).empty() )
continue;
516 if ( libNativeName( lib ) != info.library ) {
517 LOG_WARNING <<
"library [" << lib <<
"] exposes factory [" << factoryName <<
"] which is declared in ["
518 << info.library <<
"] !!";
522 component_t
type = component_t::Unknown;
524 const auto ft = allowedFactories.find( info.factory.type().name() );
525 if ( ft != allowedFactories.end() ) {
527 }
else if ( factoryName ==
"ApplicationMgr" ) {
528 type = component_t::ApplicationMgr;
536 const auto className = info.getprop(
"ClassName" );
540 string cname =
"DefaultName";
544 case component_t::Algorithm:
547 case component_t::Service:
550 case component_t::AlgTool:
556 case component_t::Auditor:
559 case component_t::ApplicationMgr:
566 LOG_ERROR <<
"Error instantiating " <<
name <<
" from " << iLib;
571 LOG_ERROR <<
"Error instantiating " <<
name <<
" from " << iLib;
576 if ( !
genComponent( lib,
name,
type, prop->getProperties(), prop->getInterfaceNames(), info ) ) {
581 LOG_ERROR <<
"could not cast IInterface* object to an IProperty* !";
582 LOG_ERROR <<
"NO Configurable will be generated for [" <<
name <<
"] !";
597 if ( !userModule.
empty() ) py <<
"from " << userModule <<
" import *" <<
endl;
612 return allGood ? EXIT_SUCCESS : EXIT_FAILURE;
◆ genHeader()
Definition at line 646 of file genconf.cpp.
652 <<
"\"\"\"Automatically generated. DO NOT EDIT please\"\"\"\n"
654 <<
"if sys.version_info >= (3,):\n"
655 <<
" # Python 2 compatibility\n"
662 genImport( py,
"from {}.Configurable import *" );
665 db <<
"## -*- ascii -*- \n"
666 <<
"# db file automatically generated by genconf on: " << now <<
"\n"
◆ genImport()
Definition at line 615 of file genconf.cpp.
617 std::string::size_type pos = 0, nxtpos = 0;
620 while ( std::string::npos != pos ) {
622 nxtpos =
m_configurable[component_t::Module].find_first_of(
',', pos );
631 if ( std::string::npos == nxtpos ) {
633 s << indent <<
import.str() <<
"\n" <<
flush;
634 pos = std::string::npos;
637 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 777 of file genconf.cpp.
784 if ( ti == typeIndex<bool>() ) {
785 pvalue = ( cvalue ==
"0" || cvalue ==
"False" || cvalue ==
"false" ) ?
"False" :
"True";
786 }
else if ( ti == typeIndex<char>() || ti == typeIndex<signed char>() || ti == typeIndex<unsigned char>() ||
787 ti == typeIndex<short>() || ti == typeIndex<unsigned short>() || ti == typeIndex<int>() ||
788 ti == typeIndex<unsigned int>() || ti == typeIndex<long>() || ti == typeIndex<unsigned long>() ||
789 ti == typeIndex<long long>() || ti == typeIndex<unsigned long long>() ) {
791 }
else if ( ti == typeIndex<float>() || ti == typeIndex<double>() ) {
793 pvalue = boost::to_lower_copy( cvalue );
794 if ( std::string::npos != pvalue.
find(
"nan" ) ) {
795 pvalue =
"float('nan')";
796 }
else if ( std::string::npos == pvalue.
find(
"." ) && std::string::npos == pvalue.
find(
"e" ) ) {
797 pvalue = cvalue +
".0";
799 }
else if ( ti == typeIndex<string>() ) {
800 pvalue = quote( cvalue );
801 }
else if ( ti == typeIndex<GaudiHandleBase>() ) {
805 pvalue =
base.pythonRepr();
806 ptype =
base.pythonPropertyClassName();
808 }
else if ( ti == typeIndex<GaudiHandleArrayBase>() ) {
812 pvalue =
base.pythonRepr();
813 ptype =
base.pythonPropertyClassName();
819 pvalue =
base.pythonRepr();
823 v_str.
setf( std::ios::showpoint );
824 p->toStream( v_str );
825 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 219 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 216 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 203 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 194 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 187 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 180 of file genconf.cpp.
◆ m_pkgName
string configGenerator::m_pkgName |
|
private |
name of the package we are processing
Definition at line 176 of file genconf.cpp.
◆ m_pyBuf
buffer of auto-generated configurables
Definition at line 183 of file genconf.cpp.
The documentation for this class was generated from the following file:
void genTrailer(std::ostream &pyOut, std::ostream &dbOut)
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)
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)
GAUDIPS_API Logger & logger()
Return the current logger instance.
void genHeader(std::ostream &pyOut, std::ostream &dbOut)
static Time current()
Returns the current time.
string m_outputDirName
absolute path to the directory where genconf will store auto-generated files (Configurables and Confi...
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.