| The Gaudi Framework v29r1 (5cd95fa2)

- 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 (self, name, others=None, force=True)
def | propagateProperties (self, names=None, others=None, force=True)
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__ (self, name=DefaultName)
def | __getstate__ (self)
def | __getnewargs__ (self)
def | __setstate__ (self, dict)
def | __len__ (self)
def | __iter__ (self)
def | __deepcopy__ (self, memo)
def | __iadd__ (self, configs, descr=None)
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 (self, tool, name=None)
def | __repr__ (self)
def | __str__ (self, indent=0, headerLastIndentUnit=indentUnit)

## 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 | __queried_configurables__ = []

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

## Detailed Description

Definition at line 1209 of file Configurable.py.

## Constructor & Destructor Documentation

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

Definition at line 1227 of file Configurable.py.

1227 def __init__(self, name=Configurable.DefaultName, _enabled=True, **kwargs):
1228 super(ConfigurableUser, self).__init__(name)
1229 for n, v in kwargs.items():
1230 setattr(self, n, v)
1231 self._enabled = _enabled
1232 self.__users__ = []
1233 self._applied = False
1234
1235 # Needed to retrieve the actual class if the declaration in __used_configurables__
1236 # and __queried_configurables__ is done with strings.
1237 from GaudiKernel.ConfigurableDb import getConfigurable as confDbGetConfigurable
1238
1239 # Set the list of users of the used configurables
1240 #
1241 self.__used_instances__ = []
1242 for used in self.__used_configurables__:
1243 # By default we want to use the default name of the instances
1244 # for the used configurables
1245 used_name = Configurable.DefaultName
1246 # If the entry in the list is a tuple, we need a named instance
1247 if type(used) is tuple:
1248 used, used_name = used # we re-set used to re-use the code below
1249 if not used_name:
1250 used_name = self._instanceName(used)
1251 # Check is 'used' is a string or not
1252 if type(used) is str:
1253 used_class = confDbGetConfigurable(used)
1254 else:
1255 used_class = used
1256 # Instantiate the configurable that we are going to use
1257 try:
1258 inst = used_class(name=used_name, _enabled=False)
1259 except AttributeError:
1260 # This cover the case where the used configurable is not a
1261 # ConfigurableUser instance, i.e. id doesn't have the attribute
1262 # '_enabled'.
1263 inst = used_class(name=used_name)
1264 self.__addActiveUseOf(inst)
1265 for queried in self.__queried_configurables__:
1266 try:
1267 if type(queried) is str:
1268 queried = confDbGetConfigurable(used)
1269 inst = queried(_enabled=False)
1270 except AttributeError:
1271 inst = queried()
1272 self.__addPassiveUseOf(inst)
1273
GaudiKernel.Configurable.ConfigurableUser.__users__
__users__
Definition: Configurable.py:1232
GaudiKernel.Configurable.ConfigurableUser.__queried_configurables__
list __queried_configurables__
Definition: Configurable.py:1225
GaudiKernel.Configurable.ConfigurableUser.__init__
def __init__(self, name=Configurable.DefaultName, _enabled=True, kwargs)
Definition: Configurable.py:1227
GaudiKernel.Configurable.ConfigurableUser.__addPassiveUseOf
def __addPassiveUseOf(self, other)
Definition: Configurable.py:1283
GaudiKernel.Configurable.ConfigurableUser._instanceName
def _instanceName(self, cls)
Definition: Configurable.py:1387
GaudiKernel.Configurable.ConfigurableUser.__used_configurables__
list __used_configurables__
Definition: Configurable.py:1222
GaudiKernel.ConfigurableDb
Definition: ConfigurableDb.py:1
GaudiKernel.Configurable.ConfigurableUser.__addActiveUseOf
def __addActiveUseOf(self, other)
Definition: Configurable.py:1274
GaudiKernel.Configurable.ConfigurableUser._enabled
_enabled
Definition: Configurable.py:1231
gaudirun.type
type
Definition: gaudirun.py:133
GaudiKernel.Configurable.ConfigurableUser._applied
_applied
Definition: Configurable.py:1233
GaudiKernel.Configurable.ConfigurableUser.__used_instances__
__used_instances__
Definition: Configurable.py:1241
GaudiKernel.Configurable.Configurable.DefaultName
Definition: Configurable.py:114

## 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 1274 of file Configurable.py.

1274 def __addActiveUseOf(self, other):
1275 """
1276 Declare that we are going to modify the Configurable 'other' in our
1277 __apply_configuration__.
1278 """
1279 self.__used_instances__.append(other)
1280 if hasattr(other, "__users__"): # allow usage of plain Configurables
1281 other.__users__.append(self)
1282
GaudiKernel.Configurable.ConfigurableUser.__addActiveUseOf
def __addActiveUseOf(self, other)
Definition: Configurable.py:1274

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 1283 of file Configurable.py.

1283 def __addPassiveUseOf(self, other):
1284 """
1285 Declare that we are going to retrieve property values from the
1286 ConfigurableUser 'other' in our __apply_configuration__.
1287 """
1288 if not isinstance(other, ConfigurableUser):
1289 raise Error("'%s': Cannot make passive use of '%s', it is not a ConfigurableUser" % (
1290 self.name(), other.name()))
1291 other.__addActiveUseOf(self)
1292
GaudiKernel.Configurable.ConfigurableUser.__addPassiveUseOf
def __addPassiveUseOf(self, other)
Definition: Configurable.py:1283
GaudiKernel.Configurable.Configurable.name
def name(self)
Definition: Configurable.py:718
GaudiKernel.Configurable.Error
Definition: Configurable.py:61

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 1371 of file Configurable.py.

1371 def __apply_configuration__(self):
1372 """
1373 Function to be overridden to convert the high level configuration into a
1374 low level one.
1375 The default implementation calls applyConf, which is the method defined
1376 in some ConfigurableUser implementations.
1377 """
1378 return self.applyConf()
1379
GaudiKernel.Configurable.ConfigurableUser.__apply_configuration__
def __apply_configuration__(self)
Definition: Configurable.py:1371
GaudiKernel.Configurable.ConfigurableUser.applyConf
def applyConf(self)
Definition: Configurable.py:1380

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

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

Definition at line 1302 of file Configurable.py.

1302 def __detach_used__(self):
1303 """
1304 Remove this ConfigurableUser instance from the users list of the used
1305 instances.
1306 """
1307 for used in self.__used_instances__:
1308 if hasattr(used, "__users__"): # allow usage of plain Configurables
1309 used.__users__.remove(self)
1310
GaudiKernel.Configurable.ConfigurableUser.__detach_used__
def __detach_used__(self)
Definition: Configurable.py:1302
GaudiKernel.Configurable.ConfigurableUser.__used_instances__
__used_instances__
Definition: Configurable.py:1241

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 1387 of file Configurable.py.

1387 def _instanceName(self, cls):
1388 """
1389 Function used to define the name of the private instance of a given class
1390 name.
1391 This method is used when the __used_configurables_property__ declares the
1392 need of a private used configurable without specifying the name.
1393 """
1394 if type(cls) is str:
1395 clName = cls
1396 else:
1397 clName = cls.__name__
1398 return "%s_%s" % (self.name(), clName)
1399
GaudiKernel.Configurable.ConfigurableUser._instanceName
def _instanceName(self, cls)
Definition: Configurable.py:1387
GaudiKernel.Configurable.Configurable.name
def name(self)
Definition: Configurable.py:718
gaudirun.type
type
Definition: gaudirun.py:133

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

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

Definition at line 1380 of file Configurable.py.

1380 def applyConf(self):
1381 """
1382 Function to be overridden to convert the high level configuration into a
1383 low level one.
1384 """
1385 pass
1386
GaudiKernel.Configurable.ConfigurableUser.applyConf
def applyConf(self)
Definition: Configurable.py:1380

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

Definition at line 1296 of file Configurable.py.

1296 def getDlls(self):
1297 return None
1298
GaudiKernel.Configurable.ConfigurableUser.getDlls
def getDlls(self)
Definition: Configurable.py:1296

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

Definition at line 1293 of file Configurable.py.

1293 def getGaudiType(self):
1294 return 'User'
1295
GaudiKernel.Configurable.ConfigurableUser.getGaudiType
def getGaudiType(self)
Definition: Configurable.py:1293

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

Definition at line 1299 of file Configurable.py.

1299 def getHandle(self):
1300 return None
1301
GaudiKernel.Configurable.ConfigurableUser.getHandle
def getHandle(self)
Definition: Configurable.py:1299

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

    Return the used instance with a given name.

Definition at line 1400 of file Configurable.py.

1400 def getUsedInstance(self, name):
1401 """
1402 Return the used instance with a given name.
1403 """
1404 for i in self.__used_instances__:
1405 if i.name() == name:
1406 if hasattr(i, "_enabled"):
1407 # ensure that the instances retrieved through the method are
1408 # enabled
1409 i._enabled = True
1410 return i
1411 raise KeyError(name)
1412
GaudiKernel.Configurable.ConfigurableUser.getUsedInstance
def getUsedInstance(self, name)
Definition: Configurable.py:1400
GaudiKernel.Configurable.ConfigurableUser.__used_instances__
__used_instances__
Definition: Configurable.py:1241

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

    Return True is the instance can be "applied".

Definition at line 1413 of file Configurable.py.

1413 def isApplicable(self):
1414 '''
1415 Return True is the instance can be "applied".
1416 '''
1417 return (not self.__users__) and (not self._applied)
1418
1419
1420 # list of callables to be called after all the __apply_configuration__ are called.
GaudiKernel.Configurable.ConfigurableUser.__users__
__users__
Definition: Configurable.py:1232
GaudiKernel.Configurable.ConfigurableUser.isApplicable
def isApplicable(self)
Definition: Configurable.py:1413
GaudiKernel.Configurable.ConfigurableUser._applied
_applied
Definition: Configurable.py:1233

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 1360 of file Configurable.py.

1360 def propagateProperties(self, names=None, others=None, force=True):
1361 """
1362 Call propagateProperty for each property listed in 'names'.
1363 If 'names' is None, all the properties are propagated.
1364 """
1365 if names is None:
1366 # use all the non-private slots
1367 names = [p for p in self.__slots__ if not p.startswith("_")]
1368 for n in names:
1369 self.propagateProperty(n, others, force)
1370
GaudiKernel.Configurable.ConfigurableUser.propagateProperty
def propagateProperty(self, name, others=None, force=True)
Definition: Configurable.py:1311
GaudiKernel.Configurable.ConfigurableUser.propagateProperties
def propagateProperties(self, names=None, others=None, force=True)
Definition: Configurable.py:1360
GaudiKernel.Configurable.Configurable.__slots__
tuple __slots__
Definition: Configurable.py:124

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 1311 of file Configurable.py.

1311 def propagateProperty(self, name, others=None, force=True):
1312 """
1313 Propagate the property 'name' (if set) to other configurables (if possible).
1314 'others' can be:
1315 None:
1316 propagate to all the entries in __used_configurables__
1317 a configurable instance:
1318 propagate only to it
1319 list of configurable instances:
1320 propagate to all of them.
1321
1322
1323 The logic is:
1324 - if the local property is set, the other property will be overwritten
1325 - local property not set and other set => keep other
1326 - local property not set and other not set => overwrite the default for
1327 ConfigurableUser instances and set the property for Configurables
1328 """
1329 # transform 'others' to a list of configurable instances
1330 if others is None:
1331 others = self.__used_instances__
1332 elif type(others) not in [list, tuple]:
1333 others = [others]
1334 # these can be computed before the loop
1335 local_is_set = self.isPropertySet(name)
1336 value = self.getProp(name)
1337 # loop over the others that do have 'name' in their slots
1338 for other in [o for o in others if name in o.__slots__]:
1339 # If self property is set, use it
1340 if local_is_set:
1341 if other.isPropertySet(name):
1342 log.warning("Property '%(prop)s' is set in both '%(self)s' and '%(other)s', using '%(self)s.%(prop)s'" %
1343 {"self": self.name(),
1344 "other": other.name(),
1345 "prop": name})
1346 other.setProp(name, value)
1347 # If not, and other property also not set, propagate the default
1348 elif not other.isPropertySet(name):
1349 if isinstance(other, ConfigurableUser):
1350 otherType = type(other._properties[name].getDefault())
1351 other._properties[name].setDefault(value)
1352 if otherType in [list, dict]:
1353 # Special case for list and dictionaries:
1354 # also set the property to the same value of the default (copy)
1355 other.setProp(name, otherType(value))
1356 else:
1357 other.setProp(name, value)
1358 # If not set and other set, do nothing
1359
GaudiKernel.Configurable.ConfigurableUser.propagateProperty
def propagateProperty(self, name, others=None, force=True)
Definition: Configurable.py:1311
GaudiKernel.Configurable.Configurable.getProp
def getProp(self, name)
Definition: Configurable.py:684
GaudiKernel.Configurable.Configurable.name
def name(self)
Definition: Configurable.py:718
gaudirun.type
type
Definition: gaudirun.py:133
GaudiKernel.Configurable.Configurable.isPropertySet
def isPropertySet(self, name)
Definition: Configurable.py:697
GaudiKernel.Configurable.ConfigurableUser.__used_instances__
__used_instances__
Definition: Configurable.py:1241

## Member Data Documentation

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

Definition at line 1225 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 1210 of file Configurable.py.

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

Definition at line 1222 of file Configurable.py.

GaudiKernel.Configurable.ConfigurableUser.__used_instances__
| private

Definition at line 1241 of file Configurable.py.

GaudiKernel.Configurable.ConfigurableUser.__users__
| private

Definition at line 1232 of file Configurable.py.

GaudiKernel.Configurable.ConfigurableUser._applied
| private

Definition at line 1233 of file Configurable.py.

GaudiKernel.Configurable.ConfigurableUser._enabled
| private

Definition at line 1231 of file Configurable.py.

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

- GaudiKernel/python/GaudiKernel/Configurable.py