|
| bool | genComponent (const std::string &libName, const std::string &componentName, component_t componentType, const vector< PropertyBase * > &properties, const Gaudi::PluginService::Details::Registry::FactoryInfo &info) |
| |
| bool | genComponent2 (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 171 of file genconf.cpp.
◆ configGenerator()
| configGenerator::configGenerator |
( |
const string & |
pkgName, |
|
|
const string & |
outputDirName |
|
) |
| |
|
inline |
◆ genBody()
◆ genComponent()
| bool configGenerator::genComponent |
( |
const std::string & |
libName, |
|
|
const std::string & |
componentName, |
|
|
component_t |
componentType, |
|
|
const vector< PropertyBase * > & |
properties, |
|
|
const Gaudi::PluginService::Details::Registry::FactoryInfo & |
info |
|
) |
| |
|
private |
Definition at line 709 of file genconf.cpp.
714 auto cname = pythonizeName( componentName );
715 const auto decl_loc = info.getprop(
"declaration_location" );
721 m_pyBuf <<
" __slots__ = { \n";
723 const string&
pname = prop->name();
725 if ( !boost::regex_match(
pname, pythonIdentifier ) ) {
726 LOG_ERROR <<
"invalid property name \"" <<
pname <<
"\" in component " << cname <<
" (invalid Python identifier)"
729 m_pyBuf <<
" #ERROR-invalid identifier '" <<
pname <<
"'\n"
734 string pvalue, ptype;
738 if ( prop->documentation() !=
"none" ) {
739 propDoc.
emplace_back(
pname, prop->documentation() +
" [" + prop->ownerTypeName() +
"]" );
743 m_pyBuf <<
" _propertyDocDct = { \n";
744 for (
const auto& prop : propDoc ) {
746 <<
"\"\"\" " << prop.second <<
" \"\"\",\n";
750 if ( !decl_loc.empty() ) {
m_pyBuf <<
" __declaration_location__ = '" << decl_loc <<
"'\n"; }
751 m_pyBuf <<
" def __init__(self, name = " <<
m_configurable[component_t::DefaultName] <<
", **kwargs):\n"
752 <<
" super(" << cname <<
", self).__init__(name)\n"
753 <<
" for n,v in kwargs.items():\n"
754 <<
" setattr(self, n, v)\n"
755 <<
" def getDlls( self ):\n"
756 <<
" return '" << libName <<
"'\n"
757 <<
" def getType( self ):\n"
758 <<
" return '" << componentName <<
"'\n"
759 <<
" pass # class " << cname <<
"\n"
764 const string modName =
fs::path( pyName ).filename().stem().string();
◆ genComponent2()
| bool configGenerator::genComponent2 |
( |
const std::string & |
componentName, |
|
|
component_t |
componentType, |
|
|
const vector< PropertyBase * > & |
properties, |
|
|
const std::vector< std::string > & |
interfaces, |
|
|
const Gaudi::PluginService::Details::Registry::FactoryInfo & |
info |
|
) |
| |
|
private |
Definition at line 773 of file genconf.cpp.
778 m_db2Buf <<
" '" << componentName <<
"': {\n";
779 m_db2Buf <<
" '__component_type__': '";
780 switch ( componentType ) {
781 case component_t::Algorithm:
784 case component_t::AlgTool:
787 case component_t::ApplicationMgr:
788 case component_t::Service:
791 case component_t::Auditor:
798 const auto decl_loc = info.getprop(
"declaration_location" );
799 if ( !decl_loc.empty() ) {
m_db2Buf <<
"',\n '__declaration_location__': '" << decl_loc; }
801 m_db2Buf <<
"',\n '__interfaces__': (";
803 if ( ignored_interfaces.find( intf ) ==
end( ignored_interfaces ) ) {
m_db2Buf <<
'\'' << intf <<
"', "; }
805 m_db2Buf <<
"),\n 'properties': {\n";
809 const string&
pname = prop->name();
811 if ( !boost::regex_match(
pname, pythonIdentifier ) ) {
812 LOG_ERROR <<
"invalid property name \"" <<
pname <<
"\" in component " << componentName
813 <<
" (invalid Python identifier)" <<
std::endl;
814 m_db2Buf <<
" #ERROR-invalid identifier '" <<
pname <<
"'\n";
819 string pvalue, ptype;
822 m_db2Buf <<
" '" <<
pname <<
"': ('" << ptype <<
"', " << pvalue <<
", '''" << prop->documentation()
823 <<
" [" << prop->ownerTypeName() <<
"]'''";
824 auto sem = prop->semantics();
825 if ( !sem.empty() ) {
m_db2Buf <<
", '" << sem <<
'\''; }
◆ 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 466 of file genconf.cpp.
469 const auto endLib = libs.end();
471 static const std::string gaudiSvc =
"GaudiCoreSvc";
472 const bool isGaudiSvc =
474 return s.find( gaudiSvc ) != std::string::npos;
479 cout <<
"ERROR: ApplicationMgr can not be created. Check environment" <<
endl;
484 using Gaudi::PluginService::Details::Registry;
485 const Registry&
registry = Registry::instance();
487 auto bkgNames =
registry.loadedFactoryNames();
490 IInterface* dummySvc =
new Service(
"DummySvc", svcLoc );
496 for (
const auto& iLib : libs ) {
498 if ( lib.
compare( 0, 3,
"lib" ) == 0 ) {
501 LOG_INFO <<
":::: processing library: " << iLib <<
"...";
520 for (
const auto& factoryName :
registry.loadedFactoryNames() ) {
521 if ( bkgNames.find( factoryName ) != bkgNames.end() ) {
523 LOG_INFO <<
"\t==> skipping [" << factoryName <<
"]...";
527 auto entry =
factories.find( factoryName );
529 LOG_ERROR <<
"inconsistency in component factories list: I cannot find anymore " << factoryName;
532 const auto& info = entry->second;
533 if ( !info.is_set() )
continue;
536 if ( !info.getprop(
"ReflexName" ).empty() )
continue;
542 if ( libNativeName( lib ) != info.library ) {
543 LOG_WARNING <<
"library [" << lib <<
"] exposes factory [" << factoryName <<
"] which is declared in ["
544 << info.library <<
"] !!";
548 component_t
type = component_t::Unknown;
550 const auto ft = allowedFactories.find( info.factory.type().name() );
551 if ( ft != allowedFactories.end() ) {
553 }
else if ( factoryName ==
"ApplicationMgr" ) {
554 type = component_t::ApplicationMgr;
562 const auto className = info.getprop(
"ClassName" );
566 string cname =
"DefaultName";
570 case component_t::Algorithm:
573 case component_t::Service:
576 case component_t::AlgTool:
582 case component_t::Auditor:
585 case component_t::ApplicationMgr:
592 LOG_ERROR <<
"Error instantiating " <<
name <<
" from " << iLib;
597 LOG_ERROR <<
"Error instantiating " <<
name <<
" from " << iLib;
611 LOG_ERROR <<
"could not cast IInterface* object to an IProperty* !";
612 LOG_ERROR <<
"NO Configurable will be generated for [" <<
name <<
"] !";
628 if ( !userModule.
empty() ) py <<
"from " << userModule <<
" import *" <<
endl;
643 return allGood ? EXIT_SUCCESS : EXIT_FAILURE;
◆ genHeader()
Definition at line 677 of file genconf.cpp.
683 <<
"\"\"\"Automatically generated. DO NOT EDIT please\"\"\"\n"
685 <<
"if sys.version_info >= (3,):\n"
686 <<
" # Python 2 compatibility\n"
693 genImport( py,
"from {}.Configurable import *" );
696 db <<
"## -*- ascii -*- \n"
697 <<
"# db file automatically generated by genconf on: " << now <<
"\n"
◆ genImport()
Definition at line 646 of file genconf.cpp.
648 std::string::size_type pos = 0, nxtpos = 0;
651 while ( std::string::npos != pos ) {
653 nxtpos =
m_configurable[component_t::Module].find_first_of(
',', pos );
662 if ( std::string::npos == nxtpos ) {
664 s << indent <<
import.str() <<
"\n" <<
flush;
665 pos = std::string::npos;
668 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 835 of file genconf.cpp.
842 if ( ti == typeIndex<bool>() ) {
843 pvalue = ( cvalue ==
"0" || cvalue ==
"False" || cvalue ==
"false" ) ?
"False" :
"True";
844 }
else if ( ti == typeIndex<char>() || ti == typeIndex<signed char>() || ti == typeIndex<unsigned char>() ||
845 ti == typeIndex<short>() || ti == typeIndex<unsigned short>() || ti == typeIndex<int>() ||
846 ti == typeIndex<unsigned int>() || ti == typeIndex<long>() || ti == typeIndex<unsigned long>() ||
847 ti == typeIndex<long long>() || ti == typeIndex<unsigned long long>() ) {
849 }
else if ( ti == typeIndex<float>() || ti == typeIndex<double>() ) {
851 pvalue = boost::to_lower_copy( cvalue );
852 if ( std::string::npos != pvalue.
find(
"nan" ) ) {
853 pvalue =
"float('nan')";
854 }
else if ( std::string::npos == pvalue.
find(
"." ) && std::string::npos == pvalue.
find(
"e" ) ) {
855 pvalue = cvalue +
".0";
857 }
else if ( ti == typeIndex<string>() ) {
858 pvalue = quote( cvalue );
859 }
else if ( ti == typeIndex<GaudiHandleBase>() ) {
863 pvalue =
base.pythonRepr();
864 ptype =
base.pythonPropertyClassName();
866 }
else if ( ti == typeIndex<GaudiHandleArrayBase>() ) {
870 pvalue =
base.pythonRepr();
871 ptype =
base.pythonPropertyClassName();
877 pvalue =
base.pythonRepr();
881 v_str.
setf( std::ios::showpoint );
882 p->toStream( v_str );
883 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 223 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 220 of file genconf.cpp.
◆ setConfigurableService()
| void configGenerator::setConfigurableService |
( |
const std::string & |
cfgService | ) |
|
|
inline |
◆ setConfigurableTypes()
| void configGenerator::setConfigurableTypes |
( |
const std::set< conf_t > & |
types | ) |
|
|
inline |
customize configurable types to generate
Definition at line 217 of file genconf.cpp.
◆ 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_confTypes
| std::set<conf_t> configGenerator::m_confTypes |
|
private |
Types of configurables to generate.
Definition at line 188 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 184 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 177 of file genconf.cpp.
◆ m_pkgName
| string configGenerator::m_pkgName |
|
private |
name of the package we are processing
Definition at line 173 of file genconf.cpp.
◆ m_pyBuf
buffer of auto-generated configurables
Definition at line 180 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
bool genComponent(const std::string &libName, const std::string &componentName, component_t componentType, const vector< PropertyBase * > &properties, const Gaudi::PluginService::Details::Registry::FactoryInfo &info)
void reset(TYPE *ptr=nullptr)
Set the internal pointer to the passed one disposing of the old one.
DataHandleProperty.h GaudiKernel/DataHandleProperty.h.
std::set< conf_t > m_confTypes
Types of configurables to generate.
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()
AttribStringParser::Iterator begin(const AttribStringParser &parser)
std::string format(bool local, std::string spec="%c") const
Format the time using strftime.
bool genComponent2(const std::string &componentName, component_t componentType, const vector< PropertyBase * > &properties, const std::vector< std::string > &interfaces, const Gaudi::PluginService::Details::Registry::FactoryInfo &info)
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...
stringstream m_db2Buf
buffer of generated GaudiConfig2 configurables
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.