| The Gaudi Framework v27r1

- 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__
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 177 of file Bindings.py.

## Constructor & Destructor Documentation

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

Definition at line 179 of file Bindings.py.

179 def __init__(self, name, ip = None) :
180 if ip : self.__dict__['_ip'] = InterfaceCast(gbl.IProperty)(ip)
181 else : self.__dict__['_ip'] = None
182 self.__dict__['_svcloc'] = gbl.Gaudi.svcLocator()
183 optsvc = Helper.service(self._svcloc,'JobOptionsSvc')
184 if optsvc : self.__dict__['_optsvc'] = InterfaceCast(gbl.IJobOptionsSvc)(optsvc)
185 else : self.__dict__['_optsvc'] = None
186 self.__dict__['_name'] = name
GaudiPython.Bindings.InterfaceCast
Definition: Bindings.py:77
GaudiPython.Bindings.iProperty.__init__
def __init__
Definition: Bindings.py:179

## Member Function Documentation

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

Definition at line 192 of file Bindings.py.

192 def __call_interface_method__(self,ifname,method,*args):
193 if not getattr(self,ifname) : self.retrieveInterface()
194 return getattr(getattr(self,ifname),method)(*args)
GaudiPython.Bindings.iProperty.retrieveInterface
def retrieveInterface(self)
Definition: Bindings.py:190
GaudiPython.Bindings.iProperty.__call_interface_method__
def __call_interface_method__(self, ifname, method, args)
Definition: Bindings.py:192

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 239 of file Bindings.py.

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

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 195 of file Bindings.py.

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

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

Definition at line 187 of file Bindings.py.

187 def getInterface(self) :
188 if not self._ip : self.retrieveInterface()
189 return self._ip
GaudiPython.Bindings.iProperty.retrieveInterface
def retrieveInterface(self)
Definition: Bindings.py:190
GaudiPython.Bindings.iProperty.getInterface
def getInterface(self)
Definition: Bindings.py:187

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

Definition at line 280 of file Bindings.py.

280 def name(self) :
281 return self._name
282
283 #----iService class---------------------------------------------------------------------
GaudiPython.Bindings.iProperty.name
def name(self)
Definition: Bindings.py:280

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

Definition at line 262 of file Bindings.py.

262 def properties(self):
263 dct = {}
264 props = None
265 ip = self.getInterface()
266 if ip :
267 props = ip.getProperties()
268 propsFrom = self._name # "interface"
269 else:
270 props = self._optsvc.getProperties( self._name )
271 propsFrom = "jobOptionsSvc"
272 if props:
273 for p in props :
274 try:
275 dct[p.name()] = PropertyEntry(p)
276 except (ValueError,TypeError),e:
277 raise ValueError, "gaudimodule.iProperty.properties(): %s%s processing property %s.%s = %s" % \
278 (e.__class__.__name__, e.args, propsFrom, p.name(), p.value())
279 return dct
GaudiPython.Bindings.PropertyEntry
Definition: Bindings.py:142
GaudiPython.Bindings.iProperty.properties
def properties(self)
Definition: Bindings.py:262
GaudiPython.Bindings.iProperty.getInterface
def getInterface(self)
Definition: Bindings.py:187

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

Definition at line 190 of file Bindings.py.

190 def retrieveInterface(self) :
191 pass
GaudiPython.Bindings.iProperty.retrieveInterface
def retrieveInterface(self)
Definition: Bindings.py:190

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

- GaudiPython/python/GaudiPython/Bindings.py