Gaudi Framework, version v22r2

Home   Generated: Tue May 10 2011
Public Member Functions

ConfigurableMeta::ConfigurableMeta Class Reference

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

List of all members.

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 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.

00066                                         :
00067         """To Gaudi, any object with the same type/name is the same object. Hence,
00068            this is mimicked in the configuration: instantiating a new Configurable
00069            of a type with the same name will return the same instance."""
00070 
00071      # Get the instance: `singleton' logic needs to be in __new__, not here,
00072      # for compatibililty with pickling.)
00073         cfg = cls.__new__( cls, *args, **kwargs )
00074 
00075      # Initialize the object, if not done already.
00076         if not hasattr(cfg, '_initok') or not cfg._initok:
00077             cls.__init__( cfg, *args, **kwargs )
00078 
00079         return cfg
def ConfigurableMeta::ConfigurableMeta::__new__ (   self,
  name,
  bases,
  dct 
)

Definition at line 19 of file ConfigurableMeta.py.

00020                                          :
00021      # enfore use of classmethod for getType() and setDefaults()
00022         if 'getType' in dct and not isinstance( dct[ 'getType' ], classmethod ):
00023             dct[ 'getType' ] = classmethod( dct[ 'getType' ] )
00024 
00025         if 'setDefaults' in dct and not isinstance( dct[ 'setDefaults' ], classmethod ):
00026             dct[ 'setDefaults' ] = classmethod( dct[ 'setDefaults' ] )
00027 
00028      # collect what are properties (basically, any public name; C++ variables
00029      # shouldn't start with an '_' because of portability constraints, hence
00030      # it is safe to assume that any such vars are python private ones)
00031         newclass = type.__new__( self, name, bases, dct )
00032 
00033      # cache references of instances by name for duplicate removal
00034         newclass.configurables = {}
00035 
00036      # loop over slots, which are all assumed to be properties, create proxies, defaults
00037         properties = {}
00038         slots = dct.get( '__slots__' )
00039         if slots:
00040             props = [ x for x in slots if x[0] != '_' ]
00041             propDict = dct.get('_propertyDocDct')
00042             for prop in props:
00043                 docString = propDict and propDict.get(prop)
00044                 if type(slots) == dict:
00045                     default = slots[prop]
00046                 else:
00047                     default = None
00048                 proxy = PropertyProxy.PropertyProxyFactory( getattr( newclass, prop ), docString, default )
00049 
00050                 properties[ prop ] = proxy
00051                 setattr( newclass, prop, proxy )
00052 
00053      # complete set of properties includes those from base classes
00054         for base in bases:
00055             try:
00056                 bprops = base._properties.copy()
00057                 bprops.update( properties )
00058                 properties = bprops
00059             except AttributeError:
00060                 pass
00061 
00062         newclass._properties = properties
00063 
00064         return newclass


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines

Generated at Tue May 10 2011 18:55:17 for Gaudi Framework, version v22r2 by Doxygen version 1.7.2 written by Dimitri van Heesch, © 1997-2004