Gaudi Framework, version v23r5

Home   Generated: Wed Nov 28 2012
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Public Member Functions | List of all members
GaudiKernel.ConfigurableMeta.ConfigurableMeta Class Reference

this metaclass installs PropertyProxy descriptors for Gaudi properties More...

Inheritance diagram for GaudiKernel.ConfigurableMeta.ConfigurableMeta:
Inheritance graph
[legend]
Collaboration diagram for GaudiKernel.ConfigurableMeta.ConfigurableMeta:
Collaboration graph
[legend]

Public Member Functions

def __new__
 
def __call__
 

Detailed Description

this metaclass installs PropertyProxy descriptors for Gaudi properties

The setting of Gaudi component properties needs to be deferred and
   history of who set what where needs to be collected. This is done
   by using PropertyProxy descriptors rather than the default ones.

Definition at line 14 of file ConfigurableMeta.py.

Member Function Documentation

def GaudiKernel.ConfigurableMeta.ConfigurableMeta.__call__ (   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 65 of file ConfigurableMeta.py.

65 
66  def __call__( cls, *args, **kwargs ):
67  """To Gaudi, any object with the same type/name is the same object. Hence,
68  this is mimicked in the configuration: instantiating a new Configurable
69  of a type with the same name will return the same instance."""
70 
71  # Get the instance: `singleton' logic needs to be in __new__, not here,
72  # for compatibililty with pickling.)
73  cfg = cls.__new__( cls, *args, **kwargs )
74 
75  # Initialize the object, if not done already.
76  if not hasattr(cfg, '_initok') or not cfg._initok:
77  cls.__init__( cfg, *args, **kwargs )
78 
79  return cfg
def GaudiKernel.ConfigurableMeta.ConfigurableMeta.__new__ (   self,
  name,
  bases,
  dct 
)

Definition at line 19 of file ConfigurableMeta.py.

19 
20  def __new__( self, name, bases, dct ):
21  # enfore use of classmethod for getType() and setDefaults()
22  if 'getType' in dct and not isinstance( dct[ 'getType' ], classmethod ):
23  dct[ 'getType' ] = classmethod( dct[ 'getType' ] )
24 
25  if 'setDefaults' in dct and not isinstance( dct[ 'setDefaults' ], classmethod ):
26  dct[ 'setDefaults' ] = classmethod( dct[ 'setDefaults' ] )
27 
28  # collect what are properties (basically, any public name; C++ variables
29  # shouldn't start with an '_' because of portability constraints, hence
30  # it is safe to assume that any such vars are python private ones)
31  newclass = type.__new__( self, name, bases, dct )
32 
33  # cache references of instances by name for duplicate removal
34  newclass.configurables = {}
35 
36  # loop over slots, which are all assumed to be properties, create proxies, defaults
37  properties = {}
38  slots = dct.get( '__slots__' )
39  if slots:
40  props = [ x for x in slots if x[0] != '_' ]
41  propDict = dct.get('_propertyDocDct')
42  for prop in props:
43  docString = propDict and propDict.get(prop)
44  if type(slots) == dict:
45  default = slots[prop]
46  else:
47  default = None
48  proxy = PropertyProxy.PropertyProxyFactory( getattr( newclass, prop ), docString, default )
49 
50  properties[ prop ] = proxy
51  setattr( newclass, prop, proxy )
52 
53  # complete set of properties includes those from base classes
54  for base in bases:
55  try:
56  bprops = base._properties.copy()
57  bprops.update( properties )
58  properties = bprops
59  except AttributeError:
60  pass
61 
62  newclass._properties = properties
63 
64  return newclass

The documentation for this class was generated from the following file:
Generated at Wed Nov 28 2012 12:17:39 for Gaudi Framework, version v23r5 by Doxygen version 1.8.2 written by Dimitri van Heesch, © 1997-2004