CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Attributes
Config.Modifier Class Reference
Inheritance diagram for Config.Modifier:

Public Member Functions

def __call__
 
def __init__
 
def modify
 
def toModify
 
def toModifyProcess
 

Private Attributes

 __objectToModifiers
 
 __processModifiers
 

Detailed Description

This class is used to define standard modifications to a Process.
An instance of this class is declared to denote a specific modification,e.g. era2017 could
reconfigure items in a process to match our expectation of running in 2017. Once declared,
these Modifier instances are imported into a configuration and items which need to be modified
are then associated with the Modifier and with the action to do the modification.
The registered modifications will only occur if the modify() method is called.

Definition at line 1041 of file Config.py.

Constructor & Destructor Documentation

def Config.Modifier.__init__ (   self)

Definition at line 1049 of file Config.py.

1050  def __init__(self):
self.__processModifiers = []

Member Function Documentation

def Config.Modifier.__call__ (   self,
  process 
)
Forwards to modify call. The presence of a __call__ allows Modifiers to be chained together.
E.g. Have bar inherit all modifiers of foo
   foo = Modifier()
   bar = Modifier()
   foo.toModifyProcess(bar)

Definition at line 1080 of file Config.py.

References AlignableModifier.modify(), and Config.Modifier.modify().

1081  def __call__(self,process):
1082  """Forwards to modify call. The presence of a __call__ allows Modifiers to be chained together.
1083  E.g. Have bar inherit all modifiers of foo
1084  foo = Modifier()
1085  bar = Modifier()
1086  foo.toModifyProcess(bar)
1087  """
self.modify(process)
def Config.Modifier.modify (   self,
  process 
)
This applies all the registered modifiers to the passed in process

Definition at line 1069 of file Config.py.

References Config.Modifier.__objectToModifiers, Config.Modifier.__processModifiers, and m.

Referenced by Config.Modifier.__call__().

1070  def modify(self,process):
1071  """This applies all the registered modifiers to the passed in process"""
1072  for m in self.__processModifiers:
1073  m(process)
1074  for o,m in self.__objectToModifiers:
1075  if isinstance(o,_Labelable):
1076  if o.hasLabel_():
1077  m(o)
1078  else:
1079  m(o)
return process
def Config.Modifier.toModify (   self,
  obj,
  func = None,
  kw 
)
This is used to register an action to be performed on the specific object. Two different forms are allowed
Form 1: A callable object (e.g. function) can be passed as the second. This callable object is expected to take one argument
which will be the object passed in as the first argument.
Form 2: A list of parameter name, value pairs can be passed
   mod.toModify(foo, fred=cms.int32(7), barney = cms.double(3.14))

Definition at line 1056 of file Config.py.

1057  def toModify(self,obj, func=None,**kw):
1058  """This is used to register an action to be performed on the specific object. Two different forms are allowed
1059  Form 1: A callable object (e.g. function) can be passed as the second. This callable object is expected to take one argument
1060  which will be the object passed in as the first argument.
1061  Form 2: A list of parameter name, value pairs can be passed
1062  mod.toModify(foo, fred=cms.int32(7), barney = cms.double(3.14))
1063  """
1064  if func is not None and len(kw) != 0:
1065  raise TypeError("toModify takes either two arguments or one argument and key/value pairs")
1066  if func is not None:
1067  self.__objectToModifiers.append( (obj,func))
1068  else:
self.__objectToModifiers.append( (obj, _ParameterModifier(kw)))
def Config.Modifier.toModifyProcess (   self,
  func 
)
This is used to register actions to be performed on the process as a whole.
This takes as argument a callable object (e.g. function) which takes as its sole argument an instance of Process

Definition at line 1052 of file Config.py.

1053  def toModifyProcess(self,func):
1054  """This is used to register actions to be performed on the process as a whole.
1055  This takes as argument a callable object (e.g. function) which takes as its sole argument an instance of Process"""
self.__processModifiers.append(func)
def toModifyProcess
Definition: Config.py:1052

Member Data Documentation

Config.Modifier.__objectToModifiers
private

Definition at line 1050 of file Config.py.

Referenced by Config.Modifier.modify().

Config.Modifier.__processModifiers
private

Definition at line 1051 of file Config.py.

Referenced by Config.Modifier.modify().