ATLAS Offline Software
Loading...
Searching...
No Matches
python.AthConfigFlags.CfgFlag Class Reference
Inheritance diagram for python.AthConfigFlags.CfgFlag:
Collaboration diagram for python.AthConfigFlags.CfgFlag:

Public Types

typedef HLT::TypeInformation::for_each_type_c< typenameEDMLIST::map, my_functor, my_result<>, my_arg< HLT::TypeInformation::get_cont, CONTAINER > >::type result

Public Member Functions

 __init__ (self, default, type=None, help=None)
 set (self, value)
 get (self, flagdict=None)
 __repr__ (self)

Protected Member Functions

 _validateType (self, value)

Protected Attributes

 _type = type
 _help = help
 _value = None
 _setDef = value

Static Protected Attributes

dict _compatibleTypes

Static Private Attributes

list __slots__ = ['_value', '_setDef', '_type', '_help']

Detailed Description

The base flag object.

A flag can be set to either a fixed value or a callable, which computes
the value based on other flags.

Definition at line 21 of file AthConfigFlags.py.

Member Typedef Documentation

◆ result

Definition at line 90 of file EDM_MasterSearch.h.

Constructor & Destructor Documentation

◆ __init__()

python.AthConfigFlags.CfgFlag.__init__ ( self,
default,
type = None,
help = None )
Initialise the flag with the default value.

Optionally set the type of the flag value and the help string.

Definition at line 34 of file AthConfigFlags.py.

34 def __init__(self, default, type=None, help=None):
35 """Initialise the flag with the default value.
36
37 Optionally set the type of the flag value and the help string.
38 """
39 if default is None:
40 raise ValueError("Default value of a flag must not be None")
41 self._type = type
42 self._help = help
43 self.set(default)
44 return
45

Member Function Documentation

◆ __repr__()

python.AthConfigFlags.CfgFlag.__repr__ ( self)

Definition at line 91 of file AthConfigFlags.py.

91 def __repr__(self):
92 if self._value is not None:
93 return repr(self._value)
94 else:
95 return "[function]"
96

◆ _validateType()

python.AthConfigFlags.CfgFlag._validateType ( self,
value )
protected

Definition at line 97 of file AthConfigFlags.py.

97 def _validateType(self, value):
98 if (self._type is None or value is None or
99 isinstance(value, self._type) or
100 (type(value), self._type) in self._compatibleTypes):
101 return
102 # Type mismatch
103 raise TypeError(f"Flag is of type '{self._type.__name__}', "
104 f"but value '{value}' of type '{type(value).__name__}' set.")
105
106

◆ get()

python.AthConfigFlags.CfgFlag.get ( self,
flagdict = None )
Get the value of the flag.

If the currently set value is a callable, a dictionary of all available
flags needs to be provided.

Definition at line 60 of file AthConfigFlags.py.

60 def get(self, flagdict=None):
61 """Get the value of the flag.
62
63 If the currently set value is a callable, a dictionary of all available
64 flags needs to be provided.
65 """
66
67 if self._value is not None:
68 return deepcopy(self._value)
69
70 # For cases where the value is intended to be None
71 # i.e. _setDef applied this value, we should not progress
72 if self._setDef is None:
73 return None
74
75 if not flagdict:
76 raise RuntimeError("Flag is using a callable but all flags are not available.")
77
78 # Have to call the method to obtain the default value, and then reuse it in all next accesses
79 if flagdict.locked():
80 # optimise future reads, drop possibility to update this flag ever
81 self._value = self._setDef(flagdict)
82 self._setDef = None
83 value = self._value
84 else:
85 # use function for as long as the flags are not locked
86 value = self._setDef(flagdict)
87
88 self._validateType(value)
89 return deepcopy(value)
90
T * get(TKey *tobj)
get a TObject* from a TKey* (why can't a TObject be a TKey?)
Definition hcg.cxx:130

◆ set()

python.AthConfigFlags.CfgFlag.set ( self,
value )
Set the value of the flag.

Can be a constant value or a callable.

Definition at line 46 of file AthConfigFlags.py.

46 def set(self, value):
47 """Set the value of the flag.
48
49 Can be a constant value or a callable.
50 """
51 if callable(value):
52 self._value=None
53 self._setDef=value
54 else:
55 self._value=value
56 self._setDef=None
57 self._validateType(self._value)
58 return
59
STL class.

Member Data Documentation

◆ __slots__

list python.AthConfigFlags.CfgFlag.__slots__ = ['_value', '_setDef', '_type', '_help']
staticprivate

Definition at line 28 of file AthConfigFlags.py.

◆ _compatibleTypes

python.AthConfigFlags.CfgFlag._compatibleTypes
staticprotected
Initial value:
= {
(int, float), # int can be assigned to float flag
}

Definition at line 30 of file AthConfigFlags.py.

◆ _help

python.AthConfigFlags.CfgFlag._help = help
protected

Definition at line 42 of file AthConfigFlags.py.

◆ _setDef

python.AthConfigFlags.CfgFlag._setDef = value
protected

Definition at line 53 of file AthConfigFlags.py.

◆ _type

python.AthConfigFlags.CfgFlag._type = type
protected

Definition at line 41 of file AthConfigFlags.py.

◆ _value

python.AthConfigFlags.CfgFlag._value = None
protected

Definition at line 52 of file AthConfigFlags.py.


The documentation for this class was generated from the following file: