11 from __future__
import print_function
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))
48 name = platform.system()
51 'Darwin':
"libGaudiPluginService.dylib",
52 'Windows':
"libGaudiPluginService.dll",
53 'Linux':
"libGaudiPluginService.so",
59 _lib = ctypes.CDLL(_libname, ctypes.RTLD_GLOBAL)
63 '''Registry holds the list of factories known by the gaudi PluginService.
65 _fields_ = [(
"_registry", ctypes.c_void_p)]
70 n = _lib.cgaudi_pluginsvc_get_factory_size(self)
72 f = _lib.cgaudi_pluginsvc_get_factory_at(self, i)
83 '''registry returns the singleton-like instance of the plugin service.'''
88 _instance = _lib.cgaudi_pluginsvc_instance()
94 factories returns the list of components factory informations known to the plugin service
101 Factory holds informations about a component's factory:
103 - the library hosting that component
104 - the type of component (algorithm, service, tool, ...)
105 - the return type of this factory
106 - the C++ class name of that component
107 - the properties which may decorate that component.
110 (
"_registry", Registry),
111 (
"_id", ctypes.c_char_p),
116 return self._id.decode(
'ascii')
120 return _lib.cgaudi_factory_get_library(self).decode(
'ascii')
124 return _lib.cgaudi_factory_get_type(self).decode(
'ascii')
128 return _lib.cgaudi_factory_get_classname(self).decode(
'ascii')
133 nprops = _lib.cgaudi_factory_get_property_size(self)
134 for i
in range(nprops):
135 prop = _lib.cgaudi_factory_get_property_at(self, i)
136 props[prop.key] = prop.value
140 '''load the C++ library hosting this factory
142 return ctypes.CDLL(self.
library, ctypes.RTLD_GLOBAL)
145 return "<Factory id=%s library=%s type=%s class=%s props=%d>" % (
158 Property is a pair (key, value) optionally decorating a factory.
159 It is used to attach additional informations about a factory.
162 (
"_registry", Registry),
163 (
"_id", ctypes.c_char_p),
164 (
"_key", ctypes.c_char_p),
169 return _lib.cgaudi_property_get_key(self).decode(
'ascii')
173 return _lib.cgaudi_property_get_value(self).decode(
'ascii')
179 "cgaudi_pluginsvc_instance",
183 "cgaudi_pluginsvc_get_factory_size",
187 "cgaudi_pluginsvc_get_factory_at",
188 [Registry, ctypes.c_int],
191 "cgaudi_factory_get_library",
195 "cgaudi_factory_get_type",
199 "cgaudi_factory_get_classname",
203 "cgaudi_factory_get_property_size",
207 "cgaudi_factory_get_property_at",
208 [Factory, ctypes.c_int],
211 "cgaudi_property_get_key",
215 "cgaudi_property_get_value",
220 for f
in _functions_list:
222 func = getattr(_lib, n)
229 if __name__ ==
"__main__":
231 print(
"factories: %d" % len(
factories()))
236 print(
"** could not load [%s] for factory [%s]" % (f.library,
240 for k, v
in f.properties.items():
241 print(
"\t%s: %s" % (k, v))