| # Gaudi Framework, version v21r6 |

Home |  | Generated: 11 Nov 2009

# Configurable::ConfigurableUser Class Reference

Inheritance diagram for Configurable::ConfigurableUser:

[legend]
Collaboration diagram for Configurable::ConfigurableUser:

[legend]

List of all members.

## Detailed Description

Definition at line 1111 of file Configurable.py.

## Public Member Functions
def | __init__
def | getGaudiType
def | getDlls
def | getHandle
def | __detach_used__
def | propagateProperty
def | propagateProperties
def | __apply_configuration__
def | applyConf
## Private Member Functions
def | __addActiveUseOf
def | __addPassiveUseOf
## Private Attributes
| _enabled
| __users__
| __used_instances__
## Static Private Attributes
dictionary | __slots__
list | __used_configurables__ = []
| list of ConfigurableUser classes this one is going to modify in the __apply_configuration__ method
list | __queried_configurables__ = []
| list of ConfigurableUser classes this one is going to query in the __apply_configuration__ method

## Member Function Documentation

def Configurable::ConfigurableUser::__init__ | ( |  | self,
|  |  | name = `Configurable.DefaultName`,
|  |  | _enabled = `True`,
|  |  | kwargs |
| ) |  |  |

Definition at line 1121 of file Configurable.py.

    01121                                                                                     :
    01122         super( ConfigurableUser, self ).__init__( name )
    01123         for n, v in kwargs.items():
    01124             setattr(self, n, v)
    01125         self._enabled = _enabled
    01126         self.__users__ = []
    01127
    01128         # Needed to retrieve the actual class if the declaration in __used_configurables__
    01129         # and  __queried_configurables__ is done with strings.
    01130         from GaudiKernel.ConfigurableDb import getConfigurable as confDbGetConfigurable
    01131
    01132         # Set the list of users of the used configurables
    01133         self.__used_instances__ = []
    01134         for used in self.__used_configurables__:
    01135             try:
    01136                 if type(used) is str:
    01137                     used = confDbGetConfigurable(used)
    01138                 inst = used(_enabled = False)
    01139             except AttributeError:
    01140                 inst = used()
    01141             self.__addActiveUseOf(inst)
    01142         for queried in self.__queried_configurables__:
    01143             try:
    01144                 if type(queried) is str:
    01145                     queried = confDbGetConfigurable(used)
    01146                 inst = queried(_enabled = False)
    01147             except AttributeError:
    01148                 inst = queried()
    01149             self.__addPassiveUseOf(inst)
        def __addActiveUseOf(self, other):

def Configurable::ConfigurableUser::__addActiveUseOf | ( |  | self,
|  |  | other |
| ) |  |  | `[private]`

    Declare that we are going to modify the Configurable 'other' in our
    __apply_configuration__.

Definition at line 1150 of file Configurable.py.

    01150                                      :
    01151         """
    01152         Declare that we are going to modify the Configurable 'other' in our
    01153         __apply_configuration__.
    01154         """
    01155         self.__used_instances__.append(other)
    01156         if hasattr(other, "__users__"): # allow usage of plain Configurables
    01157             other.__users__.append(self)
        def __addPassiveUseOf(self, other):

def Configurable::ConfigurableUser::__addPassiveUseOf | ( |  | self,
|  |  | other |
| ) |  |  | `[private]`

    Declare that we are going to retrieve property values from the
    ConfigurableUser 'other' in our __apply_configuration__.

Definition at line 1158 of file Configurable.py.

    01158                                       :
    01159         """
    01160         Declare that we are going to retrieve property values from the
    01161         ConfigurableUser 'other' in our __apply_configuration__.
    01162         """
    01163         if not isinstance(other, ConfigurableUser):
    01164             raise Error("'%s': Cannot make passive use of '%s', it is not a ConfigurableUser" % (self.name(), other.name()))
    01165         other.__addActiveUseOf(self)
        def getGaudiType( self ):

def Configurable::ConfigurableUser::getGaudiType | ( |  | self | ) |

Definition at line 1166 of file Configurable.py.

    01166                             :
    01167         return 'User'
        def getDlls( self ):

def Configurable::ConfigurableUser::getDlls | ( |  | self | ) |

Definition at line 1168 of file Configurable.py.

    01168                        :
    01169         return None
        def getHandle( self ):

def Configurable::ConfigurableUser::getHandle | ( |  | self | ) |

Definition at line 1170 of file Configurable.py.

    01170                          :
    01171         return None
    01172
        def __detach_used__(self):

def Configurable::ConfigurableUser::__detach_used__ | ( |  | self | ) |

    Remove this ConfigurableUser instance from the users list of the used
    instances.

Definition at line 1173 of file Configurable.py.

    01173                              :
    01174         """
    01175         Remove this ConfigurableUser instance from the users list of the used
    01176         instances.
    01177         """
    01178         for used in self.__used_instances__:
    01179             if hasattr(used, "__users__"): # allow usage of plain Configurables
    01180                 used.__users__.remove(self)
    01181
        def propagateProperty(self, name, others = None, force = True):

def Configurable::ConfigurableUser::propagateProperty | ( |  | self,
|  |  | name,
|  |  | others = `None`,
|  |  | force = `True` |
| ) |  |  |

    Propagate the property 'name' (if set) to other configurables (if possible).
    'others' can be:
        None:
    propagate to all the entries in __used_configurables__
        a configurable instance:
    propagate only to it
        list of configurable instances:
    propagate to all of them.

    The logic is:
    - if the local property is set, the other property will be overwritten
    - local property not set and other set => keep other
    - local property not set and other not set => overwrite the default for
        ConfigurableUser instances and set the property for Configurables

Definition at line 1182 of file Configurable.py.

    01182                                                                   :
    01183         """
    01184         Propagate the property 'name' (if set) to other configurables (if possible).
    01185         'others' can be:
    01186             None:
    01187                 propagate to all the entries in __used_configurables__
    01188             a configurable instance:
    01189                 propagate only to it
    01190             list of configurable instances:
    01191                 propagate to all of them.
    01192
    01193
    01194         The logic is:
    01195         - if the local property is set, the other property will be overwritten
    01196         - local property not set and other set => keep other
    01197         - local property not set and other not set => overwrite the default for
    01198             ConfigurableUser instances and set the property for Configurables
    01199         """
    01200         # transform 'others' to a list of configurable instances
    01201         if others is None:
    01202             others = self.__used_instances__
    01203         elif type(others) not in [ list, tuple ] :
    01204             others = [ others ]
    01205         # these can be computed before the loop
    01206         local_is_set = self.isPropertySet(name)
    01207         value = self.getProp(name)
    01208         # loop over the others that do have 'name' in their slots
    01209         for other in [ o for o in others if name in o.__slots__ ]:
    01210             # If self property is set, use it
    01211             if local_is_set:
    01212                 if other.isPropertySet(name):
    01213                     log.warning("Property '%(prop)s' is set in both '%(self)s' and '%(other)s', using '%(self)s.%(prop)s'"%
    01214                                 { "self": self.name(),
    01215                                   "other": other.name(),
    01216                                   "prop": name } )
    01217                 other.setProp(name, value)
    01218             # If not, and other property also not set, propagate the default
    01219             elif not other.isPropertySet(name):
    01220                 if isinstance(other,ConfigurableUser):
    01221                     otherType = type(other._properties[name].getDefault())
    01222                     other._properties[name].setDefault(value)
    01223                     if otherType in [list, dict]:
    01224                         # Special case for list and dictionaries:
    01225                         # also set the property to the same value of the default (copy)
    01226                         other.setProp(name, otherType(value))
    01227                 else:
    01228                     other.setProp(name, value)
    01229             # If not set and other set, do nothing
    01230
        def propagateProperties(self, names = None, others = None, force = True):

def Configurable::ConfigurableUser::propagateProperties | ( |  | self,
|  |  | names = `None`,
|  |  | others = `None`,
|  |  | force = `True` |
| ) |  |  |

    Call propagateProperty for each property listed in 'names'.
    If 'names' is None, all the properties are propagated.

Definition at line 1231 of file Configurable.py.

    01231                                                                             :
    01232         """
    01233         Call propagateProperty for each property listed in 'names'.
    01234         If 'names' is None, all the properties are propagated.
    01235         """
    01236         if names is None:
    01237             # use all the non-private slots
    01238             names = [ p for p in self.__slots__ if not p.startswith("_") ]
    01239         for n in names:
    01240             self.propagateProperty(n, others, force)
    01241
        def __apply_configuration__(self):

def Configurable::ConfigurableUser::__apply_configuration__ | ( |  | self | ) |

    Function to be overridden to convert the high level configuration into a
    low level one.
    The default implementation calls applyConf, which is the method defined
    in some ConfigurableUser implementations.

Definition at line 1242 of file Configurable.py.

    01242                                      :
    01243         """
    01244         Function to be overridden to convert the high level configuration into a
    01245         low level one.
    01246         The default implementation calls applyConf, which is the method defined
    01247         in some ConfigurableUser implementations.
    01248         """
    01249         return self.applyConf()
    01250
        def applyConf( self ):

def Configurable::ConfigurableUser::applyConf | ( |  | self | ) |

    Function to be overridden to convert the high level configuration into a
    low level one.

Definition at line 1251 of file Configurable.py.

    01251                          :
    01252         """
    01253         Function to be overridden to convert the high level configuration into a
    01254         low level one.
    01255         """
    01256         pass
    01257
    01258 # list of callables to be called after all the __apply_configuration__ are called.
    postConfigActions = []

## Member Data Documentation

dictionary Configurable::ConfigurableUser::__slots__`[static, private]`

Initial value:

    { "__users__": [],
                      "__used_instances__": [],
                      "_enabled": True }

Reimplemented from Configurable::Configurable.

Definition at line 1112 of file Configurable.py.

list Configurable::ConfigurableUser::__used_configurables__ = []`[static, private]`

list of ConfigurableUser classes this one is going to modify in the __apply_configuration__ method

Definition at line 1117 of file Configurable.py.

list Configurable::ConfigurableUser::__queried_configurables__ = []`[static, private]`

list of ConfigurableUser classes this one is going to query in the __apply_configuration__ method

Definition at line 1120 of file Configurable.py.

Configurable::ConfigurableUser::_enabled`[private]`

Definition at line 1125 of file Configurable.py.

Configurable::ConfigurableUser::__users__`[private]`

Definition at line 1126 of file Configurable.py.

Configurable::ConfigurableUser::__used_instances__`[private]`

Definition at line 1133 of file Configurable.py.

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

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