| The Gaudi Framework v32r1 (f65d50dc)

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

## Classes
class | DefaultName

## Public Member Functions
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)

## Static Public Attributes
| propertyNoValue
string | indentUnit = '| '
int | printHeaderWidth = 100
int | printHeaderPre = 5
dictionary | allConfigurables
dictionary | configurableServices

## Private Member Functions
def | _isInSetDefaults (self)
def | __setupServices (self)
def | __setupDlls (self)
def | __setupDefaults (self)

## Static Private Member Functions
def | _printHeader (indentStr, title)
def | _printFooter (indentStr, title)

## Private Attributes
| __children
| __tools
| _name
| _inSetDefaults
| _initok
| _setupok
| _unpickling

## Static Private Attributes
| __metaclass__ = ConfigurableMeta.ConfigurableMeta
tuple | __slots__
bool | _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 106 of file Configurable.py.

## Constructor & Destructor Documentation

## ◆ __init__()

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

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

Definition at line 285 of file Configurable.py.

285 def __init__(self, name=DefaultName):
286 # check class readiness, all required overloads should be there now
287 klass = self.__class__
288
289 # this is an abstract class
290 if klass == Configurable:
291 raise TypeError(
292 "%s is an ABC and can not be instantiated" % str(Configurable))
293
294 # the following methods require overloading
295 # NOT YET meths = { 'getServices' : 1, # retrieve list of services to configure
296 meths = {
297 'getDlls': 1, # provide list of Dlls to load
298 'getGaudiType': 1, # return string describing component class
299 'getHandle': 1
300 } # provide access to C++ side component instance
301 # 'getType' : 1 } # return the type of the actual C++ component
302
303 for meth, nArgs in meths.items():
304 try:
305 f = getattr(klass, meth).im_func
306 except AttributeError:
307 raise NotImplementedError(
308 "%s is missing in class %s" % (meth, str(klass)))
309
310 # in addition, verify the number of arguments w/o defaults
311 nargcount = f.func_code.co_argcount
312 ndefaults = f.func_defaults and len(f.func_defaults) or 0
313 if not nargcount - ndefaults <= nArgs <= nargcount:
314 raise TypeError("%s.%s requires exactly %d arguments" %
315 (klass, meth, nArgs))
316
317 # for using this Configurable as a (Gaudi) sequence
318 self.__children = []
319 self.__tools = {}
320
321 # know who we are
322 if name == Configurable.DefaultName:
323 if hasattr(self.__class__, 'DefaultedName'):
324 self._name = self.__class__.DefaultedName
325 else:
326 self._name = self.getType()
327 else:
328 self._name = name
329
330 # set to True when collecting defaults, False otherwise
331 self._inSetDefaults = False
332
333 # for later, in case __init__ itself is overridden
334 self._initok = True
335
336 # for debugging purposes (temporary)
337 self._setupok = False
338
339 # used to prevent spurious deprecation warnings when unpickling
340 self._unpickling = False
341

## Member Function Documentation

## ◆ __deepcopy__()

def GaudiKernel.Configurable.Configurable.__deepcopy__ | ( |  | self,
|  |  | memo
| ) |  |

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

Definition at line 383 of file Configurable.py.

383 def __deepcopy__(self, memo):
384 newconf = object.__new__(self.__class__)
385 self.__class__.__init__(newconf, self.getName())
386
387 for proxy in self._properties.values():
388 try:
389 proxy.__set__(newconf, proxy.__get__(self))
390 except AttributeError:
391 pass # means property was not set for self
392
393 for c in self.__children:
394 newconf += c # processes proper copy semantics
395
396 return newconf
397

## ◆ __delattr__()

def GaudiKernel.Configurable.Configurable.__delattr__ | ( |  | self,
|  |  | attr
| ) |  |

Definition at line 461 of file Configurable.py.

461 def __delattr__(self, attr):
462 # remove as property, otherwise try as child
463 try:
464 # remove history etc., then reset to default (in case set before)
465 prop = self._properties[attr]
466 prop.__delete__(self)
467 prop.__set__(self, prop.default)
468 return # reaches here? was property: done now
469 except KeyError:
470 pass
471 # otherwise, remove the private tool
472 if attr in self.__tools:
473 del self.__tools[attr]
474
475 # otherwise, remove child, if one is so named
476 for c in self.__children:
477 if c.getName() == attr:
478 self.__children.remove(c)
479
480 # potentially, there are left over caches (certain user derived classes)
481 try:
482 del self.__dict__[attr]
483 except (AttributeError, KeyError):
484 pass
485

## ◆ __getattr__()

def GaudiKernel.Configurable.Configurable.__getattr__ | ( |  | self,
|  |  | attr
| ) |  |

Definition at line 432 of file Configurable.py.

432 def __getattr__(self, attr): # until ToolProperties exist ...
433
434 if attr in self.__tools:
435 return self.__tools[attr]
436
437 if attr in self._properties:
438 if isinstance(self._properties[attr].__get__(self),
439 DataObjectHandleBase):
440 return self._properties[attr].__get__(self)
441
442 for c in self.__children:
443 if c.getName() == attr:
444 return c
445
446 raise AttributeError(
447 "'%s' object has no attribute '%s'" % (self.__class__, attr))
448

## ◆ __getnewargs__()

def GaudiKernel.Configurable.Configurable.__getnewargs__ | ( |  | self | ) |

Definition at line 356 of file Configurable.py.

356 def __getnewargs__(self):
357 return (self._name, )
358

## ◆ __getstate__()

def GaudiKernel.Configurable.Configurable.__getstate__ | ( |  | self | ) |

Definition at line 343 of file Configurable.py.

343 def __getstate__(self):
344 dict = {}
345 for name, proxy in self._properties.items():
346 try:
347 dict[name] = proxy.__get__(self)
348 except AttributeError:
349 pass
350
351 dict['_Configurable__children'] = self.__children
352 dict['_Configurable__tools'] = self.__tools
353 dict['_name'] = self._name
354 return dict
355

## ◆ __iadd__()

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

Definition at line 399 of file Configurable.py.

399 def __iadd__(self, configs, descr=None):
400 if not type(configs) in (list, tuple):
401 configs = (configs, )
402
403 joname = self.getJobOptName()
404
405 for cfg in configs:
406 # prevent type mismatches
407 if not isinstance(cfg, Configurable):
408 raise TypeError("'%s' is not a Configurable" % str(cfg))
409
410 cc = self.copyChildAndSetParent(cfg, joname)
411
412 # filters dupes; usually "ok" (backdoor should catch them)
413 ccjo = cc.getJobOptName()
414 for c in self.__children:
415 if c.getJobOptName() == ccjo:
416 log.error('attempt to add a duplicate ... dupe ignored%s',
417 error_explanation)
418 break
419 else:
420 self.__children.append(cc)
421
422 try:
423 if descr: # support for tool properties
424 descr.__set__(self, cc)
425 else:
426 setattr(self, cc.getName(), cc)
427 except AttributeError:
428 pass # to allow free addition of tools/subalgorithms
429
430 return self
431
gaudirun.type
type
Definition: gaudirun.py:142

## ◆ __iter__()

def GaudiKernel.Configurable.Configurable.__iter__ | ( |  | self | ) |

Definition at line 379 of file Configurable.py.

379 def __iter__(self):
380 return iter(self.__children)
381
GaudiPython.Pythonizations.__iter__
__iter__
Definition: Pythonizations.py:117

## ◆ __len__()

def GaudiKernel.Configurable.Configurable.__len__ | ( |  | self | ) |

Definition at line 376 of file Configurable.py.

376 def __len__(self):
377 return len(self.__children)
378
GaudiPython.Pythonizations.__len__
__len__
Definition: Pythonizations.py:116

## ◆ __new__()

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

141 def __new__(cls, *args, **kwargs):
142 """To Gaudi, any object with the same type/name is the same object. Hence,
143 this is mimicked in the configuration: instantiating a new Configurable
144 of a type with the same name will return the same instance."""
145
146 global log
147 # try to get the name of the Configurable (having a name is compulsory)
148 if 'name' in kwargs:
149 # simple keyword (by far the easiest)
150 name = kwargs['name']
151 elif 'name' in cls.__init__.func_code.co_varnames:
152 # either positional in args, or default
153 index = list(cls.__init__.func_code.co_varnames).index('name')
154 try:
155 # var names index is offset by one as __init__ is to be called with self
156 name = args[index - 1]
157 except IndexError:
158 # retrieve default value, then
159 name = cls.__init__.func_defaults[index - (len(args) + 1)]
160 else:
161 # positional index is assumed (will work most of the time)
162 try:
163 name = args[1] # '0' is for self
164 except (IndexError, TypeError):
165 raise TypeError('no "name" argument while instantiating "%s"' %
166 cls.__name__)
167
168 argname = name
169 if name == Configurable.DefaultName:
170 if hasattr(cls, 'DefaultedName'):
171 name = cls.DefaultedName
172 else:
173 name = cls.getType()
174 elif not name or type(name) != str:
175 # unnamed, highly specialized user code, etc. ... unacceptable
176 raise TypeError(
177 'could not retrieve name from %s.__init__ arguments' %
178 cls.__name__)
179
180 # Handle the case of global tools to prepend ToolSvc in the name.
181 # This is needed for compatibility with old JobOptions files being read
182 if issubclass(cls, ConfigurableAlgTool) and '.' not in name:
183 name = 'ToolSvc.' + name
184
185 # close backdoor access to otherwise private subalgs/tools
186 # PM if 0 <= name.find( '.' ):
187 # PM # temp protection for old style types
188 # PM from OldStyleConfig import GenericConfigurable
189 # PM if not issubclass( cls, GenericConfigurable ): # except raised for new types only
190 # PM raise NameError( '"%s": backdoor access to private configurables not allowed' % name )
191
192 # ordinary recycle case
193 if name in cls.configurables:
194 conf = cls.configurables[name]
195 if name != argname: # special case: user derived <-> real ... make same
196 cls.configurables[conf.getType()] = conf
197 # ---PM: Initialize additional properties
198 for n, v in kwargs.items():
199 if n != "name": # it should not be confused with a normal property
200 setattr(conf, n, v)
201 if not cls._configurationLocked and not "_enabled" in kwargs and isinstance(
202 conf, ConfigurableUser):
203 # Ensure that the ConfigurableUser gets enabled if nothing is
204 # specified in the constructor.
205 setattr(conf, "_enabled", True)
206 return conf
207
208 # a couple of special cases (note that these cases don't mix)
209 spos = name.find('/')
210 ti_name = None
211 if spos < 0:
212 ti_name = "%s/%s" % (name, name)
213 if ti_name in cls.configurables:
214 # support for old-style name as type/name lookup where name==type
215 return cls.configurables[ti_name]
216
217 i_name = None
218 if spos > 0:
219 i_name = name[:spos]
220 if i_name == name[spos + 1:] and i_name in cls.configurables:
221 # this is the opposite of the above special case
222 return cls.configurables[i_name]
223
224 # the following is purely for debugging support and should realistically bomb
225 conf = cls.allConfigurables.get(name, None) or\
226 (spos < 0 and cls.allConfigurables.get(ti_name, None)) or\
227 (spos > 0 and i_name == name[spos + 1:]
228 and cls.allConfigurables.get(i_name, None))
229 if conf: # wrong type used?
230 if conf.__class__ is ConfigurableGeneric:
231 # If the instance found is ConfigurableGeneric then
232 # we create a new one with the proper type and fill with
233 # the contents of the generic one
234 newconf = object.__new__(cls)
235 cls.__init__(newconf, *args, **kwargs)
236 # initialize with the properties of generic configurable
237 # (we map the names of the properties to lowercase versions because
238 # old options are not case sensitive)
239 names = {}
240 for n in newconf.__slots__:
241 names[n.lower()] = n
242 for n in conf._properties:
243 if names[n.lower()] != n:
244 log.warning(
245 "Option '%s' was used for %s, but the correct spelling is '%s'"
246 % (n, name, names[n.lower()]))
247 setattr(newconf, names[n.lower()], getattr(conf, n))
248 for n, v in kwargs.items():
249 setattr(newconf, n, v)
250 cls.configurables[name] = newconf
251 cls.allConfigurables[name] = newconf
252 return newconf
253 else:
254 # will be an actual error in the future (now only report as such)
255 log.error(
256 'attempt to redefine type of "%s" (was: %s, new: %s)%s',
257 name, conf.__class__.__name__, cls.__name__,
258 error_explanation)
259 # in the future:
260 # return None # will bomb on use (or go unharmed on non-use)
261 # for now, allow use through allConfigurables lookup
262 # ---PM: Initialize additional properties
263 for n, v in kwargs.items():
264 setattr(conf, n, v)
265 return conf
266
267 # still here: create a new instance and initialize it
268 conf = object.__new__(cls)
269 cls.__init__(conf, *args, **kwargs)
270
271 # update normal, per-class cache
272 cls.configurables[name] = conf
273
274 for base in cls.__bases__:
275 if base.__name__ == 'ConfigurableService':
276 cls.configurableServices[name] = conf
277
278 # update generics super-cache, if needed
279 cls.allConfigurables[name] = conf
280 # -->PM#if hasattr( cls, 'getType' ) and name.find('/') < 0:
281 # -->PM# cls.allConfigurables[ cls.getType() + '/' + name ] = conf
282
283 return conf
284
gaudirun.type
type
Definition: gaudirun.py:142
Gaudi::Functional::details::get
auto get(const Handle &handle, const Algo &, const EventContext &) -> decltype(details::deref(handle.get()))
Definition: FunctionalDetails.h:332

## ◆ __nonzero__()

def GaudiKernel.Configurable.Configurable.__nonzero__ | ( |  | self | ) |

Definition at line 486 of file Configurable.py.

486 def __nonzero__(self):
487 return True
488

## ◆ __repr__()

def GaudiKernel.Configurable.Configurable.__repr__ | ( |  | self | ) |

Definition at line 908 of file Configurable.py.

908 def __repr__(self):
909 return '{0}({1!r})'.format(self.__class__.__name__, self.name())
910
format
GAUDI_API std::string format(const char *,...)
MsgStream format utility "a la sprintf(...)".
Definition: MsgStream.cpp:109
GaudiPython.HistoUtils.__repr__
__repr__
Definition: HistoUtils.py:508

## ◆ __setattr__()

def GaudiKernel.Configurable.Configurable.__setattr__ | ( |  | self,
|  |  | name,
|  |  | value
| ) |  |

Reimplemented in GaudiKernel.Configurable.ConfigurableGeneric.

Definition at line 449 of file Configurable.py.

449 def __setattr__(self, name, value):
450 if self._configurationLocked:
451 raise RuntimeError(
452 "%s: Configuration cannot be modified after the ApplicationMgr has been started."
453 % self.name())
454 try:
455 super(Configurable, self).__setattr__(name, value)
456 except AttributeError:
457 raise AttributeError(
458 "Configurable '%s' does not have property '%s'." %
459 (self.__class__.__name__, name))
460

## ◆ __setstate__()

def GaudiKernel.Configurable.Configurable.__setstate__ | ( |  | self,
|  |  | dict
| ) |  |

Definition at line 359 of file Configurable.py.

359 def __setstate__(self, dict):
360 self._initok = True
361 from contextlib import contextmanager
362
363 @contextmanager
364 def unpickling():
365 try:
366 self._unpickling = True
367 yield
368 finally:
369 self._unpickling = False
370
371 with unpickling():
372 for n, v in dict.items():
373 setattr(self, n, v)
374

## ◆ __setupDefaults()

def GaudiKernel.Configurable.Configurable.__setupDefaults | ( |  | self | ) |
| private

Definition at line 884 of file Configurable.py.

884 def __setupDefaults(self):
885 # set handle defaults flags to inform __setattr__ that it is being
886 # called during setDefaults of the concrete Configurable
887 self._inSetDefaults = True
888 self.setDefaults(self)
889 self._inSetDefaults = False
890

## ◆ __setupDlls()

def GaudiKernel.Configurable.Configurable.__setupDlls | ( |  | self | ) |
| private

Definition at line 872 of file Configurable.py.

872 def __setupDlls(self):
873 dlls = self.getDlls()
874 if not dlls:
875 dlls = []
876 elif type(dlls) == types.StringType:
877 dlls = [dlls]
878
879 from __main__ import theApp
880 dlls = filter(lambda d: d not in theApp.Dlls, dlls)
881 if dlls:
882 theApp.Dlls += dlls
883
gaudirun.type
type
Definition: gaudirun.py:142

## ◆ __setupServices()

def GaudiKernel.Configurable.Configurable.__setupServices | ( |  | self | ) |
| private

Definition at line 855 of file Configurable.py.

855 def __setupServices(self):
856 #svcs = self.getServices()
857 # if not svcs:
858 svcs = []
859 # elif type(svcs) == types.StringType:
860 # svcs = [ svcs ]
861
862 import __main__
863 for svc in svcs:
864 handle = __main__.Service(svc)
865 # services should be configurables as well, but aren't for now
866 # handle.setup()
867
868 # allow Configurable to make some changes
869 if hasattr(self, 'configure' + svc):
870 eval('self.configure' + svc + '( handle )')
871

## ◆ __str__()

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

Definition at line 911 of file Configurable.py.

911 def __str__(self, indent=0, headerLastIndentUnit=indentUnit):
912 global log # to print some info depending on output level
913 indentStr = indent * Configurable.indentUnit
914 # print header
915 title = self.getPrintTitle()
916 # print line to easily see start-of-configurable
917 if indent > 0:
918 headerIndent = (indent - 1) * \
919 Configurable.indentUnit + headerLastIndentUnit
920 else:
921 headerIndent = ''
922 rep = Configurable._printHeader(headerIndent, title)
923 rep += os.linesep
924 # print own properties
925 props = self.getProperties()
926 defs = self.getDefaultProperties()
927 if not props:
928 rep += indentStr + '|-<no properties>' + os.linesep
929 else:
930 # get property name with
931 nameWidth = 0
932 for p in props.keys():
933 nameWidth = max(nameWidth, len(p))
934 for p, v in props.items():
935 # start with indent and property name
936 prefix = indentStr + '|-%-*s' % (nameWidth, p)
937 # add memory address for debugging (not for defaults)
938 if log.isEnabledFor(logging.DEBUG):
939 if v != Configurable.propertyNoValue:
940 address = ' @%11s' % hex(id(v))
941 else:
942 address = 13 * ' '
943 prefix += address
944 # add value and default
945 default = defs.get(p)
946 if v == Configurable.propertyNoValue:
947 # show default value as value, and no extra 'default'
948 strVal = repr(default)
949 strDef = None
950 else:
951 # convert configurable to handle
952 if hasattr(v, "getGaudiHandle"):
953 vv = v.getGaudiHandle()
954 else:
955 vv = v
956 if isinstance(vv, GaudiHandle) or isinstance(
957 vv, GaudiHandleArray):
958 strVal = repr(vv)
959 # the default may not be a GaudiHandle (?)
960 if hasattr(default, "toStringProperty"):
961 strDef = repr(default.toStringProperty())
962 else:
963 strDef = repr(default)
964 if strDef == repr(vv.toStringProperty()):
965 strDef = None
966 else:
967 strVal = repr(vv)
968 strDef = repr(default)
969 # add the value
970 line = prefix + ' = ' + strVal
971 # add default if present
972 if strDef is not None:
973 # put default on new line if too big
974 if len(line) + len(strDef) > Configurable.printHeaderWidth:
975 line += os.linesep + indentStr + '| ' + \
976 (len(prefix) - len(indentStr) - 3) * ' '
977 line += ' (default: %s)' % (strDef, )
978 # add the line to the total string
979 rep += line + os.linesep
980 # print out full private configurables
981 # if isinstance(v,Configurable) and not v.isPublic():
MSG::hex
MsgStream & hex(MsgStream &log)
Definition: MsgStream.h:271
max
EventIDBase max(const EventIDBase &lhs, const EventIDBase &rhs)
Definition: EventIDBase.h:215
GaudiPython.HistoUtils.__str__
__str__
Definition: HistoUtils.py:510

## ◆ _isInSetDefaults()

def GaudiKernel.Configurable.Configurable._isInSetDefaults | ( |  | self | ) |
| private

Definition at line 852 of file Configurable.py.

852 def _isInSetDefaults(self):
853 return self._inSetDefaults
854

## ◆ _printFooter()

def GaudiKernel.Configurable.Configurable._printFooter | ( |  | indentStr,
|  |  | title
| ) |  |
| static private

Definition at line 900 of file Configurable.py.

900 def _printFooter(indentStr, title):
901 preLen = Configurable.printHeaderPre
902 postLen = Configurable.printHeaderWidth - \
903 preLen - 12 - len(title) # - len(indentStr)
904 postLen = max(preLen, postLen)
905 return indentStr + '\\%s (End of %s) %s' % (preLen * '-', title,
906 postLen * '-')
907
max
EventIDBase max(const EventIDBase &lhs, const EventIDBase &rhs)
Definition: EventIDBase.h:215

## ◆ _printHeader()

def GaudiKernel.Configurable.Configurable._printHeader | ( |  | indentStr,
|  |  | title
| ) |  |
| static private

Definition at line 892 of file Configurable.py.

892 def _printHeader(indentStr, title):
893 preLen = Configurable.printHeaderPre
894 postLen = Configurable.printHeaderWidth - \
895 preLen - 3 - len(title) # - len(indentStr)
896 postLen = max(preLen, postLen)
897 return indentStr + '/%s %s %s' % (preLen * '*', title, postLen * '*')
898
max
EventIDBase max(const EventIDBase &lhs, const EventIDBase &rhs)
Definition: EventIDBase.h:215

## ◆ addTool()

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

Definition at line 829 of file Configurable.py.

829 def addTool(self, tool, name=None):
830 if isclass(tool) and issubclass(tool, ConfigurableAlgTool):
831 if name is None:
832 name = tool.__name__
833 priv_tool = tool(self.getName() + '.' + name)
834 elif isinstance(tool, ConfigurableAlgTool):
835 if name is None:
836 name = tool.splitName()[1]
837 priv_tool = tool.clone(self.getName() + '.' + name)
838 else:
839 if isclass(tool):
840 classname = tool.__name__
841 else:
842 classname = type(tool).__name__
843 raise TypeError(
844 "addTool requires AlgTool configurable. Got %s type" %
845 classname)
846 self.__tools[name] = priv_tool
847 if name in self.__slots__:
848 # this is to avoid that the property hides the tool
849 setattr(self, name, self.__tools[name])
850 return self.__tools[name]
851
gaudirun.type
type
Definition: gaudirun.py:142

## ◆ children()

def GaudiKernel.Configurable.Configurable.children | ( |  | self | ) |

Definition at line 537 of file Configurable.py.

537 def children(self):
538 log.error(
539 "children() is deprecated, use getChildren() instead for consistency"
540 )
541 log.error(
542 "getChildren() returns a copy; to add a child, use 'parent += child'%s",
543 error_explanation)
544 return self.__children # by ref, for compatibility
545

## ◆ clone()

def GaudiKernel.Configurable.Configurable.clone | ( |  | self,
|  |  | name = `None`,
|  | ** | kwargs
| ) |  |

Definition at line 782 of file Configurable.py.

782 def clone(self, name=None, **kwargs):
783 if not name:
784 if hasattr(self, 'DefaultedName'):
785 name = self.DefaultedName
786 else:
787 name = self.getType()
788
789 newconf = Configurable.__new__(self.__class__, name)
790 self.__class__.__init__(newconf, name)
791
792 for proxy in self._properties.values():
793 try:
794 value = proxy.__get__(self)
795 if type(value) in [str, list, dict, tuple]:
796 # clone the values of the properties for basic types
797 value = type(value)(value)
798 proxy.__set__(newconf, value)
799 except AttributeError:
800 pass
801
802 for c in self.__children:
803 newconf += c # processes proper copy semantics
804
805 for n, t in self.__tools.items():
806 newconf.addTool(t, n)
807
808 for name, value in kwargs.items():
809 setattr(newconf, name, value)
810
811 return newconf
812
gaudirun.type
type
Definition: gaudirun.py:142

## ◆ copyChild()

def GaudiKernel.Configurable.Configurable.copyChild | ( |  | self,
|  |  | child
| ) |  |

Reimplemented in GaudiKernel.Configurable.ConfigurableService.

Definition at line 499 of file Configurable.py.

499 def copyChild(self, child):
500 return copy.deepcopy(child)
501

## ◆ copyChildAndSetParent()

def GaudiKernel.Configurable.Configurable.copyChildAndSetParent | ( |  | self,
|  |  | cfg,
|  |  | parent
| ) |  |

Definition at line 511 of file Configurable.py.

511 def copyChildAndSetParent(self, cfg, parent):
512 cc = self.copyChild(cfg)
513
514 if hasattr(cc, 'setParent') and parent:
515 try:
516 cc.setParent(parent)
517 except RuntimeError as e:
518 # temporary backdoor resolution for compatibility
519 log.error(str(e) + '%s', error_explanation)
520 ccbd = cc.configurables[cc.getJobOptName()]
521
522 # merge properties, new over pre-existing
523 for proxy in self._properties.values():
524 if proxy.history.has_key(cc):
525 proxy.__set__(ccbd, proxy.__get__(cc))
526
527 # consolidate
528 cc = ccbd
529 return cc
530

## ◆ getAllChildren()

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

546 def getAllChildren(self):
547 """Get all (private) configurable children, both explicit ones (added with +=)
548 and the ones in the private GaudiHandle properties"""
549 childs = []
550 # add private configurable properties (also inside handles)
551 for proxy in self._properties.values():
552 try:
553 c = proxy.__get__(self)
554 except AttributeError:
555 pass
556 else:
557 if isinstance(c, Configurable) and not c.isPublic():
558 childs.append(c)
559 elif isinstance(c, GaudiHandle):
560 try:
561 conf = c.configurable
562 except AttributeError:
563 pass
564 else:
565 if not conf.isPublic():
566 childs.append(conf)
567 elif isinstance(c, GaudiHandleArray):
568 # only setup private arrays
569 if not c.isPublic():
570 for ci in c:
571 if isinstance(ci, Configurable):
572 childs.append(ci)
573 else:
574 try:
575 conf = ci.configurable
576 except AttributeError:
577 pass
578 else:
579 childs.append(conf)
580
581 # add explicit children
582 childs += self.__children
583 return childs
584

## ◆ getChildren()

def GaudiKernel.Configurable.Configurable.getChildren | ( |  | self | ) |

Definition at line 531 of file Configurable.py.

531 def getChildren(self):
532 return self.__children[:] # read only
533

## ◆ getDefaultProperties()

def GaudiKernel.Configurable.Configurable.getDefaultProperties | ( |  | cls | ) |

Definition at line 676 of file Configurable.py.

676 def getDefaultProperties(cls):
677 class collector:
678 pass
679
680 # user provided defaults
681 c = collector()
682 cls.setDefaults(c)
683
684 # defaults from C++
685 for k, v in cls._properties.items():
686 if not k in c.__dict__ and hasattr(v, 'default'):
687 c.__dict__[k] = v.default
688
689 return c.__dict__
690

## ◆ getDefaultProperty()

def GaudiKernel.Configurable.Configurable.getDefaultProperty | ( |  | cls,
|  |  | name
| ) |  |

Definition at line 692 of file Configurable.py.

692 def getDefaultProperty(cls, name):
693 class collector:
694 pass
695
696 # user provided defaults
697 c = collector()
698 cls.setDefaults(c)
699
700 if name in c.__dict__:
701 return c.__dict__[name]
702
703 # defaults from C++
704 try:
705 v = cls._properties[name]
706 if hasattr(v, 'default'):
707 return v.default
708 except KeyError:
709 pass
710
711 return None
712

## ◆ getFullJobOptName()

def GaudiKernel.Configurable.Configurable.getFullJobOptName | ( |  | self | ) |

Definition at line 766 of file Configurable.py.

766 def getFullJobOptName(self):
767 return "%s/%s" % (self.getType(), self.getJobOptName()
768 or self.getName())
769

## ◆ getFullName()

def GaudiKernel.Configurable.Configurable.getFullName | ( |  | self | ) |

Reimplemented in GaudiKernel.Configurable.ConfigurableAlgTool.

Definition at line 763 of file Configurable.py.

763 def getFullName(self):
764 return str(self.getType() + '/' + self.getName())
765

## ◆ getJobOptName()

def GaudiKernel.Configurable.Configurable.getJobOptName | ( |  | self | ) |

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

Definition at line 750 of file Configurable.py.

750 def getJobOptName(self): # full hierachical name
751 return self.getName()
752

## ◆ getName()

def GaudiKernel.Configurable.Configurable.getName | ( |  | self | ) |

Definition at line 744 of file Configurable.py.

744 def getName(self):
745 return self._name
746

## ◆ getParent()

def GaudiKernel.Configurable.Configurable.getParent | ( |  | self | ) |

Reimplemented in GaudiKernel.Configurable.ConfigurableAlgTool.

Definition at line 505 of file Configurable.py.

505 def getParent(self):
506 return ""
507

## ◆ getPrintTitle()

def GaudiKernel.Configurable.Configurable.getPrintTitle | ( |  | self | ) |

Reimplemented in GaudiKernel.Configurable.ConfigurableAlgTool.

Definition at line 770 of file Configurable.py.

770 def getPrintTitle(self):
771 return self.getGaudiType() + ' ' + self.getTitleName()
772

## ◆ getProp()

def GaudiKernel.Configurable.Configurable.getProp | ( |  | self,
|  |  | name
| ) |  |

    Returns the value of the given property.

Definition at line 713 of file Configurable.py.

713 def getProp(self, name):
714 """Returns the value of the given property.
715 """
716 if hasattr(self, name):
717 return getattr(self, name)
718 else:
719 return self.getDefaultProperties()[name]
720

## ◆ getProperties()

def GaudiKernel.Configurable.Configurable.getProperties | ( |  | self | ) |

Definition at line 625 of file Configurable.py.

625 def getProperties(self):
626 props = {}
627 for name, proxy in self._properties.items():
628 try:
629 props[name] = proxy.__get__(self)
630 except AttributeError:
631 props[name] = Configurable.propertyNoValue
632
633 return props
634

## ◆ getPropertiesWithDescription()

def GaudiKernel.Configurable.Configurable.getPropertiesWithDescription | ( |  | self | ) |

    Get all properties with their description string as { name : (value, desc) }.

Definition at line 635 of file Configurable.py.

635 def getPropertiesWithDescription(self):
636 """Get all properties with their description string as { name : (value, desc) }."""
637 props = {}
638 for name, proxy in self._properties.items():
639 try:
640 props[name] = (proxy.__get__(self), proxy.__doc__)
641 except AttributeError:
642 props[name] = (Configurable.propertyNoValue, proxy.__doc__)
643 return props
644

## ◆ getSequence()

def GaudiKernel.Configurable.Configurable.getSequence | ( |  | self | ) |

Definition at line 585 of file Configurable.py.

585 def getSequence(self):
586 elems = []
587 for c in self.__children:
588 elems.append(c.getFullName())
589 return elems
590

## ◆ getTitleName()

def GaudiKernel.Configurable.Configurable.getTitleName | ( |  | self | ) |

Definition at line 773 of file Configurable.py.

773 def getTitleName(self):
774 if log.isEnabledFor(logging.DEBUG):
775 return self.getFullJobOptName()
776 else:
777 return self.getFullName()
778

## ◆ getTools()

def GaudiKernel.Configurable.Configurable.getTools | ( |  | self | ) |

Definition at line 534 of file Configurable.py.

534 def getTools(self):
535 return self.__tools.values() # read only
536

## ◆ getType()

def GaudiKernel.Configurable.Configurable.getType | ( |  | cls | ) |

Definition at line 741 of file Configurable.py.

741 def getType(cls):
742 return cls.__name__
743

## ◆ getValuedProperties()

def GaudiKernel.Configurable.Configurable.getValuedProperties | ( |  | self | ) |

Definition at line 645 of file Configurable.py.

645 def getValuedProperties(self):
646 props = {}
647 for name, proxy in self._properties.items():
648 if self.isPropertySet(name):
649 value = proxy.__get__(self)
650 if hasattr(value, 'getFullName'):
651 value = value.getFullName()
652 elif type(value) in [list, tuple]:
653 new_value = []
654 for i in value:
655 if hasattr(i, 'getFullName'):
656 new_value.append(i.getFullName())
657 else:
658 new_value.append(i)
659 value = type(value)(new_value)
660 elif type(value) is dict:
661 new_value = {}
662 for i in value:
663 if hasattr(value[i], 'getFullName'):
664 new_value[i] = value[i].getFullName()
665 else:
666 new_value[i] = value[i]
667 value = new_value
668 props[name] = value
669
670 return props
671
gaudirun.type
type
Definition: gaudirun.py:142

## ◆ hasParent()

def GaudiKernel.Configurable.Configurable.hasParent | ( |  | self,
|  |  | parent
| ) |  |

Reimplemented in GaudiKernel.Configurable.ConfigurableAlgTool.

Definition at line 508 of file Configurable.py.

508 def hasParent(self, parent):
509 return False
510

## ◆ isPropertySet()

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

726 def isPropertySet(self, name):
727 """Tell if the property 'name' has been set or not.
728
729 Because of a problem with list and dictionary properties, in those cases
730 if the value is equal to the default, the property is considered as not
731 set.
732 """
733 if not hasattr(self, name):
734 return False
735 default = self.getDefaultProperty(name)
736 if isinstance(default, (list, dict, DataObjectHandleBase)):
737 value = getattr(self, name)
738 return value != default
739 return True
740

## ◆ isPublic()

def GaudiKernel.Configurable.Configurable.isPublic | ( |  | self | ) |

Reimplemented in GaudiKernel.Configurable.ConfigurableAlgTool.

Definition at line 753 of file Configurable.py.

753 def isPublic(self):
754 return True
755

## ◆ jobOptName()

def GaudiKernel.Configurable.Configurable.jobOptName | ( |  | self | ) |

Definition at line 757 of file Configurable.py.

757 def jobOptName(self):
758 log.error(
759 "jobOptName() is deprecated, use getJobOptName() instead for consistency%s",
760 error_explanation)
761 return self.getJobOptName() # compatibility
762

## ◆ name()

def GaudiKernel.Configurable.Configurable.name | ( |  | self | ) |

Definition at line 747 of file Configurable.py.

747 def name(self):
748 return self.getName()
749
gaudiComponentHelp.name
name
Definition: gaudiComponentHelp.py:41

## ◆ properties()

def GaudiKernel.Configurable.Configurable.properties | ( |  | self | ) |

Definition at line 672 of file Configurable.py.

672 def properties(self):
673 return self.getProperties() # compatibility
674
gaudiComponentHelp.properties
properties
Definition: gaudiComponentHelp.py:51

## ◆ remove()

def GaudiKernel.Configurable.Configurable.remove | ( |  | self,
|  |  | items
| ) |  |

Definition at line 489 of file Configurable.py.

489 def remove(self, items):
490 if type(items) != list and type(items) != tuple:
491 items = [items]
492
493 self.__children = [e for e in self.__children if not e in items]
494
gaudirun.type
type
Definition: gaudirun.py:142

## ◆ removeAll()

def GaudiKernel.Configurable.Configurable.removeAll | ( |  | self | ) |

Definition at line 495 of file Configurable.py.

495 def removeAll(self):
496 self.remove(self.__children)
497

## ◆ setDefaults()

def GaudiKernel.Configurable.Configurable.setDefaults | ( |  | cls,
|  |  | handle
| ) |  |

Definition at line 779 of file Configurable.py.

779 def setDefaults(cls, handle):
780 pass
781

## ◆ setParent()

def GaudiKernel.Configurable.Configurable.setParent | ( |  | self,
|  |  | parentName
| ) |  |

Reimplemented in GaudiKernel.Configurable.ConfigurableAlgTool.

Definition at line 502 of file Configurable.py.

502 def setParent(self, parentName):
503 pass
504

## ◆ setProp()

def GaudiKernel.Configurable.Configurable.setProp | ( |  | self,
|  |  | name,
|  |  | value
| ) |  |

    Set the value of a given property

Definition at line 721 of file Configurable.py.

721 def setProp(self, name, value):
722 """Set the value of a given property
723 """
724 return setattr(self, name, value)
725

## ◆ setup()

def GaudiKernel.Configurable.Configurable.setup | ( |  | self | ) |

Definition at line 591 of file Configurable.py.

591 def setup(self):
592 # make sure base class init has been called
593 if not hasattr(self, '_initok') or not self._initok:
594 # could check more, but this is the only explanation
595 raise TypeError("Configurable.__init__ not called in %s override" %
596 self.__class__.__name__)
597
598 # log.debug("calling setup() on " + self.getFullJobOptName())
599
600 # setup self: this collects all values on the python side
601 self.__setupServices()
602 self.__setupDlls()
603 self.__setupDefaults()
604
605 # setup children
606 for c in self.getAllChildren():
607 c.setup()
608
609 # now get handle to work with for moving properties into the catalogue
610 handle = self.getHandle()
611 if not handle:
612 log.debug('no handle for %s: not transporting properties',
613 self._name)
614 return # allowed, done early
615
616 # pass final set of properties on to handle on the C++ side or JobOptSvc
617 for name in self._properties.keys():
618 if hasattr(self,
619 name): # means property has python-side value/default
620 setattr(handle, name, getattr(self, name))
621
622 # for debugging purposes
623 self._setupok = True
624

## ◆ splitName()

def GaudiKernel.Configurable.Configurable.splitName | ( |  | self | ) |

Definition at line 813 of file Configurable.py.

813 def splitName(self):
814 fullname = self.getName()
815 dot = fullname.find('.')
816 if dot != -1:
817 parentname = fullname[:dot]
818 longname = fullname[dot + 1:]
819 else:
820 parentname = ''
821 longname = fullname
822 dot = longname.find('.')
823 if dot != -1:
824 name = longname[:dot]
825 else:
826 name = longname
827 return parentname, name, longname
828

## Member Data Documentation

## ◆ __children

GaudiKernel.Configurable.Configurable.__children
| private

Definition at line 318 of file Configurable.py.

## ◆ __metaclass__

GaudiKernel.Configurable.Configurable.__metaclass__ = ConfigurableMeta.ConfigurableMeta
| static private

Definition at line 121 of file Configurable.py.

## ◆ __slots__

tuple GaudiKernel.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)
'_unpickling', # flag for actions done during unpickling
)

Definition at line 123 of file Configurable.py.

## ◆ __tools

GaudiKernel.Configurable.Configurable.__tools
| private

Definition at line 319 of file Configurable.py.

## ◆ _configurationLocked

bool GaudiKernel.Configurable.Configurable._configurationLocked = False
| static private

Definition at line 139 of file Configurable.py.

## ◆ _initok

GaudiKernel.Configurable.Configurable._initok
| private

Definition at line 334 of file Configurable.py.

## ◆ _inSetDefaults

GaudiKernel.Configurable.Configurable._inSetDefaults
| private

Definition at line 331 of file Configurable.py.

## ◆ _name

GaudiKernel.Configurable.Configurable._name
| private

Definition at line 324 of file Configurable.py.

## ◆ _setupok

GaudiKernel.Configurable.Configurable._setupok
| private

Definition at line 337 of file Configurable.py.

## ◆ _unpickling

GaudiKernel.Configurable.Configurable._unpickling
| private

Definition at line 340 of file Configurable.py.

## ◆ allConfigurables

dictionary GaudiKernel.Configurable.Configurable.allConfigurables
| static

Initial value:
= {
}

Definition at line 133 of file Configurable.py.

## ◆ configurableServices

dictionary GaudiKernel.Configurable.Configurable.configurableServices
| static

Initial value:
= {
}

Definition at line 135 of file Configurable.py.

## ◆ indentUnit

string GaudiKernel.Configurable.Configurable.indentUnit = '| '
| static

Definition at line 117 of file Configurable.py.

## ◆ printHeaderPre

int GaudiKernel.Configurable.Configurable.printHeaderPre = 5
| static

Definition at line 119 of file Configurable.py.

## ◆ printHeaderWidth

int GaudiKernel.Configurable.Configurable.printHeaderWidth = 100
| static

Definition at line 118 of file Configurable.py.

## ◆ propertyNoValue

GaudiKernel.Configurable.Configurable.propertyNoValue
| static

Definition at line 116 of file Configurable.py.

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

- GaudiKernel/python/GaudiKernel/Configurable.py