Gaudi Framework, version v21r4

Home   Generated: 7 Sep 2009

Configurable::ConfigurableUser Class Reference

Inheritance diagram for Configurable::ConfigurableUser:

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

Collaboration graph
[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         # Set the list of users of the used configurables
01129         self.__used_instances__ = []
01130         for used in self.__used_configurables__:
01131             try:
01132                 inst = used(_enabled = False)
01133             except AttributeError:
01134                 inst = used()
01135             self.__addActiveUseOf(inst)
01136         for queried in self.__queried_configurables__:
01137             try:
01138                 inst = queried(_enabled = False)
01139             except AttributeError:
01140                 inst = queried()
01141             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 1142 of file Configurable.py.

01142                                      :
01143         """
01144         Declare that we are going to modify the Configurable 'other' in our
01145         __apply_configuration__. 
01146         """
01147         self.__used_instances__.append(other)
01148         if hasattr(other, "__users__"): # allow usage of plain Configurables
01149             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 1150 of file Configurable.py.

01150                                       :
01151         """
01152         Declare that we are going to retrieve property values from the
01153         ConfigurableUser 'other' in our __apply_configuration__. 
01154         """
01155         if not isinstance(other, ConfigurableUser):
01156             raise Error("'%s': Cannot make passive use of '%s', it is not a ConfigurableUser" % (self.name(), other.name()))
01157         other.__addActiveUseOf(self)
    def getGaudiType( self ):

def Configurable::ConfigurableUser::getGaudiType (   self  ) 

Definition at line 1158 of file Configurable.py.

01158                             :
01159         return 'User'
    def getDlls( self ):

def Configurable::ConfigurableUser::getDlls (   self  ) 

Definition at line 1160 of file Configurable.py.

01160                        :
01161         return None
    def getHandle( self ):

def Configurable::ConfigurableUser::getHandle (   self  ) 

Definition at line 1162 of file Configurable.py.

01162                          :
01163         return None
01164     
    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 1165 of file Configurable.py.

01165                              :
01166         """
01167         Remove this ConfigurableUser instance from the users list of the used
01168         instances.
01169         """
01170         for used in self.__used_instances__:
01171             if hasattr(used, "__users__"): # allow usage of plain Configurables
01172                 used.__users__.remove(self)
01173     
    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 1174 of file Configurable.py.

01174                                                                   :
01175         """
01176         Propagate the property 'name' (if set) to other configurables (if possible).
01177         'others' can be:
01178             None:
01179                 propagate to all the entries in __used_configurables__
01180             a configurable instance:
01181                 propagate only to it
01182             list of configurable instances:
01183                 propagate to all of them.
01184         
01185         
01186         The logic is:
01187         - if the local property is set, the other property will be overwritten
01188         - local property not set and other set => keep other
01189         - local property not set and other not set => overwrite the default for
01190             ConfigurableUser instances and set the property for Configurables
01191         """
01192         # transform 'others' to a list of configurable instances
01193         if others is None:
01194             others = self.__used_instances__
01195         elif type(others) not in [ list, tuple ] :
01196             others = [ others ]
01197         # these can be computed before the loop
01198         local_is_set = self.isPropertySet(name)
01199         value = self.getProp(name)
01200         # loop over the others that do have 'name' in their slots
01201         for other in [ o for o in others if name in o.__slots__ ]:
01202             # If self property is set, use it
01203             if local_is_set:
01204                 if other.isPropertySet(name):
01205                     log.warning("Property '%(prop)s' is set in both '%(self)s' and '%(other)s', using '%(self)s.%(prop)s'"%
01206                                 { "self": self.name(),
01207                                   "other": other.name(),
01208                                   "prop": name } )
01209                 other.setProp(name, value)
01210             # If not, and other property also not set, propagate the default
01211             elif not other.isPropertySet(name):
01212                 if isinstance(other,ConfigurableUser):
01213                     other._properties[name].setDefault(value)
01214                 else:
01215                     other.setProp(name, value)
01216             # If not set and other set, do nothing
01217         
    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 1218 of file Configurable.py.

01218                                                                             :
01219         """
01220         Call propagateProperty for each property listed in 'names'.
01221         If 'names' is None, all the properties are propagated.
01222         """
01223         if names is None:
01224             # use all the non-private slots
01225             names = [ p for p in self.__slots__ if not p.startswith("_") ]
01226         for n in names:
01227             self.propagateProperty(n, others, force)
01228 
    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 1229 of file Configurable.py.

01229                                      :
01230         """
01231         Function to be overridden to convert the high level configuration into a
01232         low level one.
01233         The default implementation calls applyConf, which is the method defined
01234         in some ConfigurableUser implementations.
01235         """
01236         return self.applyConf()
01237     
    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 1238 of file Configurable.py.

01238                          :
01239         """
01240         Function to be overridden to convert the high level configuration into a
01241         low level one. 
01242         """
01243         pass
01244 
01245 # 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 of ConfigurableUser classes this one is going to modify in the __apply_configuration__ method

Definition at line 1117 of file Configurable.py.

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

Definition at line 1120 of file Configurable.py.

Definition at line 1125 of file Configurable.py.

Definition at line 1126 of file Configurable.py.

Definition at line 1129 of file Configurable.py.


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

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