Gaudi Framework, version v21r4

Home   Generated: 7 Sep 2009

GaudiPython::Bindings::iProperty Class Reference

Inheritance diagram for GaudiPython::Bindings::iProperty:

Inheritance graph
[legend]

List of all members.


Detailed Description

Python equivalent to the C++ Property interface 

Definition at line 162 of file Bindings.py.


Public Member Functions

def __init__
def getInterface
def retrieveInterface
def __call_interface_method__
def __setattr__
def __getattr__
def properties
def name

Member Function 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 164 of file Bindings.py.

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

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

Definition at line 172 of file Bindings.py.

00172                          :
00173     if not self._ip : self.retrieveInterface()
00174     return self._ip
  def retrieveInterface(self) :

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

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

Definition at line 175 of file Bindings.py.

00175                               :
00176     pass
  def __call_interface_method__(self,ifname,method,*args):

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

Definition at line 177 of file Bindings.py.

00177                                                          :
00178     if not getattr(self,ifname) : self.retrieveInterface()
00179     return getattr(getattr(self,ifname),method)(*args)
  def __setattr__(self, name, value):

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

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

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 retrieevd from JobOptionsCatalogue    

Definition at line 207 of file Bindings.py.

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

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

Definition at line 230 of file Bindings.py.

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

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

Reimplemented in GaudiPython::Bindings::iAlgTool.

Definition at line 248 of file Bindings.py.

00248                  :
00249     return self._name
00250 
00251 #----iService class--------------------------------------------------------------------- 
class iService(iProperty) :


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

Generated at Mon Sep 7 18:26:33 2009 for Gaudi Framework, version v21r4 by Doxygen version 1.5.6 written by Dimitri van Heesch, © 1997-2004