14 cpluginsvc is a ctypes-based wrapper for the C-API of the GaudiPluginService.
18 >>> from GaudiPluginService import cpluginsvc
19 >>> for _,f in cpluginsvc.factories().items():
23 ... print ("** could not load [%s] for factory [%s]" % (f.library, f.name))
26 ... for k,v in f.properties.iteritems():
27 ... print ("\t%s: %s" % (k,v))
49 name = platform.system()
52 "Darwin":
"libGaudiPluginService.dylib",
53 "Windows":
"libGaudiPluginService.dll",
54 "Linux":
"libGaudiPluginService.so",
60 _lib = ctypes.CDLL(_libname, ctypes.RTLD_GLOBAL)
64 """Registry holds the list of factories known by the gaudi PluginService."""
66 _fields_ = [(
"_registry", ctypes.c_void_p)]
71 n = _lib.cgaudi_pluginsvc_get_factory_size(self)
73 f = _lib.cgaudi_pluginsvc_get_factory_at(self, i)
84 """registry returns the singleton-like instance of the plugin service."""
89 _instance = _lib.cgaudi_pluginsvc_instance()
95 factories returns the list of components factory informations known to the plugin service
102 Factory holds informations about a component's factory:
104 - the library hosting that component
105 - the type of component (algorithm, service, tool, ...)
106 - the return type of this factory
107 - the C++ class name of that component
108 - the properties which may decorate that component.
112 (
"_registry", Registry),
113 (
"_id", ctypes.c_char_p),
118 return self._id.decode(
"ascii")
122 return _lib.cgaudi_factory_get_library(self).decode(
"ascii")
126 return _lib.cgaudi_factory_get_type(self).decode(
"ascii")
130 return _lib.cgaudi_factory_get_classname(self).decode(
"ascii")
135 nprops = _lib.cgaudi_factory_get_property_size(self)
136 for i
in range(nprops):
137 prop = _lib.cgaudi_factory_get_property_at(self, i)
138 props[prop.key] = prop.value
142 """load the C++ library hosting this factory"""
143 return ctypes.CDLL(self.
library, ctypes.RTLD_GLOBAL)
146 return "<Factory id=%s library=%s type=%s class=%s props=%d>" % (
159 Property is a pair (key, value) optionally decorating a factory.
160 It is used to attach additional informations about a factory.
164 (
"_registry", Registry),
165 (
"_id", ctypes.c_char_p),
166 (
"_key", ctypes.c_char_p),
171 return _lib.cgaudi_property_get_key(self).decode(
"ascii")
175 return _lib.cgaudi_property_get_value(self).decode(
"ascii")
182 "cgaudi_pluginsvc_instance",
187 "cgaudi_pluginsvc_get_factory_size",
192 "cgaudi_pluginsvc_get_factory_at",
193 [Registry, ctypes.c_int],
197 "cgaudi_factory_get_library",
202 "cgaudi_factory_get_type",
207 "cgaudi_factory_get_classname",
212 "cgaudi_factory_get_property_size",
217 "cgaudi_factory_get_property_at",
218 [Factory, ctypes.c_int],
222 "cgaudi_property_get_key",
227 "cgaudi_property_get_value",
233 for f
in _functions_list:
235 func = getattr(_lib, n)
242 if __name__ ==
"__main__":
244 print(
"factories: %d" % len(
factories()))
249 print(
"** could not load [%s] for factory [%s]" % (f.library, f.name))
252 for k, v
in f.properties.items():
253 print(
"\t%s: %s" % (k, v))