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 22 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 35 of file AthConfigFlags.py.

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

Member Function Documentation

◆ __repr__()

python.AthConfigFlags.CfgFlag.__repr__ ( self)

Definition at line 92 of file AthConfigFlags.py.

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

◆ _validateType()

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

Definition at line 98 of file AthConfigFlags.py.

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

◆ 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 61 of file AthConfigFlags.py.

61 def get(self, flagdict=None):
62 """Get the value of the flag.
63
64 If the currently set value is a callable, a dictionary of all available
65 flags needs to be provided.
66 """
67
68 if self._value is not None:
69 return deepcopy(self._value)
70
71 # For cases where the value is intended to be None
72 # i.e. _setDef applied this value, we should not progress
73 if self._setDef is None:
74 return None
75
76 if not flagdict:
77 raise RuntimeError("Flag is using a callable but all flags are not available.")
78
79 # Have to call the method to obtain the default value, and then reuse it in all next accesses
80 if flagdict.locked():
81 # optimise future reads, drop possibility to update this flag ever
82 self._value = self._setDef(flagdict)
83 self._setDef = None
84 value = self._value
85 else:
86 # use function for as long as the flags are not locked
87 value = self._setDef(flagdict)
88
89 self._validateType(value)
90 return deepcopy(value)
91
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 47 of file AthConfigFlags.py.

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

Member Data Documentation

◆ __slots__

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

Definition at line 29 of file AthConfigFlags.py.

◆ _compatibleTypes

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

Definition at line 31 of file AthConfigFlags.py.

◆ _help

python.AthConfigFlags.CfgFlag._help = help
protected

Definition at line 43 of file AthConfigFlags.py.

◆ _setDef

python.AthConfigFlags.CfgFlag._setDef = value
protected

Definition at line 54 of file AthConfigFlags.py.

◆ _type

python.AthConfigFlags.CfgFlag._type = type
protected

Definition at line 42 of file AthConfigFlags.py.

◆ _value

python.AthConfigFlags.CfgFlag._value = None
protected

Definition at line 53 of file AthConfigFlags.py.


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