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

Constructor & Destructor Documentation

def Config.Modifier.__init__ (   self)

Definition at line 1026 of file Config.py.

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

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

1058  def __call__(self,process):
1059  """Forwards to modify call. The presence of a __call__ allows Modifiers to be chained together.
1060  E.g. Have bar inherit all modifiers of foo
1061  foo = Modifier()
1062  bar = Modifier()
1063  foo.toModifyProcess(bar)
1064  """
self.modify(process)
def Config.Modifier.modify (   self,
  process 
)
This applies all the registered modifiers to the passed in process

Definition at line 1046 of file Config.py.

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

Referenced by Config.Modifier.__call__().

1047  def modify(self,process):
1048  """This applies all the registered modifiers to the passed in process"""
1049  for m in self.__processModifiers:
1050  m(process)
1051  for o,m in self.__objectToModifiers:
1052  if isinstance(o,_Labelable):
1053  if o.hasLabel_():
1054  m(o)
1055  else:
1056  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 1033 of file Config.py.

1034  def toModify(self,obj, func=None,**kw):
1035  """This is used to register an action to be performed on the specific object. Two different forms are allowed
1036  Form 1: A callable object (e.g. function) can be passed as the second. This callable object is expected to take one argument
1037  which will be the object passed in as the first argument.
1038  Form 2: A list of parameter name, value pairs can be passed
1039  mod.toModify(foo, fred=cms.int32(7), barney = cms.double(3.14))
1040  """
1041  if func is not None and len(kw) != 0:
1042  raise TypeError("toModify takes either two arguments or one argument and key/value pairs")
1043  if func is not None:
1044  self.__objectToModifiers.append( (obj,func))
1045  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 1029 of file Config.py.

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

Member Data Documentation

Config.Modifier.__objectToModifiers
private

Definition at line 1027 of file Config.py.

Referenced by Config.Modifier.modify().

Config.Modifier.__processModifiers
private

Definition at line 1028 of file Config.py.

Referenced by Config.Modifier.modify().