| The Gaudi Framework v27r1

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
GaudiKernel.Configurable.ConfigurableUser Class Reference
Inheritance diagram for GaudiKernel.Configurable.ConfigurableUser:
[legend]
Collaboration diagram for GaudiKernel.Configurable.ConfigurableUser:
[legend]

## Public Member Functions
def | __init__ (self, name=Configurable.DefaultName, _enabled=True, kwargs)
def | getGaudiType (self)
def | getDlls (self)
def | getHandle (self)
def | __detach_used__ (self)
def | propagateProperty
def | propagateProperties
def | __apply_configuration__ (self)
def | applyConf (self)
def | getUsedInstance (self, name)
def | isApplicable (self)
Public Member Functions inherited from GaudiKernel.Configurable.Configurable
def | __new__ (cls, args, kwargs)
def | __init__
def | __getstate__ (self)
def | __getnewargs__ (self)
def | __setstate__ (self, dict)
def | __len__ (self)
def | __iter__ (self)
def | __deepcopy__ (self, memo)
def | __iadd__
def | __getattr__ (self, attr)
def | __setattr__ (self, name, value)
def | __delattr__ (self, attr)
def | __nonzero__ (self)
def | remove (self, items)
def | removeAll (self)
def | copyChild (self, child)
def | setParent (self, parentName)
def | getParent (self)
def | hasParent (self, parent)
def | copyChildAndSetParent (self, cfg, parent)
def | getChildren (self)
def | getTools (self)
def | children (self)
def | getAllChildren (self)
def | getSequence (self)
def | setup (self)
def | getProperties (self)
def | getPropertiesWithDescription (self)
def | getValuedProperties (self)
def | properties (self)
def | getDefaultProperties (cls)
def | getDefaultProperty (cls, name)
def | getProp (self, name)
def | setProp (self, name, value)
def | isPropertySet (self, name)
def | getType (cls)
def | getName (self)
def | name (self)
def | getJobOptName (self)
def | isPublic (self)
def | jobOptName (self)
def | getFullName (self)
def | getFullJobOptName (self)
def | getPrintTitle (self)
def | getTitleName (self)
def | setDefaults (cls, handle)
def | clone (self, name=None, kwargs)
def | splitName (self)
def | addTool
def | __repr__ (self)
def | __str__

## Private Member Functions
def | __addActiveUseOf (self, other)
def | __addPassiveUseOf (self, other)
def | _instanceName (self, cls)

## Private Attributes
| _enabled
| __users__
| _applied
| __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. More...
list | __queried_configurables__ = []
| list of ConfigurableUser classes this one is going to query in the apply_configuration method More...

## Additional Inherited Members
Static Public Attributes inherited from GaudiKernel.Configurable.Configurable
string | indentUnit = '| '
int | printHeaderWidth = 100
int | printHeaderPre = 5
dictionary | allConfigurables = {}
dictionary | configurableServices = {}

## Detailed Description

Definition at line 1134 of file Configurable.py.

## Constructor & Destructor Documentation

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

Definition at line 1151 of file Configurable.py.

1151 def __init__( self, name = Configurable.DefaultName, _enabled = True, **kwargs ):
1152 super( ConfigurableUser, self ).__init__( name )
1153 for n, v in kwargs.items():
1154 setattr(self, n, v)
1155 self._enabled = _enabled
1156 self.__users__ = []
1157 self._applied = False
1158
1159 # Needed to retrieve the actual class if the declaration in __used_configurables__
1160 # and __queried_configurables__ is done with strings.
1161 from GaudiKernel.ConfigurableDb import getConfigurable as confDbGetConfigurable
1162
1163 # Set the list of users of the used configurables
1164 #
1165 self.__used_instances__ = []
1166 for used in self.__used_configurables__:
1167 # By default we want to use the default name of the instances
1168 # for the used configurables
1169 used_name = Configurable.DefaultName
1170 # If the entry in the list is a tuple, we need a named instance
1171 if type(used) is tuple:
1172 used, used_name = used # we re-set used to re-use the code below
1173 if not used_name:
1174 used_name = self._instanceName(used)
1175 # Check is 'used' is a string or not
1176 if type(used) is str:
1177 used_class = confDbGetConfigurable(used)
1178 else:
1179 used_class = used
1180 # Instantiate the configurable that we are going to use
1181 try:
1182 inst = used_class(name = used_name, _enabled = False)
1183 except AttributeError:
1184 # This cover the case where the used configurable is not a
1185 # ConfigurableUser instance, i.e. id doesn't have the attribute
1186 # '_enabled'.
1187 inst = used_class(name = used_name)
1188 self.__addActiveUseOf(inst)
1189 for queried in self.__queried_configurables__:
1190 try:
1191 if type(queried) is str:
1192 queried = confDbGetConfigurable(used)
1193 inst = queried(_enabled = False)
1194 except AttributeError:
1195 inst = queried()
1196 self.__addPassiveUseOf(inst)
GaudiKernel.Configurable.ConfigurableUser.__users__
__users__
Definition: Configurable.py:1156
GaudiKernel.Configurable.ConfigurableUser.__queried_configurables__
list __queried_configurables__
list of ConfigurableUser classes this one is going to query in the apply_configuration method ...
Definition: Configurable.py:1150
GaudiKernel.Configurable.ConfigurableUser.__init__
def __init__(self, name=Configurable.DefaultName, _enabled=True, kwargs)
Definition: Configurable.py:1151
GaudiKernel.Configurable.ConfigurableUser.__addPassiveUseOf
def __addPassiveUseOf(self, other)
Definition: Configurable.py:1205
GaudiKernel.Configurable.ConfigurableUser._instanceName
def _instanceName(self, cls)
Definition: Configurable.py:1305
GaudiKernel.Configurable.ConfigurableUser.__used_configurables__
list __used_configurables__
list of ConfigurableUser classes this one is going to modify in the apply_configuration method...
Definition: Configurable.py:1147
GaudiKernel.ConfigurableDb
Definition: ConfigurableDb.py:1
GaudiKernel.Configurable.ConfigurableUser.__addActiveUseOf
def __addActiveUseOf(self, other)
Definition: Configurable.py:1197
gaudirun.type
string type
Definition: gaudirun.py:151
GaudiKernel.Configurable.ConfigurableUser._enabled
_enabled
Definition: Configurable.py:1155
GaudiKernel.Configurable.ConfigurableUser._applied
_applied
Definition: Configurable.py:1157
GaudiKernel.Configurable.ConfigurableUser.__used_instances__
__used_instances__
Definition: Configurable.py:1165
GaudiKernel.Configurable.Configurable.DefaultName
for detecting the default name
Definition: Configurable.py:96

## Member Function Documentation

def GaudiKernel.Configurable.ConfigurableUser.__addActiveUseOf | ( |  | self,
|  |  | other
| ) |  |
| private

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

Definition at line 1197 of file Configurable.py.

1197 def __addActiveUseOf(self, other):
1198 """
1199 Declare that we are going to modify the Configurable 'other' in our
1200 __apply_configuration__.
1201 """
1202 self.__used_instances__.append(other)
1203 if hasattr(other, "__users__"): # allow usage of plain Configurables
1204 other.__users__.append(self)
GaudiKernel.Configurable.ConfigurableUser.__addActiveUseOf
def __addActiveUseOf(self, other)
Definition: Configurable.py:1197

def GaudiKernel.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 1205 of file Configurable.py.

1205 def __addPassiveUseOf(self, other):
1206 """
1207 Declare that we are going to retrieve property values from the
1208 ConfigurableUser 'other' in our __apply_configuration__.
1209 """
1210 if not isinstance(other, ConfigurableUser):
1211 raise Error("'%s': Cannot make passive use of '%s', it is not a ConfigurableUser" % (self.name(), other.name()))
1212 other.__addActiveUseOf(self)
GaudiKernel.Configurable.ConfigurableUser.__addPassiveUseOf
def __addPassiveUseOf(self, other)
Definition: Configurable.py:1205
GaudiKernel.Configurable.Configurable.name
def name(self)
Definition: Configurable.py:690
GaudiKernel.Configurable.Error
Definition: Configurable.py:51

def GaudiKernel.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 1289 of file Configurable.py.

1289 def __apply_configuration__(self):
1290 """
1291 Function to be overridden to convert the high level configuration into a
1292 low level one.
1293 The default implementation calls applyConf, which is the method defined
1294 in some ConfigurableUser implementations.
1295 """
1296 return self.applyConf()
1297
GaudiKernel.Configurable.ConfigurableUser.__apply_configuration__
def __apply_configuration__(self)
Definition: Configurable.py:1289
GaudiKernel.Configurable.ConfigurableUser.applyConf
def applyConf(self)
Definition: Configurable.py:1298

def GaudiKernel.Configurable.ConfigurableUser.__detach_used__ | ( |  | self | ) |

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

Definition at line 1220 of file Configurable.py.

1220 def __detach_used__(self):
1221 """
1222 Remove this ConfigurableUser instance from the users list of the used
1223 instances.
1224 """
1225 for used in self.__used_instances__:
1226 if hasattr(used, "__users__"): # allow usage of plain Configurables
1227 used.__users__.remove(self)
1228
GaudiKernel.Configurable.ConfigurableUser.__detach_used__
def __detach_used__(self)
Definition: Configurable.py:1220
GaudiKernel.Configurable.ConfigurableUser.__used_instances__
__used_instances__
Definition: Configurable.py:1165

def GaudiKernel.Configurable.ConfigurableUser._instanceName | ( |  | self,
|  |  | cls
| ) |  |
| private

    Function used to define the name of the private instance of a given class
    name.
    This method is used when the __used_configurables_property__ declares the
    need of a private used configurable without specifying the name.

Definition at line 1305 of file Configurable.py.

1305 def _instanceName(self, cls):
1306 """
1307 Function used to define the name of the private instance of a given class
1308 name.
1309 This method is used when the __used_configurables_property__ declares the
1310 need of a private used configurable without specifying the name.
1311 """
1312 if type(cls) is str:
1313 clName = cls
1314 else:
1315 clName = cls.__name__
1316 return "%s_%s" % (self.name(), clName)
1317
GaudiKernel.Configurable.ConfigurableUser._instanceName
def _instanceName(self, cls)
Definition: Configurable.py:1305
GaudiKernel.Configurable.Configurable.name
def name(self)
Definition: Configurable.py:690
gaudirun.type
string type
Definition: gaudirun.py:151

def GaudiKernel.Configurable.ConfigurableUser.applyConf | ( |  | self | ) |

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

Definition at line 1298 of file Configurable.py.

1298 def applyConf( self ):
1299 """
1300 Function to be overridden to convert the high level configuration into a
1301 low level one.
1302 """
1303 pass
1304
GaudiKernel.Configurable.ConfigurableUser.applyConf
def applyConf(self)
Definition: Configurable.py:1298

def GaudiKernel.Configurable.ConfigurableUser.getDlls | ( |  | self | ) |

Definition at line 1215 of file Configurable.py.

1215 def getDlls( self ):
1216 return None
GaudiKernel.Configurable.ConfigurableUser.getDlls
def getDlls(self)
Definition: Configurable.py:1215

def GaudiKernel.Configurable.ConfigurableUser.getGaudiType | ( |  | self | ) |

Definition at line 1213 of file Configurable.py.

1213 def getGaudiType( self ):
1214 return 'User'
GaudiKernel.Configurable.ConfigurableUser.getGaudiType
def getGaudiType(self)
Definition: Configurable.py:1213

def GaudiKernel.Configurable.ConfigurableUser.getHandle | ( |  | self | ) |

Definition at line 1217 of file Configurable.py.

1217 def getHandle( self ):
1218 return None
1219
GaudiKernel.Configurable.ConfigurableUser.getHandle
def getHandle(self)
Definition: Configurable.py:1217

def GaudiKernel.Configurable.ConfigurableUser.getUsedInstance | ( |  | self,
|  |  | name
| ) |  |

    Return the used instance with a given name.

Definition at line 1318 of file Configurable.py.

1318 def getUsedInstance(self, name):
1319 """
1320 Return the used instance with a given name.
1321 """
1322 for i in self.__used_instances__:
1323 if i.name() == name:
1324 if hasattr(i, "_enabled"):
1325 # ensure that the instances retrieved through the method are
1326 # enabled
1327 i._enabled = True
1328 return i
1329 raise KeyError(name)
1330
GaudiKernel.Configurable.ConfigurableUser.getUsedInstance
def getUsedInstance(self, name)
Definition: Configurable.py:1318
GaudiKernel.Configurable.ConfigurableUser.__used_instances__
__used_instances__
Definition: Configurable.py:1165

def GaudiKernel.Configurable.ConfigurableUser.isApplicable | ( |  | self | ) |

    Return True is the instance can be "applied".

Definition at line 1331 of file Configurable.py.

1331 def isApplicable(self):
1332 '''
1333 Return True is the instance can be "applied".
1334 '''
1335 return (not self.__users__) and (not self._applied)
1336
1337
1338 # list of callables to be called after all the __apply_configuration__ are called.
GaudiKernel.Configurable.ConfigurableUser.__users__
__users__
Definition: Configurable.py:1156
GaudiKernel.Configurable.ConfigurableUser.isApplicable
def isApplicable(self)
Definition: Configurable.py:1331
GaudiKernel.Configurable.ConfigurableUser._applied
_applied
Definition: Configurable.py:1157

def GaudiKernel.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 1278 of file Configurable.py.

1278 def propagateProperties(self, names = None, others = None, force = True):
1279 """
1280 Call propagateProperty for each property listed in 'names'.
1281 If 'names' is None, all the properties are propagated.
1282 """
1283 if names is None:
1284 # use all the non-private slots
1285 names = [ p for p in self.__slots__ if not p.startswith("_") ]
1286 for n in names:
1287 self.propagateProperty(n, others, force)
1288
GaudiKernel.Configurable.ConfigurableUser.propagateProperty
def propagateProperty
Definition: Configurable.py:1229
GaudiKernel.Configurable.ConfigurableUser.propagateProperties
def propagateProperties
Definition: Configurable.py:1278
GaudiKernel.Configurable.Configurable.__slots__
tuple __slots__
Definition: Configurable.py:106

def GaudiKernel.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 1229 of file Configurable.py.

1229 def propagateProperty(self, name, others = None, force = True):
1230 """
1231 Propagate the property 'name' (if set) to other configurables (if possible).
1232 'others' can be:
1233 None:
1234 propagate to all the entries in __used_configurables__
1235 a configurable instance:
1236 propagate only to it
1237 list of configurable instances:
1238 propagate to all of them.
1239
1240
1241 The logic is:
1242 - if the local property is set, the other property will be overwritten
1243 - local property not set and other set => keep other
1244 - local property not set and other not set => overwrite the default for
1245 ConfigurableUser instances and set the property for Configurables
1246 """
1247 # transform 'others' to a list of configurable instances
1248 if others is None:
1249 others = self.__used_instances__
1250 elif type(others) not in [ list, tuple ] :
1251 others = [ others ]
1252 # these can be computed before the loop
1253 local_is_set = self.isPropertySet(name)
1254 value = self.getProp(name)
1255 # loop over the others that do have 'name' in their slots
1256 for other in [ o for o in others if name in o.__slots__ ]:
1257 # If self property is set, use it
1258 if local_is_set:
1259 if other.isPropertySet(name):
1260 log.warning("Property '%(prop)s' is set in both '%(self)s' and '%(other)s', using '%(self)s.%(prop)s'"%
1261 { "self": self.name(),
1262 "other": other.name(),
1263 "prop": name } )
1264 other.setProp(name, value)
1265 # If not, and other property also not set, propagate the default
1266 elif not other.isPropertySet(name):
1267 if isinstance(other,ConfigurableUser):
1268 otherType = type(other._properties[name].getDefault())
1269 other._properties[name].setDefault(value)
1270 if otherType in [list, dict]:
1271 # Special case for list and dictionaries:
1272 # also set the property to the same value of the default (copy)
1273 other.setProp(name, otherType(value))
1274 else:
1275 other.setProp(name, value)
1276 # If not set and other set, do nothing
1277
GaudiKernel.Configurable.Configurable.getProp
def getProp(self, name)
Definition: Configurable.py:655
GaudiKernel.Configurable.ConfigurableUser.propagateProperty
def propagateProperty
Definition: Configurable.py:1229
GaudiKernel.Configurable.Configurable.name
def name(self)
Definition: Configurable.py:690
gaudirun.type
string type
Definition: gaudirun.py:151
GaudiKernel.Configurable.Configurable.isPropertySet
def isPropertySet(self, name)
Definition: Configurable.py:668
GaudiKernel.Configurable.ConfigurableUser.__used_instances__
__used_instances__
Definition: Configurable.py:1165

## Member Data Documentation

list GaudiKernel.Configurable.ConfigurableUser.__queried_configurables__ = []
| static private

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

Definition at line 1150 of file Configurable.py.

dictionary GaudiKernel.Configurable.ConfigurableUser.__slots__
| static private

Initial value:
1 = { "__users__": [],
2 "__used_instances__": [],
3 "_enabled": True,
4 "_applied": False }

Definition at line 1135 of file Configurable.py.

list GaudiKernel.Configurable.ConfigurableUser.__used_configurables__ = []
| static private

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

The list may contain class objects, strings representing class objects or tuples with the class object (or a string) as first element and the instance name as second element. If the instance name is None or not present, the function instanceName() is used to determine the name of the instance (the default implementation returns "<this name></em><other name>".

Definition at line 1147 of file Configurable.py.

GaudiKernel.Configurable.ConfigurableUser.__used_instances__
| private

Definition at line 1165 of file Configurable.py.

GaudiKernel.Configurable.ConfigurableUser.__users__
| private

Definition at line 1156 of file Configurable.py.

GaudiKernel.Configurable.ConfigurableUser._applied
| private

Definition at line 1157 of file Configurable.py.

GaudiKernel.Configurable.ConfigurableUser._enabled
| private

Definition at line 1155 of file Configurable.py.

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

- GaudiKernel/python/GaudiKernel/Configurable.py