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 1043 of file Config.py.

Constructor & Destructor Documentation

def Config.Modifier.__init__ (   self)

Definition at line 1051 of file Config.py.

1052  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 1082 of file Config.py.

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

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

Definition at line 1071 of file Config.py.

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

Referenced by Config.Modifier.__call__().

1072  def modify(self,process):
1073  """This applies all the registered modifiers to the passed in process"""
1074  for m in self.__processModifiers:
1075  m(process)
1076  for o,m in self.__objectToModifiers:
1077  if isinstance(o,_Labelable):
1078  if o.hasLabel_():
1079  m(o)
1080  else:
1081  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 1058 of file Config.py.

1059  def toModify(self,obj, func=None,**kw):
1060  """This is used to register an action to be performed on the specific object. Two different forms are allowed
1061  Form 1: A callable object (e.g. function) can be passed as the second. This callable object is expected to take one argument
1062  which will be the object passed in as the first argument.
1063  Form 2: A list of parameter name, value pairs can be passed
1064  mod.toModify(foo, fred=cms.int32(7), barney = cms.double(3.14))
1065  """
1066  if func is not None and len(kw) != 0:
1067  raise TypeError("toModify takes either two arguments or one argument and key/value pairs")
1068  if func is not None:
1069  self.__objectToModifiers.append( (obj,func))
1070  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 1054 of file Config.py.

1055  def toModifyProcess(self,func):
1056  """This is used to register actions to be performed on the process as a whole.
1057  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:1054

Member Data Documentation

Config.Modifier.__objectToModifiers
private

Definition at line 1052 of file Config.py.

Referenced by Config.Modifier.modify().

Config.Modifier.__processModifiers
private

Definition at line 1053 of file Config.py.

Referenced by Config.Modifier.modify().