| The Gaudi Framework v28r2-patches (bc4ad17a)

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Member Functions | List of all members
GaudiPython.Bindings.iProperty Class Reference
Inheritance diagram for GaudiPython.Bindings.iProperty:
[legend]
Collaboration diagram for GaudiPython.Bindings.iProperty:
[legend]

## Public Member Functions
def | __init__ (self, name, ip=None)
def | getInterface (self)
def | retrieveInterface (self)
def | __call_interface_method__ (self, ifname, method, args)
def | __setattr__ (self, name, value)
def | __getattr__ (self, name)
def | properties (self)
def | name (self)

## Detailed Description

    Python equivalent to the C++ Property interface

Definition at line 186 of file Bindings.py.

## Constructor & Destructor Documentation

def GaudiPython.Bindings.iProperty.__init__ | ( |  | self,
|  |  | name,
|  |  | ip = `None`
| ) |  |

Definition at line 188 of file Bindings.py.

188 def __init__(self, name, ip = None) :
189 if ip : self.__dict__['_ip'] = InterfaceCast(gbl.IProperty)(ip)
190 else : self.__dict__['_ip'] = None
191 self.__dict__['_svcloc'] = gbl.Gaudi.svcLocator()
192 optsvc = Helper.service(self._svcloc,'JobOptionsSvc')
193 if optsvc : self.__dict__['_optsvc'] = InterfaceCast(gbl.IJobOptionsSvc)(optsvc)
194 else : self.__dict__['_optsvc'] = None
195 self.__dict__['_name'] = name
GaudiPython.Bindings.InterfaceCast
Definition: Bindings.py:86
GaudiPython.Bindings.iProperty.__init__
def __init__(self, name, ip=None)
Definition: Bindings.py:188

## Member Function Documentation

def GaudiPython.Bindings.iProperty.__call_interface_method__ | ( |  | self,
|  |  | ifname,
|  |  | method,
|  |  | args
| ) |  |

Definition at line 201 of file Bindings.py.

201 def __call_interface_method__(self,ifname,method,*args):
202 if not getattr(self,ifname) : self.retrieveInterface()
203 return getattr(getattr(self,ifname),method)(*args)
GaudiPython.Bindings.iProperty.retrieveInterface
def retrieveInterface(self)
Definition: Bindings.py:199
GaudiPython.Bindings.iProperty.__call_interface_method__
def __call_interface_method__(self, ifname, method, args)
Definition: Bindings.py:201

def GaudiPython.Bindings.iProperty.__getattr__ | ( |  | self,
|  |  | name
| ) |  |

    The method which returns the value for the given property
    - In the case of the valid instance it returns the valid property value through IProperty interface
    - In the case of placeholder the property value is retrieved from JobOptionsCatalogue

Definition at line 248 of file Bindings.py.

248 def __getattr__(self, name ):
249 """
250 The method which returns the value for the given property
251 - In the case of the valid instance it returns the valid property value through IProperty interface
252 - In the case of placeholder the property value is retrieved from JobOptionsCatalogue
253 """
254 ip = self.getInterface()
255 if ip :
256 if not gbl.Gaudi.Utils.hasProperty ( ip , name ) :
257 raise AttributeError, 'property %s does not exist' % name
258 prop = ip.getProperty(name)
259 if StringProperty == type( prop ) : return prop.value()
260 elif StringPropertyRef == type( prop ) : return prop.value()
261 try: return eval( prop.toString(), {}, {} )
262 except : return prop.value()
263 else :
264 props = self._optsvc.getProperties(self._name)
265 for p in props :
266 if not p.name() == name : continue
267 # from JobOptionsSvc we always have only strings
268 try: return eval( p.value(), {}, {} )
269 except: return p.value()
270 raise AttributeError, 'property %s does not exist' % name
gaudirun.type
type
Definition: gaudirun.py:125
GaudiPython.Bindings.iProperty.getInterface
def getInterface(self)
Definition: Bindings.py:196
GaudiPython.Bindings.iProperty.__getattr__
def __getattr__(self, name)
Definition: Bindings.py:248

def GaudiPython.Bindings.iProperty.__setattr__ | ( |  | self,
|  |  | name,
|  |  | value
| ) |  |

    The method which is used for setting the property from the given value.
    - In the case of the valid instance it sets the property through IProperty interface
    - In the case of placeholder the property is added to JobOptionsCatalogue

Definition at line 204 of file Bindings.py.

204 def __setattr__(self, name, value):
205 """
206 The method which is used for setting the property from the given value.
207 - In the case of the valid instance it sets the property through IProperty interface
208 - In the case of placeholder the property is added to JobOptionsCatalogue
209 """
210 if hasattr( value, 'toStringProperty' ):
211 # user defined behaviour
212 value = '%s' % value.toStringProperty()
213 ip = self.getInterface()
214 if ip :
215 if not gbl.Gaudi.Utils.hasProperty ( ip , name ) :
216 raise AttributeError, 'property %s does not exist' % name
217 prop = ip.getProperty(name)
218
219 if ROOT6WorkAroundEnabled('ROOT-7201'):
220 canSetValue = (hasattr(prop, 'value') and
221 'const&[' not in prop.value.func_doc and
222 type(value) == type(prop.value()))
223 else:
224 canSetValue = (hasattr(prop, 'value') and
225 type(value) == type(prop.value()))
226
227 if canSetValue:
228 if not prop.setValue(value) :
229 raise AttributeError, 'property %s could not be set from %s' % (name, value)
230 else:
231 if tuple == type( value ) : value = str(value)
232 elif hasattr ( value , 'toString' ) : value = value.toString()
233 elif not long == type( value ) : value = '%s' % value
234 else : value = '%d' % value
235 if ROOT6WorkAroundEnabled('ROOT-6028'):
236 sc = cppyy.gbl.GaudiPython.Helper.setPropertyFromString(prop, value)
237 else:
238 sc = prop.fromString(value)
239 if sc.isFailure() :
240 raise AttributeError, 'property %s could not be set from %s' % (name,value)
241 else :
242 if type(value) == str : value = '"%s"' % value # need double quotes
243 elif type(value) == tuple : value = str(value)
244 elif hasattr( value , 'toString' ) : value = value.toString()
245 elif type(value) == long: value = '%d' % value # prevent pending 'L'
246 sp = gbl.GaudiPython.Helpers.mkStringProperty(name, str(value))
247 self._optsvc.addPropertyToCatalogue( self._name , sp ).ignore()
GaudiKernel.ROOT6WorkAroundEnabled
def ROOT6WorkAroundEnabled(id=None)
Definition: __init__.py:3
gaudirun.type
type
Definition: gaudirun.py:125
GaudiPython.Bindings.iProperty.getInterface
def getInterface(self)
Definition: Bindings.py:196
GaudiPython.Bindings.iProperty.__setattr__
def __setattr__(self, name, value)
Definition: Bindings.py:204

def GaudiPython.Bindings.iProperty.getInterface | ( |  | self | ) |

Definition at line 196 of file Bindings.py.

196 def getInterface(self) :
197 if not self._ip : self.retrieveInterface()
198 return self._ip
GaudiPython.Bindings.iProperty.retrieveInterface
def retrieveInterface(self)
Definition: Bindings.py:199
GaudiPython.Bindings.iProperty.getInterface
def getInterface(self)
Definition: Bindings.py:196

def GaudiPython.Bindings.iProperty.name | ( |  | self | ) |

Definition at line 289 of file Bindings.py.

289 def name(self) :
290 return self._name
291
292 #----iService class---------------------------------------------------------------------
GaudiPython.Bindings.iProperty.name
def name(self)
Definition: Bindings.py:289

def GaudiPython.Bindings.iProperty.properties | ( |  | self | ) |

Definition at line 271 of file Bindings.py.

271 def properties(self):
272 dct = {}
273 props = None
274 ip = self.getInterface()
275 if ip :
276 props = ip.getProperties()
277 propsFrom = self._name # "interface"
278 else:
279 props = self._optsvc.getProperties( self._name )
280 propsFrom = "jobOptionsSvc"
281 if props:
282 for p in props :
283 try:
284 dct[p.name()] = PropertyEntry(p)
285 except (ValueError,TypeError),e:
286 raise ValueError, "gaudimodule.iProperty.properties(): %s%s processing property %s.%s = %s" % \
287 (e.__class__.__name__, e.args, propsFrom, p.name(), p.value())
288 return dct
GaudiPython.Bindings.PropertyEntry
Definition: Bindings.py:151
GaudiPython.Bindings.iProperty.properties
def properties(self)
Definition: Bindings.py:271
GaudiPython.Bindings.iProperty.getInterface
def getInterface(self)
Definition: Bindings.py:196

def GaudiPython.Bindings.iProperty.retrieveInterface | ( |  | self | ) |

Definition at line 199 of file Bindings.py.

199 def retrieveInterface(self) :
200 pass
GaudiPython.Bindings.iProperty.retrieveInterface
def retrieveInterface(self)
Definition: Bindings.py:199

The documentation for this class was generated from the following file:

- GaudiPython/python/GaudiPython/Bindings.py