| # Gaudi Framework, version v23r1 |

Home |  | Generated: Wed Feb 29 2012

Classes | Public Member Functions | Static Public Attributes | Private Member Functions | Private Attributes | Static Private Attributes

# Configurable::Configurable Class Reference

Inheritance diagram for Configurable::Configurable:
[legend]
Collaboration diagram for Configurable::Configurable:
[legend]

List of all members.

## Classes
class | DefaultName
| for detecting the default name More...
## Public Member Functions
def | __new__
def | __init__
def | __getstate__
def | __getnewargs__
def | __setstate__
def | __len__
def | __iter__
def | __deepcopy__
def | __iadd__
def | __getattr__
def | __setattr__
def | __delattr__
def | __nonzero__
def | remove
def | removeAll
def | copyChild
def | setParent
def | getParent
def | hasParent
def | copyChildAndSetParent
def | getChildren
def | getTools
def | children
def | getAllChildren
def | getSequence
def | setup
def | getProperties
def | getValuedProperties
def | properties
def | getDefaultProperties
def | getDefaultProperty
def | getProp
def | setProp
def | isPropertySet
def | getType
def | getName
def | name
def | getJobOptName
def | isPublic
def | jobOptName
def | getFullName
def | getFullJobOptName
def | getPrintTitle
def | getTitleName
def | setDefaults
def | clone
def | splitName
def | addTool
def | __repr__
def | __str__
## Static Public Attributes
string | indentUnit = '| '
int | printHeaderWidth = 100
int | printHeaderPre = 5
dictionary | allConfigurables = {}
dictionary | configurableServices = {}
## Private Member Functions
def | _isInSetDefaults
def | __setupServices
def | __setupDlls
def | __setupDefaults
def | _printHeader
def | _printFooter
## Private Attributes
| __children
| __tools
| _name
| _inSetDefaults
| _initok
| _setupok
## Static Private Attributes
| __metaclass__ = ConfigurableMeta.ConfigurableMeta
tuple | __slots__
| _configurationLocked = False

## Detailed Description

    Base class for Gaudi components that implement the IProperty interface.
       Provides most of the boilerplate code, but the actual useful classes
       are its derived ConfigurableAlgorithm, ConfigurableService, and
       ConfigurableAlgTool.

Definition at line 87 of file Configurable.py.

## Constructor & Destructor Documentation

def Configurable::Configurable::__init__ | ( |  | self,
|  |  | name = `DefaultName`
| ) |  |

Reimplemented in Configurable::ConfigurableGeneric, Configurable::ConfigurableAlgorithm, Configurable::ConfigurableAlgTool, and Configurable::ConfigurableAuditor.

Definition at line 254 of file Configurable.py.

    00255                                             :
    00256         # check class readiness, all required overloads should be there now
    00257         klass = self.__class__
    00258
    00259         # this is an abstract class
    00260         if klass == Configurable:
    00261             raise TypeError, "%s is an ABC and can not be instantiated" % str(Configurable)
    00262
    00263         # the following methods require overloading
    00264         #NOT YET  meths = { 'getServices'   : 1,    # retrieve list of services to configure
    00265         meths = { 'getDlls'       : 1,    # provide list of Dlls to load
    00266                   'getGaudiType'  : 1,    # return string describing component class
    00267                   'getHandle'     : 1 }   # provide access to C++ side component instance
    00268 #                'getType'       : 1 }   # return the type of the actual C++ component
    00269
    00270         for meth, nArgs in meths.items():
    00271             try:
    00272                 f = getattr( klass, meth ).im_func
    00273             except AttributeError:
    00274                 raise NotImplementedError, "%s is missing in class %s" % (meth,str(klass))
    00275
    00276             # in addition, verify the number of arguments w/o defaults
    00277             nargcount = f.func_code.co_argcount
    00278             ndefaults = f.func_defaults and len(f.func_defaults) or 0
    00279             if not nargcount - ndefaults <= nArgs <= nargcount:
    00280                 raise TypeError, "%s.%s requires exactly %d arguments" % (klass,meth,nArgs)
    00281
    00282         # for using this Configurable as a (Gaudi) sequence
    00283         self.__children = []
    00284         self.__tools = {}
    00285
    00286         # know who we are
    00287         if name == Configurable.DefaultName :
    00288             if hasattr(self.__class__, 'DefaultedName' ) :
    00289                 self._name = self.__class__.DefaultedName
    00290             else :
    00291                 self._name = self.getType()
    00292         else :
    00293             self._name = name
    00294
    00295         # set to True when collecting defaults, False otherwise
    00296         self._inSetDefaults = False
    00297
    00298         # for later, in case __init__ itself is overridden
    00299         self._initok = True
    00300
    00301         # for debugging purposes (temporary)
    00302         self._setupok = False

## Member Function Documentation

def Configurable::Configurable::__deepcopy__ | ( |  | self,
|  |  | memo
| ) |  |

Reimplemented in Configurable::ConfigurableGeneric, Configurable::ConfigurableAlgorithm, and Configurable::ConfigurableService.

Definition at line 334 of file Configurable.py.

    00335                                   :
    00336         newconf = object.__new__( self.__class__ )
    00337         self.__class__.__init__( newconf, self.getName() )
    00338
    00339         for proxy in self._properties.values():
    00340             try:
    00341                 proxy.__set__( newconf, proxy.__get__( self ) )
    00342             except AttributeError:
    00343                 pass                   # means property was not set for self
    00344
    00345         for c in self.__children:
    00346             newconf += c              # processes proper copy semantics
    00347
    00348         return newconf

def Configurable::Configurable::__delattr__ | ( |  | self,
|  |  | attr
| ) |  |

Definition at line 401 of file Configurable.py.

    00402                                  :
    00403         # remove as property, otherwise try as child
    00404         try:
    00405             # remove history etc., then reset to default (in case set before)
    00406             prop = self._properties[ attr ]
    00407             prop.__delete__( self )
    00408             prop.__set__( self, prop.default )
    00409             return               # reaches here? was property: done now
    00410         except KeyError:
    00411             pass
    00412         # otherwise, remove the private tool
    00413         if attr in self.__tools :
    00414             del self.__tools[attr]
    00415
    00416         # otherwise, remove child, if one is so named
    00417         for c in self.__children:
    00418             if c.getName() == attr:
    00419                 self.__children.remove( c )
    00420
    00421         # potentially, there are left over caches (certain user derived classes)
    00422         try:
    00423             del self.__dict__[ attr ]
    00424         except (AttributeError,KeyError):
    00425             pass

def Configurable::Configurable::__getattr__ | ( |  | self,
|  |  | attr
| ) |  |

Definition at line 382 of file Configurable.py.

    00382                                  :  # until ToolProperties exist ...
    00383
    00384         if attr in self.__tools : return self.__tools[attr]
    00385
    00386         for c in self.__children:
    00387             if c.getName() == attr:
    00388                 return c
    00389
    00390         raise AttributeError( "'%s' object has no attribute '%s'" % (self.__class__,attr) )
    00391

def Configurable::Configurable::__getnewargs__ | ( |  | self ) |

Definition at line 317 of file Configurable.py.

    00318                              :
    00319         return (self._name,)

def Configurable::Configurable::__getstate__ | ( |  | self ) |

Definition at line 304 of file Configurable.py.

    00305                            :
    00306         dict = {}
    00307         for name, proxy in self._properties.items():
    00308             try:
    00309                 dict[ name ] = proxy.__get__( self )
    00310             except AttributeError:
    00311                 pass
    00312
    00313         dict[ '_Configurable__children' ] = self.__children
    00314         dict[ '_Configurable__tools' ] = self.__tools
    00315         dict[ '_name' ] = self._name
    00316         return dict

def Configurable::Configurable::__iadd__ | ( |  | self,
|  |  | configs,
|  |  | descr = `None`
| ) |  |

Definition at line 350 of file Configurable.py.

    00351                                                :
    00352         if not type(configs) in (list,tuple):
    00353             configs = ( configs, )
    00354
    00355         joname = self.getJobOptName()
    00356
    00357         for cfg in configs:
    00358             # prevent type mismatches
    00359             if not isinstance( cfg, Configurable ):
    00360                 raise TypeError( "'%s' is not a Configurable" % str(cfg) )
    00361
    00362             cc = self.copyChildAndSetParent( cfg, joname )
    00363
    00364             # filters dupes; usually "ok" (backdoor should catch them)
    00365             ccjo = cc.getJobOptName()
    00366             for c in self.__children:
    00367                 if c.getJobOptName() == ccjo:
    00368                     log.error( 'attempt to add a duplicate ... dupe ignored%s', error_explanation )
    00369                     break
    00370             else:
    00371                 self.__children.append( cc )
    00372
    00373             try:
    00374                 if descr:         # support for tool properties
    00375                     descr.__set__( self, cc )
    00376                 else:
    00377                     setattr( self, cc.getName(), cc )
    00378             except AttributeError:
    00379                 pass              # to allow free addition of tools/subalgorithms
    00380
    00381         return self

def Configurable::Configurable::__iter__ | ( |  | self ) |

Definition at line 330 of file Configurable.py.

    00331                         :
    00332         return iter( self.__children )

def Configurable::Configurable::__len__ | ( |  | self ) |

Definition at line 327 of file Configurable.py.

    00328                        :
    00329         return len( self.__children )

def Configurable::Configurable::__new__ | ( |  | cls,
|  |  | args,
|  |  | kwargs
| ) |  |

    To Gaudi, any object with the same type/name is the same object. Hence,
       this is mimicked in the configuration: instantiating a new Configurable
       of a type with the same name will return the same instance.

Definition at line 119 of file Configurable.py.

    00120                                         :
    00121         """To Gaudi, any object with the same type/name is the same object. Hence,
    00122            this is mimicked in the configuration: instantiating a new Configurable
    00123            of a type with the same name will return the same instance."""
    00124
    00125         global log
    00126         # try to get the name of the Configurable (having a name is compulsory)
    00127         if 'name' in kwargs:
    00128         # simple keyword (by far the easiest)
    00129             name = kwargs[ 'name' ]
    00130         elif 'name' in cls.__init__.func_code.co_varnames:
    00131         # either positional in args, or default
    00132             index =  list(cls.__init__.func_code.co_varnames).index( 'name' )
    00133             try:
    00134              # var names index is offset by one as __init__ is to be called with self
    00135                 name = args[ index - 1 ]
    00136             except IndexError:
    00137              # retrieve default value, then
    00138                 name = cls.__init__.func_defaults[ index - (len(args)+1) ]
    00139         else:
    00140         # positional index is assumed (will work most of the time)
    00141             try:
    00142                 name = args[1]    # '0' is for self
    00143             except (IndexError,TypeError):
    00144                 raise TypeError( 'no "name" argument while instantiating "%s"' % cls.__name__ )
    00145
    00146         argname = name
    00147         if name == Configurable.DefaultName :
    00148             if hasattr(cls, 'DefaultedName' ) :
    00149                 name = cls.DefaultedName
    00150             else :
    00151                 name = cls.getType()
    00152         elif not name or type(name) != str:
    00153         # unnamed, highly specialized user code, etc. ... unacceptable
    00154             raise TypeError( 'could not retrieve name from %s.__init__ arguments' % cls.__name__ )
    00155
    00156         # Handle the case of global tools to prepend ToolSvc in the name.
    00157         # This is needed for compatibility with old JobOptions files being read
    00158         if issubclass( cls, ConfigurableAlgTool) and '.' not in name :
    00159             name = 'ToolSvc.' + name
    00160
    00161         # close backdoor access to otherwise private subalgs/tools
    00162         #PM if 0 <= name.find( '.' ):
    00163         #PM # temp protection for old style types
    00164         #PM   from OldStyleConfig import GenericConfigurable
    00165         #PM   if not issubclass( cls, GenericConfigurable ): # except raised for new types only
    00166         #PM      raise NameError( '"%s": backdoor access to private configurables not allowed' % name )
    00167
    00168         # ordinary recycle case
    00169         if name in cls.configurables:
    00170             conf = cls.configurables[ name ]
    00171             if name != argname:      # special case: user derived <-> real ... make same
    00172                 cls.configurables[ conf.getType() ] = conf
    00173             #---PM: Initialize additional properties
    00174             for n,v in kwargs.items():
    00175                 if n != "name": # it should not be confused with a normal property
    00176                     setattr(conf, n, v)
    00177             if not cls._configurationLocked and not "_enabled" in kwargs and isinstance(conf, ConfigurableUser):
    00178                 # Ensure that the ConfigurableUser gets enabled if nothing is
    00179                 # specified in the constructor.
    00180                 setattr(conf, "_enabled", True)
    00181             return conf
    00182
    00183         # a couple of special cases (note that these cases don't mix)
    00184         spos = name.find( '/' )
    00185         ti_name = None
    00186         if spos < 0:
    00187             ti_name = "%s/%s" % (name,name)
    00188             if ti_name in cls.configurables:
    00189                 # support for old-style name as type/name lookup where name==type
    00190                 return cls.configurables[ ti_name ]
    00191
    00192         i_name = None
    00193         if spos > 0:
    00194             i_name = name[:spos]
    00195             if i_name == name[spos+1:] and i_name in cls.configurables:
    00196             # this is the opposite of the above special case
    00197                 return cls.configurables[ i_name ]
    00198
    00199         # the following is purely for debugging support and should realistically bomb
    00200         conf = cls.allConfigurables.get( name, None ) or\
    00201                  (spos < 0 and cls.allConfigurables.get( ti_name, None )) or\
    00202                  (spos > 0 and i_name == name[spos+1:] and cls.allConfigurables.get( i_name, None ))
    00203         if conf:                    # wrong type used?
    00204             if conf.__class__ is ConfigurableGeneric :
    00205                 #  If the instance found is ConfigurableGeneric then
    00206                 #  we create a new one with the proper type and fill with
    00207                 #  the contents of the generic one
    00208                 newconf = object.__new__( cls )
    00209                 cls.__init__( newconf, *args, **kwargs )
    00210                 #  initialize with the properties of generic configurable
    00211                 #  (we map the names of the properties to lowercase versions because
    00212                 #  old options are not case sensitive)
    00213                 names = {}
    00214                 for n in newconf.__slots__:
    00215                     names[n.lower()] = n
    00216                 for n in conf._properties:
    00217                     if names[n.lower()] != n:
    00218                         log.warning( "Option '%s' was used for %s, but the correct spelling is '%s'"%(n,name,names[n.lower()]) )
    00219                     setattr(newconf, names[n.lower()], getattr( conf, n ) )
    00220                 for n,v in kwargs.items():
    00221                     setattr(newconf, n, v)
    00222                 cls.configurables[ name ] = newconf
    00223                 cls.allConfigurables[ name ] = newconf
    00224                 return newconf
    00225             else :
    00226                 #  will be an actual error in the future (now only report as such)
    00227                 log.error( 'attempt to redefine type of "%s" (was: %s, new: %s)%s',
    00228                 name, conf.__class__.__name__, cls.__name__, error_explanation )
    00229                 #  in the future:
    00230                 #  return None             # will bomb on use (or go unharmed on non-use)
    00231                 #  for now, allow use through allConfigurables lookup
    00232                 #---PM: Initialize additional properties
    00233                 for n,v in kwargs.items():
    00234                     setattr(conf, n, v)
    00235                 return conf
    00236
    00237         # still here: create a new instance and initialize it
    00238         conf = object.__new__(cls)
    00239         cls.__init__( conf, *args, **kwargs )
    00240
    00241         # update normal, per-class cache
    00242         cls.configurables[ name ] = conf
    00243
    00244         for base in cls.__bases__:
    00245             if base.__name__ == 'ConfigurableService':
    00246                 cls.configurableServices[ name ] = conf
    00247
    00248         # update generics super-cache, if needed
    00249         cls.allConfigurables[ name ] = conf
    00250         #-->PM#if hasattr( cls, 'getType' ) and name.find('/') < 0:
    00251         #-->PM#   cls.allConfigurables[ cls.getType() + '/' + name ] = conf
    00252
    00253         return conf

def Configurable::Configurable::__nonzero__ | ( |  | self ) |

Definition at line 426 of file Configurable.py.

    00427                          :
    00428         return True
    00429

def Configurable::Configurable::__repr__ | ( |  | self ) |

Definition at line 827 of file Configurable.py.

    00828                         :
    00829         return '<%s at %s>' % (self.getFullJobOptName(),hex(id(self)))

def Configurable::Configurable::__setattr__ | ( |  | self,
|  |  | name,
|  |  | value
| ) |  |

Reimplemented in Configurable::ConfigurableGeneric.

Definition at line 392 of file Configurable.py.

    00393                                          :
    00394         if self._configurationLocked:
    00395             raise RuntimeError("%s: Configuration cannot be modified after the ApplicationMgr has been started."%self.name())
    00396         try :
    00397             super( Configurable, self ).__setattr__( name, value )
    00398         except AttributeError:
    00399             raise AttributeError( "Configurable '%s' does not have property '%s'."
    00400                                   % ( self.__class__.__name__, name) )

def Configurable::Configurable::__setstate__ | ( |  | self,
|  |  | dict
| ) |  |

Definition at line 320 of file Configurable.py.

    00321                                    :
    00322         self._initok = True
    00323         for n, v in dict.items():
    00324             setattr (self, n, v)
    00325         return

def Configurable::Configurable::__setupDefaults | ( |  | self ) | `[private]`

Definition at line 806 of file Configurable.py.

    00807                                :
    00808         # set handle defaults flags to inform __setattr__ that it is being
    00809         # called during setDefaults of the concrete Configurable
    00810         self._inSetDefaults = True
    00811         self.setDefaults( self )
    00812         self._inSetDefaults = False

def Configurable::Configurable::__setupDlls | ( |  | self ) | `[private]`

Definition at line 795 of file Configurable.py.

    00796                            :
    00797         dlls = self.getDlls()
    00798         if not dlls:
    00799             dlls = []
    00800         elif type(dlls) == types.StringType:
    00801             dlls = [ dlls ]
    00802
    00803         from __main__ import theApp
    00804         dlls = filter( lambda d: d not in theApp.Dlls, dlls )
    00805         if dlls: theApp.Dlls += dlls

def Configurable::Configurable::__setupServices | ( |  | self ) | `[private]`

Definition at line 778 of file Configurable.py.

    00779                                :
    00780         #svcs = self.getServices()
    00781         #if not svcs:
    00782         svcs = []
    00783         #elif type(svcs) == types.StringType:
    00784         #   svcs = [ svcs ]
    00785
    00786         import __main__
    00787         for svc in svcs:
    00788             handle = __main__.Service( svc )
    00789             # services should be configurables as well, but aren't for now
    00790             # handle.setup()
    00791
    00792             # allow Configurable to make some changes
    00793             if hasattr( self, 'configure' + svc ):
    00794                 eval( 'self.configure' + svc + '( handle )' )

def Configurable::Configurable::__str__ | ( |  | self,
|  |  | indent = `0`,
|  |  | headerLastIndentUnit = `indentUnit`
| ) |  |

Definition at line 830 of file Configurable.py.

    00831                                                                     :
    00832         global log  # to print some info depending on output level
    00833         indentStr = indent*Configurable.indentUnit
    00834         # print header
    00835         title = self.getPrintTitle()
    00836         # print line to easily see start-of-configurable
    00837         if indent > 0:
    00838             headerIndent = (indent-1)*Configurable.indentUnit + headerLastIndentUnit
    00839         else:
    00840             headerIndent = ''
    00841         rep = Configurable._printHeader( headerIndent, title )
    00842         rep += os.linesep
    00843         # print own properties
    00844         props = self.getProperties()
    00845         defs = self.getDefaultProperties()
    00846         if not props:
    00847             rep += indentStr + '|-<no properties>' + os.linesep
    00848         else:
    00849             # get property name with
    00850             nameWidth = 0
    00851             for p in props.keys():
    00852                 nameWidth=max(nameWidth,len(p))
    00853             for p, v in props.items():
    00854                 # start with indent and property name
    00855                 prefix = indentStr + '|-%-*s' % (nameWidth,p)
    00856                 # add memory address for debugging (not for defaults)
    00857                 if log.isEnabledFor( logging.DEBUG ):
    00858                     if v != Configurable.propertyNoValue:
    00859                         address = ' @%11s' % hex(id(v))
    00860                     else:
    00861                         address = 13*' '
    00862                     prefix += address
    00863                 # add value and default
    00864                 default = defs.get(p)
    00865                 if v == Configurable.propertyNoValue:
    00866                     # show default value as value, and no extra 'default'
    00867                     strVal = repr(default)
    00868                     strDef = None
    00869                 else:
    00870                     # convert configurable to handle
    00871                     if hasattr(v,"getGaudiHandle"):
    00872                         vv = v.getGaudiHandle()
    00873                     else:
    00874                         vv = v
    00875                     if isinstance(vv,GaudiHandle) or isinstance(vv,GaudiHandleArray):
    00876                         strVal = repr(vv)
    00877                         if hasattr(default,"toStringProperty"): # the default may not be a GaudiHandle (?)
    00878                             strDef = repr(default.toStringProperty())
    00879                         else:
    00880                             strDef = repr(default)
    00881                         if strDef == repr(vv.toStringProperty()):
    00882                             strDef = None
    00883                     else:
    00884                         strVal = repr(vv)
    00885                         strDef = repr(default)
    00886                 # add the value
    00887                 line = prefix + ' = ' + strVal
    00888                 # add default if present
    00889                 if strDef is not None:
    00890                     # put default on new line if too big
    00891                     if len(line) + len(strDef) > Configurable.printHeaderWidth:
    00892                         line += os.linesep + indentStr + '| ' + (len(prefix)-len(indentStr)-3)*' '
    00893                     line += '  (default: %s)' % (strDef,)
    00894                 # add the line to the total string
    00895                 rep += line + os.linesep
                    # print out full private configurables

def Configurable::Configurable::_isInSetDefaults | ( |  | self ) | `[private]`

Definition at line 775 of file Configurable.py.

    00776                                 :
    00777         return self._inSetDefaults

def Configurable::Configurable::_printFooter | ( |  | indentStr,
|  |  | title
| ) |  | `[private]`

Definition at line 821 of file Configurable.py.

    00822                                         :
    00823         preLen  = Configurable.printHeaderPre
    00824         postLen = Configurable.printHeaderWidth - preLen - 12 - len(title)# - len(indentStr)
    00825         postLen = max(preLen,postLen)
    00826         return indentStr + '\\%s (End of %s) %s' % (preLen*'-',title,postLen*'-')

def Configurable::Configurable::_printHeader | ( |  | indentStr,
|  |  | title
| ) |  | `[private]`

Definition at line 814 of file Configurable.py.

    00815                                         :
    00816         preLen  = Configurable.printHeaderPre
    00817         postLen = Configurable.printHeaderWidth - preLen - 3 - len(title)# - len(indentStr)
    00818         postLen = max(preLen,postLen)
    00819         return indentStr + '/%s %s %s' % (preLen*'*',title,postLen*'*')

def Configurable::Configurable::addTool | ( |  | self,
|  |  | tool,
|  |  | name = `None`
| ) |  |

Definition at line 755 of file Configurable.py.

    00756                                            :
    00757         if isclass(tool) and issubclass(tool, ConfigurableAlgTool):
    00758             if name is None:
    00759                 name = tool.__name__
    00760             priv_tool = tool( self.getName()+ '.' + name )
    00761         elif isinstance(tool, ConfigurableAlgTool):
    00762             if name is None:
    00763                 name = tool.splitName()[1]
    00764             priv_tool = tool.clone( self.getName()+ '.' + name )
    00765         else:
    00766             if isclass(tool):
    00767                 classname = tool.__name__
    00768             else:
    00769                 classname = type(tool).__name__
    00770             raise TypeError, "addTool requires AlgTool configurable. Got %s type" % classname
    00771         self.__tools[name] =  priv_tool
    00772         if name in self.__slots__:
    00773             # this is to avoid that the property hides the tool
    00774             setattr(self,name,self.__tools[name])

def Configurable::Configurable::children | ( |  | self ) |

Definition at line 478 of file Configurable.py.

    00479                         :
    00480         log.error( "children() is deprecated, use getChildren() instead for consistency" )
    00481         log.error( "getChildren() returns a copy; to add a child, use 'parent += child'%s",
    00482                    error_explanation )
    00483         return self.__children       # by ref, for compatibility

def Configurable::Configurable::clone | ( |  | self,
|  |  | name = `None`,
|  |  | kwargs
| ) |  |

Definition at line 710 of file Configurable.py.

    00711                                               :
    00712         if not name :
    00713             if hasattr(self, 'DefaultedName' ) : name = self.DefaultedName
    00714             else                               : name = self.getType()
    00715
    00716         newconf = Configurable.__new__( self.__class__, name )
    00717         self.__class__.__init__( newconf, name )
    00718
    00719         for proxy in self._properties.values():
    00720             try :
    00721                 value = proxy.__get__( self )
    00722                 if type(value) in [ str, list, dict, tuple ]:
    00723                     # clone the values of the properties for basic types
    00724                     value = type(value)(value)
    00725                 proxy.__set__( newconf, value )
    00726             except AttributeError:
    00727                 pass
    00728
    00729         for c in self.__children:
    00730             newconf += c              # processes proper copy semantics
    00731
    00732         for n , t in self.__tools.items():
    00733             newconf.addTool(t, n)
    00734
    00735         for name, value in kwargs.items():
    00736             setattr(newconf, name, value)
    00737
    00738         return newconf

def Configurable::Configurable::copyChild | ( |  | self,
|  |  | child
| ) |  |

Reimplemented in Configurable::ConfigurableService.

Definition at line 440 of file Configurable.py.

    00441                                 :
    00442         return copy.deepcopy( child )

def Configurable::Configurable::copyChildAndSetParent | ( |  | self,
|  |  | cfg,
|  |  | parent
| ) |  |

Definition at line 452 of file Configurable.py.

    00453                                               :
    00454         cc = self.copyChild( cfg )
    00455
    00456         if hasattr( cc, 'setParent' ) and parent:
    00457             try:
    00458                 cc.setParent( parent )
    00459             except RuntimeError, e:
    00460                 # temporary backdoor resolution for compatibility
    00461                 log.error( str(e) + '%s', error_explanation )
    00462                 ccbd = cc.configurables[ cc.getJobOptName() ]
    00463
    00464                 # merge properties, new over pre-existing
    00465                 for proxy in self._properties.values():
    00466                     if proxy.history.has_key( cc ):
    00467                         proxy.__set__( ccbd, proxy.__get__( cc ) )
    00468
    00469                 # consolidate
    00470                 cc = ccbd
    00471         return cc

def Configurable::Configurable::getAllChildren | ( |  | self ) |

    Get all (private) configurable children, both explicit ones (added with +=)
    and the ones in the private GaudiHandle properties

Definition at line 484 of file Configurable.py.

    00485                               :
    00486         """Get all (private) configurable children, both explicit ones (added with +=)
    00487         and the ones in the private GaudiHandle properties"""
    00488         childs = []
    00489         # add private configurable properties (also inside handles)
    00490         for proxy in self._properties.values():
    00491             try:
    00492                 c = proxy.__get__( self )
    00493             except AttributeError:
    00494                 pass
    00495             else:
    00496                 if isinstance(c,Configurable) and not c.isPublic():
    00497                     childs.append(c)
    00498                 elif isinstance(c,GaudiHandle):
    00499                     try:
    00500                         conf = c.configurable
    00501                     except AttributeError:
    00502                         pass
    00503                     else:
    00504                         if not conf.isPublic():
    00505                             childs.append(conf)
    00506                 elif isinstance(c,GaudiHandleArray):
    00507                     # only setup private arrays
    00508                     if not c.isPublic():
    00509                         for ci in c:
    00510                             if isinstance(ci,Configurable):
    00511                                 childs.append(ci)
    00512                             else:
    00513                                 try:
    00514                                     conf = ci.configurable
    00515                                 except AttributeError:
    00516                                     pass
    00517                                 else:
    00518                                     childs.append(conf)
    00519
    00520         # add explicit children
    00521         childs += self.__children
    00522         return childs

def Configurable::Configurable::getChildren | ( |  | self ) |

Definition at line 472 of file Configurable.py.

    00473                            :
    00474         return self.__children[:]    # read only

def Configurable::Configurable::getDefaultProperties | ( |  | cls ) |

Definition at line 602 of file Configurable.py.

    00603                                    :
    00604         class collector:
    00605             pass
    00606
    00607         # user provided defaults
    00608         c = collector()
    00609         cls.setDefaults( c )
    00610
    00611         # defaults from C++
    00612         for k,v in cls._properties.items():
    00613             if not k in c.__dict__ and hasattr( v, 'default' ):
    00614                 c.__dict__[ k ] = v.default
    00615
    00616         return c.__dict__

def Configurable::Configurable::getDefaultProperty | ( |  | cls,
|  |  | name
| ) |  |

Definition at line 618 of file Configurable.py.

    00619                                        :
    00620         class collector:
    00621             pass
    00622
    00623         # user provided defaults
    00624         c = collector()
    00625         cls.setDefaults( c )
    00626
    00627         if name in c.__dict__:
    00628             return c.__dict__[ name ]
    00629
    00630         # defaults from C++
    00631         try:
    00632             v = cls._properties[name]
    00633             if hasattr( v, 'default' ):
    00634                 return v.default
    00635         except KeyError:
    00636             pass
    00637
    00638         return None

def Configurable::Configurable::getFullJobOptName | ( |  | self ) |

Definition at line 695 of file Configurable.py.

    00696                                  :
    00697         return "%s/%s" % (self.getType(),self.getJobOptName() or self.getName())

def Configurable::Configurable::getFullName | ( |  | self ) |

Reimplemented in Configurable::ConfigurableAlgTool.

Definition at line 692 of file Configurable.py.

    00693                             :
    00694         return str( self.getType() + '/' + self.getName() )

def Configurable::Configurable::getJobOptName | ( |  | self ) |

Reimplemented in Configurable::ConfigurableGeneric, Configurable::ConfigurableAlgorithm, Configurable::ConfigurableAlgTool, and Configurable::ConfigurableAuditor.

Definition at line 680 of file Configurable.py.

    00680                              :               # full hierachical name
    00681         return self.getName()
    00682

def Configurable::Configurable::getName | ( |  | self ) |

Definition at line 674 of file Configurable.py.

    00675                        :
    00676         return self._name

def Configurable::Configurable::getParent | ( |  | self ) |

Reimplemented in Configurable::ConfigurableAlgTool.

Definition at line 446 of file Configurable.py.

    00447                          :
    00448         return ""

def Configurable::Configurable::getPrintTitle | ( |  | self ) |

Reimplemented in Configurable::ConfigurableAlgTool.

Definition at line 698 of file Configurable.py.

    00699                            :
    00700         return self.getGaudiType() + ' ' + self.getTitleName()

def Configurable::Configurable::getProp | ( |  | self,
|  |  | name
| ) |  |

    Returns the value of the given property.

Definition at line 639 of file Configurable.py.

    00640                            :
    00641         """Returns the value of the given property.
    00642         """
    00643         if hasattr(self, name):
    00644             return getattr(self, name)
    00645         else:
    00646             return self.getDefaultProperties()[name]

def Configurable::Configurable::getProperties | ( |  | self ) |

Definition at line 561 of file Configurable.py.

    00562                              :
    00563         props = {}
    00564         for name, proxy in self._properties.items():
    00565             try:
    00566                 props[ name ] = proxy.__get__( self )
    00567             except AttributeError:
    00568                 props[ name ] = Configurable.propertyNoValue
    00569
    00570         return props

def Configurable::Configurable::getSequence | ( |  | self ) |

Definition at line 523 of file Configurable.py.

    00524                            :
    00525         elems = []
    00526         for c in self.__children:
    00527             elems.append( c.getFullName() )
    00528         return elems

def Configurable::Configurable::getTitleName | ( |  | self ) |

Definition at line 701 of file Configurable.py.

    00702                             :
    00703         if log.isEnabledFor( logging.DEBUG ):
    00704             return self.getFullJobOptName()
    00705         else:
    00706             return self.getFullName()

def Configurable::Configurable::getTools | ( |  | self ) |

Definition at line 475 of file Configurable.py.

    00476                         :
    00477         return self.__tools.values()    # read only

def Configurable::Configurable::getType | ( |  | cls ) |

Definition at line 671 of file Configurable.py.

    00672                       :
    00673         return cls.__name__

def Configurable::Configurable::getValuedProperties | ( |  | self ) |

Definition at line 571 of file Configurable.py.

    00572                                    :
    00573         props = {}
    00574         for name, proxy in self._properties.items():
    00575             if self.isPropertySet(name):
    00576                 value = proxy.__get__( self )
    00577                 if hasattr(value, 'getFullName') :
    00578                     value = value.getFullName()
    00579                 elif type(value) in [list, tuple]:
    00580                     new_value = []
    00581                     for i in value:
    00582                         if hasattr(i, 'getFullName'):
    00583                             new_value.append(i.getFullName())
    00584                         else:
    00585                             new_value.append(i)
    00586                     value = type(value)(new_value)
    00587                 elif type(value) is dict:
    00588                     new_value = {}
    00589                     for i in value:
    00590                         if hasattr(value[i], 'getFullName'):
    00591                             new_value[i] = value[i].getFullName()
    00592                         else:
    00593                             new_value[i] = value[i]
    00594                     value = new_value
    00595                 props[ name ] = value
    00596
    00597         return props

def Configurable::Configurable::hasParent | ( |  | self,
|  |  | parent
| ) |  |

Reimplemented in Configurable::ConfigurableAlgTool.

Definition at line 449 of file Configurable.py.

    00450                                  :
    00451         return False

def Configurable::Configurable::isPropertySet | ( |  | self,
|  |  | name
| ) |  |

    Tell if the property 'name' has been set or not.

    Because of a problem with list and dictionary properties, in those cases
    if the value is equal to the default, the property is considered as not
    set.

Definition at line 652 of file Configurable.py.

    00653                                  :
    00654         """Tell if the property 'name' has been set or not.
    00655
    00656         Because of a problem with list and dictionary properties, in those cases
    00657         if the value is equal to the default, the property is considered as not
    00658         set.
    00659         """
    00660         if not hasattr(self, name):
    00661             return False
    00662         else:
    00663             try:
    00664                 default = self.getDefaultProperties()[name]
    00665                 if isinstance(default, (list, dict)):
    00666                     value = getattr(self, name)
    00667                     return value != default
    00668             except KeyError:
    00669                 pass # no default found
    00670             return True

def Configurable::Configurable::isPublic | ( |  | self ) |

Reimplemented in Configurable::ConfigurableAlgTool.

Definition at line 683 of file Configurable.py.

    00684                         :
    00685         return True

def Configurable::Configurable::jobOptName | ( |  | self ) |

Definition at line 687 of file Configurable.py.

    00688                           :
    00689         log.error( "jobOptName() is deprecated, use getJobOptName() instead for consistency%s",
    00690                    error_explanation )
    00691         return self.getJobOptName()           # compatibility

def Configurable::Configurable::name | ( |  | self ) |

Definition at line 677 of file Configurable.py.

    00678                     :
    00679         return self.getName()

def Configurable::Configurable::properties | ( |  | self ) |

Definition at line 598 of file Configurable.py.

    00599                           :
    00600         return self.getProperties()           # compatibility

def Configurable::Configurable::remove | ( |  | self,
|  |  | items
| ) |  |

Definition at line 430 of file Configurable.py.

    00431                              :
    00432         if type(items) != list and type(items) != tuple:
    00433             items = [ items ]
    00434
    00435         self.__children = [ e for e in self.__children if not e in items ]

def Configurable::Configurable::removeAll | ( |  | self ) |

Definition at line 436 of file Configurable.py.

    00437                          :
    00438         self.remove( self.__children )

def Configurable::Configurable::setDefaults | ( |  | cls,
|  |  | handle
| ) |  |

Definition at line 707 of file Configurable.py.

    00708                                   :
    00709         pass

def Configurable::Configurable::setParent | ( |  | self,
|  |  | parentName
| ) |  |

Reimplemented in Configurable::ConfigurableAlgTool.

Definition at line 443 of file Configurable.py.

    00444                                      :
    00445         pass

def Configurable::Configurable::setProp | ( |  | self,
|  |  | name,
|  |  | value
| ) |  |

    Set the value of a given property

Definition at line 647 of file Configurable.py.

    00648                                   :
    00649         """Set the value of a given property
    00650         """
    00651         return setattr(self, name, value)

def Configurable::Configurable::setup | ( |  | self ) |

Definition at line 529 of file Configurable.py.

    00530                      :
    00531         # make sure base class init has been called
    00532         if not hasattr(self,'_initok') or not self._initok:
    00533         # could check more, but this is the only explanation
    00534             raise TypeError, \
    00535                "Configurable.__init__ not called in %s override" % self.__class__.__name__
    00536
    00537 #      log.debug("calling setup() on " + self.getFullJobOptName())
    00538
    00539         # setup self: this collects all values on the python side
    00540         self.__setupServices()
    00541         self.__setupDlls()
    00542         self.__setupDefaults()
    00543
    00544         # setup children
    00545         for c in self.getAllChildren():
    00546             c.setup()
    00547
    00548         # now get handle to work with for moving properties into the catalogue
    00549         handle = self.getHandle()
    00550         if not handle:
    00551             log.debug( 'no handle for %s: not transporting properties', self._name )
    00552             return                    # allowed, done early
    00553
    00554         # pass final set of properties on to handle on the C++ side or JobOptSvc
    00555         for name in self._properties.keys():
    00556             if hasattr( self, name ): # means property has python-side value/default
    00557                 setattr( handle, name, getattr(self,name) )
    00558
    00559         # for debugging purposes
    00560         self._setupok = True

def Configurable::Configurable::splitName | ( |  | self ) |

Definition at line 739 of file Configurable.py.

    00740                           :
    00741         fullname = self.getName()
    00742         dot = fullname.find('.')
    00743         if dot != -1 :
    00744             parentname = fullname[:dot]
    00745             longname = fullname[dot+1:]
    00746         else :
    00747             parentname = ''
    00748             longname = fullname
    00749         dot = longname.find('.')
    00750         if dot != -1 :
    00751             name = longname[:dot]
    00752         else :
    00753             name = longname
    00754         return parentname, name, longname

## Member Data Documentation

Configurable::Configurable::__children`[private]`

Definition at line 255 of file Configurable.py.

Configurable::Configurable::__metaclass__ = ConfigurableMeta.ConfigurableMeta`[static, private]`

Definition at line 102 of file Configurable.py.

tuple Configurable::Configurable::__slots__`[static, private]`

Initial value:

    (
           '__children',           # controlled components, e.g. private AlgTools
           '__tools',              # private AlgTools  (#PM-->)
           '_name',                # the (unqualified) component name
           '_inSetDefaults',       # currently setting default values
           '_initok',              # used to enforce base class init
           '_setupok'              # for debugging purposes (temporary)
        )

Reimplemented in Configurable::ConfigurableAlgorithm, Configurable::ConfigurableService, Configurable::ConfigurableAlgTool, Configurable::ConfigurableAuditor, and Configurable::ConfigurableUser.

Definition at line 104 of file Configurable.py.

Configurable::Configurable::__tools`[private]`

Definition at line 255 of file Configurable.py.

Configurable::Configurable::_configurationLocked = False`[static, private]`

Definition at line 117 of file Configurable.py.

Configurable::Configurable::_initok`[private]`

Definition at line 255 of file Configurable.py.

Configurable::Configurable::_inSetDefaults`[private]`

Definition at line 255 of file Configurable.py.

Configurable::Configurable::_name`[private]`

Reimplemented in Configurable::ConfigurableGeneric, and Configurable::ConfigurableAlgTool.

Definition at line 255 of file Configurable.py.

Configurable::Configurable::_setupok`[private]`

Definition at line 255 of file Configurable.py.

dictionary Configurable::Configurable::allConfigurables = {}`[static]`

Definition at line 113 of file Configurable.py.

dictionary Configurable::Configurable::configurableServices = {}`[static]`

Definition at line 114 of file Configurable.py.

string Configurable::Configurable::indentUnit = '| '`[static]`

Definition at line 98 of file Configurable.py.

int Configurable::Configurable::printHeaderPre = 5`[static]`

Definition at line 100 of file Configurable.py.

int Configurable::Configurable::printHeaderWidth = 100`[static]`

Definition at line 99 of file Configurable.py.

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

- /afs/cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v23r1/GaudiKernel/python/GaudiKernel/Configurable.py

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