11 from __future__
import print_function
15 cpluginsvc is a ctypes-based wrapper for the C-API of the GaudiPluginService.
19 >>> from GaudiPluginService import cpluginsvc
20 >>> for _,f in cpluginsvc.factories().items():
24 ... print ("** could not load [%s] for factory [%s]" % (f.library, f.name))
27 ... for k,v in f.properties.iteritems():
28 ... print ("\t%s: %s" % (k,v))
50 name = platform.system()
53 "Darwin":
"libGaudiPluginService.dylib",
54 "Windows":
"libGaudiPluginService.dll",
55 "Linux":
"libGaudiPluginService.so",
61 _lib = ctypes.CDLL(_libname, ctypes.RTLD_GLOBAL)
65 """Registry holds the list of factories known by the gaudi PluginService."""
67 _fields_ = [(
"_registry", ctypes.c_void_p)]
72 n = _lib.cgaudi_pluginsvc_get_factory_size(self)
74 f = _lib.cgaudi_pluginsvc_get_factory_at(self, i)
85 """registry returns the singleton-like instance of the plugin service."""
90 _instance = _lib.cgaudi_pluginsvc_instance()
96 factories returns the list of components factory informations known to the plugin service
103 Factory holds informations about a component's factory:
105 - the library hosting that component
106 - the type of component (algorithm, service, tool, ...)
107 - the return type of this factory
108 - the C++ class name of that component
109 - the properties which may decorate that component.
113 (
"_registry", Registry),
114 (
"_id", ctypes.c_char_p),
119 return self._id.decode(
"ascii")
123 return _lib.cgaudi_factory_get_library(self).decode(
"ascii")
127 return _lib.cgaudi_factory_get_type(self).decode(
"ascii")
131 return _lib.cgaudi_factory_get_classname(self).decode(
"ascii")
136 nprops = _lib.cgaudi_factory_get_property_size(self)
137 for i
in range(nprops):
138 prop = _lib.cgaudi_factory_get_property_at(self, i)
139 props[prop.key] = prop.value
143 """load the C++ library hosting this factory"""
144 return ctypes.CDLL(self.
library, ctypes.RTLD_GLOBAL)
147 return "<Factory id=%s library=%s type=%s class=%s props=%d>" % (
160 Property is a pair (key, value) optionally decorating a factory.
161 It is used to attach additional informations about a factory.
165 (
"_registry", Registry),
166 (
"_id", ctypes.c_char_p),
167 (
"_key", ctypes.c_char_p),
172 return _lib.cgaudi_property_get_key(self).decode(
"ascii")
176 return _lib.cgaudi_property_get_value(self).decode(
"ascii")
183 "cgaudi_pluginsvc_instance",
188 "cgaudi_pluginsvc_get_factory_size",
193 "cgaudi_pluginsvc_get_factory_at",
194 [Registry, ctypes.c_int],
198 "cgaudi_factory_get_library",
203 "cgaudi_factory_get_type",
208 "cgaudi_factory_get_classname",
213 "cgaudi_factory_get_property_size",
218 "cgaudi_factory_get_property_at",
219 [Factory, ctypes.c_int],
223 "cgaudi_property_get_key",
228 "cgaudi_property_get_value",
234 for f
in _functions_list:
236 func = getattr(_lib, n)
243 if __name__ ==
"__main__":
245 print(
"factories: %d" % len(
factories()))
250 print(
"** could not load [%s] for factory [%s]" % (f.library, f.name))
253 for k, v
in f.properties.items():
254 print(
"\t%s: %s" % (k, v))