Gaudi Framework, version v24r2

Home   Generated: Wed Dec 4 2013
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Public Member Functions | List of all members
GaudiPython.Bindings.iProperty Class Reference
Inheritance diagram for GaudiPython.Bindings.iProperty:
Inheritance graph
[legend]
Collaboration diagram for GaudiPython.Bindings.iProperty:
Collaboration graph
[legend]

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 
)

Definition at line 166 of file Bindings.py.

167  def __init__(self, name, ip = None) :
168  if ip : self.__dict__['_ip'] = InterfaceCast(gbl.IProperty)(ip)
169  else : self.__dict__['_ip'] = None
170  self.__dict__['_svcloc'] = gbl.Gaudi.svcLocator()
171  optsvc = Helper.service(self._svcloc,'JobOptionsSvc')
172  if optsvc : self.__dict__['_optsvc'] = InterfaceCast(gbl.IJobOptionsSvc)(optsvc)
173  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.

180  def __call_interface_method__(self,ifname,method,*args):
181  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.

214  def __getattr__(self, name ):
215  """
216  The method which returns the value for the given property
217  - In the case of the valid instance it returns the valid property value through IProperty interface
218  - In the case of placeholder the property value is retrieved from JobOptionsCatalogue
219  """
220  ip = self.getInterface()
221  if ip :
222  if not gbl.Gaudi.Utils.hasProperty ( ip , name ) :
223  raise AttributeError, 'property %s does not exist' % name
224  prop = ip.getProperty(name)
225  if StringProperty == type( prop ) : return prop.value()
226  elif StringPropertyRef == type( prop ) : return prop.value()
227  try: return eval( prop.toString(), {}, {} )
228  except : return prop.value()
229  else :
230  props = self._optsvc.getProperties(self._name)
231  for p in props :
232  if not p.name() == name : continue
233  # from JobOptionsSvc we always have only strings
234  try: return eval( p.value(), {}, {} )
235  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.

183  def __setattr__(self, name, value):
184  """
185  The method which is used for setting the property from the given value.
186  - In the case of the valid instance it sets the property through IProperty interface
187  - In the case of placeholder the property is added to JobOptionsCatalogue
188  """
189  if hasattr( value, 'toStringProperty' ):
190  # user defined behaviour
191  value = '%s' % value.toStringProperty()
192  ip = self.getInterface()
193  if ip :
194  if not gbl.Gaudi.Utils.hasProperty ( ip , name ) :
195  raise AttributeError, 'property %s does not exist' % name
196  prop = ip.getProperty(name)
197  if not hasattr ( prop , 'value' ) or not type( value ) == type( prop.value() ) :
198  if tuple == type( value ) : value = str(value)
199  elif hasattr ( value , 'toString' ) : value = value.toString()
200  elif not long == type( value ) : value = '%s' % value
201  else : value = '%d' % value
202  if prop.fromString( value ).isFailure() :
203  raise AttributeError, 'property %s could not be set from %s' % (name,value)
204  else :
205  if not prop.setValue( value ) :
206  raise AttributeError, 'property %s could not be set from %s' % (name,value)
207  else :
208  if type(value) == str : value = '"%s"' % value # need double quotes
209  elif type(value) == tuple : value = str(value)
210  elif hasattr( value , 'toString' ) : value = value.toString()
211  elif type(value) == long: value = '%d' % value # prevent pending 'L'
212  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.

175  def getInterface(self) :
176  if not self._ip : self.retrieveInterface()
return self._ip
def GaudiPython.Bindings.iProperty.name (   self)

Definition at line 254 of file Bindings.py.

255  def name(self) :
256  return self._name
257 
#----iService class---------------------------------------------------------------------
def GaudiPython.Bindings.iProperty.properties (   self)

Definition at line 236 of file Bindings.py.

237  def properties(self):
238  dct = {}
239  props = None
240  ip = self.getInterface()
241  if ip :
242  props = ip.getProperties()
243  propsFrom = self._name # "interface"
244  else:
245  props = self._optsvc.getProperties( self._name )
246  propsFrom = "jobOptionsSvc"
247  if props:
248  for p in props :
249  try:
250  dct[p.name()] = PropertyEntry(p)
251  except (ValueError,TypeError),e:
252  raise ValueError, "gaudimodule.iProperty.properties(): %s%s processing property %s.%s = %s" % \
253  (e.__class__.__name__, e.args, propsFrom, p.name(), p.value())
return dct
def GaudiPython.Bindings.iProperty.retrieveInterface (   self)

Definition at line 177 of file Bindings.py.

178  def retrieveInterface(self) :
pass

The documentation for this class was generated from the following file:
Generated at Wed Dec 4 2013 14:33:22 for Gaudi Framework, version v24r2 by Doxygen version 1.8.2 written by Dimitri van Heesch, © 1997-2004