| # Gaudi Framework, version v23r0 |

Home |  | Generated: Mon Jan 30 2012

Public Member Functions

# GaudiPython::Bindings::iProperty Class Reference

Inheritance diagram for GaudiPython::Bindings::iProperty:
[legend]

List of all members.

## Public Member Functions
def | __init__
def | getInterface
def | retrieveInterface
def | __call_interface_method__
def | __setattr__
def | __getattr__
def | properties
def | name

## Detailed Description

    Python equivalent to the C++ Property interface

Definition at line 164 of file Bindings.py.

## Constructor & Destructor Documentation

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

Reimplemented in GaudiPython::Bindings::iService, GaudiPython::Bindings::iAlgorithm, GaudiPython::Bindings::iAlgTool, GaudiPython::Bindings::iDataSvc, GaudiPython::Bindings::iHistogramSvc, GaudiPython::Bindings::iNTupleSvc, GaudiPython::Bindings::iToolSvc, and GaudiPython::Bindings::iJobOptSvc.

Definition at line 166 of file Bindings.py.

    00167                                         :
    00168         if ip : self.__dict__['_ip'] = InterfaceCast(gbl.IProperty)(ip)
    00169         else  : self.__dict__['_ip'] = None
    00170         self.__dict__['_svcloc'] = gbl.Gaudi.svcLocator()
    00171         optsvc = Helper.service(self._svcloc,'JobOptionsSvc')
    00172         if optsvc : self.__dict__['_optsvc'] = InterfaceCast(gbl.IJobOptionsSvc)(optsvc)
    00173         else      : self.__dict__['_optsvc'] = None
            self.__dict__['_name'] = name

## Member Function Documentation

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

Definition at line 179 of file Bindings.py.

    00180                                                            :
    00181         if not getattr(self,ifname) : self.retrieveInterface()
            return getattr(getattr(self,ifname),method)(*args)

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

    00214                                 :
    00215         """
    00216         The method which returns the value for the given property
    00217         - In the case of the valid instance it returns the valid property value through IProperty interface
    00218         - In the case of placeholder the property value is retrieved from JobOptionsCatalogue
    00219         """
    00220         ip = self.getInterface()
    00221         if ip :
    00222             if not gbl.Gaudi.Utils.hasProperty ( ip , name ) :
    00223                 raise AttributeError, 'property %s does not exist' % name
    00224             prop = ip.getProperty(name)
    00225             if   StringProperty    == type( prop )   : return prop.value()
    00226             elif StringPropertyRef == type( prop )   : return prop.value()
    00227             try:     return eval( prop.toString(), {}, {} )
    00228             except : return prop.value()
    00229         else :
    00230             props = self._optsvc.getProperties(self._name)
    00231             for p in props :
    00232                 if not p.name() == name : continue
    00233                 # from JobOptionsSvc we always have only strings
    00234                 try:    return eval( p.value(), {}, {} )
    00235                 except: return p.value()
                raise AttributeError, 'property %s does not exist' % name

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

    00183                                       :
    00184         """
    00185         The method which is used for setting the property from the given value.
    00186         - In the case of the valid instance it sets the property through IProperty interface
    00187         - In the case of placeholder the property is added to JobOptionsCatalogue
    00188         """
    00189         if hasattr( value, 'toStringProperty' ):
    00190             # user defined behaviour
    00191             value = '%s' % value.toStringProperty()
    00192         ip = self.getInterface()
    00193         if ip :
    00194             if not gbl.Gaudi.Utils.hasProperty ( ip , name ) :
    00195                 raise AttributeError, 'property %s does not exist' % name
    00196             prop = ip.getProperty(name)
    00197             if not hasattr ( prop , 'value' ) or not type( value ) == type( prop.value() ) :
    00198                 if   tuple     == type( value  )     : value = str(value)
    00199                 elif hasattr ( value , 'toString' )  : value = value.toString()
    00200                 elif not long  == type( value )      : value = '%s' % value
    00201                 else                                 : value = '%d' % value
    00202                 if prop.fromString( value ).isFailure() :
    00203                     raise AttributeError, 'property %s could not be set from %s' % (name,value)
    00204             else :
    00205                 if not prop.setValue( value ) :
    00206                     raise AttributeError, 'property %s could not be set from %s' % (name,value)
    00207         else :
    00208             if   type(value) == str            : value = '"%s"' % value # need double quotes
    00209             elif type(value) == tuple          : value = str(value)
    00210             elif hasattr( value , 'toString' ) : value = value.toString()
    00211             elif type(value) == long: value = '%d'   % value # prevent pending 'L'
    00212             sp = StringProperty( name , str(value))
                self._optsvc.addPropertyToCatalogue( self._name , sp )

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

Definition at line 174 of file Bindings.py.

    00175                            :
    00176         if not self._ip : self.retrieveInterface()
            return self._ip

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

Reimplemented in GaudiPython::Bindings::iAlgTool.

Definition at line 254 of file Bindings.py.

    00255                    :
    00256         return self._name
    00257
    #----iService class---------------------------------------------------------------------

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

Definition at line 236 of file Bindings.py.

    00237                         :
    00238         dct = {}
    00239         props = None
    00240         ip = self.getInterface()
    00241         if ip :
    00242             props = ip.getProperties()
    00243             propsFrom = self._name # "interface"
    00244         else:
    00245             props = self._optsvc.getProperties( self._name )
    00246             propsFrom = "jobOptionsSvc"
    00247         if props:
    00248             for p in props :
    00249                 try:
    00250                     dct[p.name()] = PropertyEntry(p)
    00251                 except (ValueError,TypeError),e:
    00252                     raise ValueError, "gaudimodule.iProperty.properties(): %s%s processing property %s.%s = %s" % \
    00253                           (e.__class__.__name__, e.args, propsFrom, p.name(), p.value())
            return dct

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

Reimplemented in GaudiPython::Bindings::iService, GaudiPython::Bindings::iAlgorithm, and GaudiPython::Bindings::iAlgTool.

Definition at line 177 of file Bindings.py.

    00178                                 :
            pass

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

- /afs/cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v23r0/GaudiPython/python/GaudiPython/Bindings.py

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines